Remove dead code.

Now every InputElement has exactly one File in it, so "expand"
method is now no-op.

llvm-svn: 225769
This commit is contained in:
Rui Ueyama 2015-01-13 05:59:17 +00:00
parent 906ed278b9
commit d5bb5c2bfe
4 changed files with 1 additions and 53 deletions

View File

@ -63,9 +63,6 @@ public:
/// \brief Adds a node at the beginning of the InputGraph
void addInputElementFront(std::unique_ptr<InputElement>);
/// Normalize the InputGraph. It calls getReplacements() on each element.
void normalize();
InputElementVectorT &inputElements() {
return _inputArgs;
}
@ -116,11 +113,6 @@ public:
/// Get the next file to be processed by the resolver
virtual File *getNextFile() = 0;
/// Get the elements that we want to expand with.
virtual bool getReplacements(InputGraph::InputElementVectorT &) {
return false;
}
protected:
Kind _kind; // The type of the Element
};
@ -189,11 +181,10 @@ public:
_files.push_back(std::move(ai));
}
bool getReplacements(InputGraph::InputElementVectorT &result) override;
/// \brief Return the next File thats part of this node to the
/// resolver.
File *getNextFile() override {
assert(_files.size() == 1);
if (_nextFileIndex == _files.size())
return nullptr;
return _files[_nextFileIndex++].get();

View File

@ -49,16 +49,6 @@ InputElement *InputGraph::getNextInputElement() {
return elem;
}
void InputGraph::normalize() {
std::vector<std::unique_ptr<InputElement>> vec;
for (std::unique_ptr<InputElement> &elt : _inputArgs) {
if (elt->getReplacements(vec))
continue;
vec.push_back(std::move(elt));
}
_inputArgs = std::move(vec);
}
// If we are at the end of a group, return its size (which indicates
// how many files we need to go back in the command line).
// Returns 0 if we are not at the end of a group.
@ -78,14 +68,6 @@ void InputGraph::skipGroup() {
_nextElementIndex++;
}
bool FileNode::getReplacements(InputGraph::InputElementVectorT &result) {
if (_files.size() < 2)
return false;
for (std::unique_ptr<File> &file : _files)
result.push_back(llvm::make_unique<SimpleFileNode>(_path, std::move(file)));
return true;
}
std::error_code FileNode::parse(const LinkingContext &, raw_ostream &) {
for (std::unique_ptr<File> &file : _files)
if (std::error_code ec = file->parse())

View File

@ -77,7 +77,6 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
InputGraph &inputGraph = context.getInputGraph();
if (!inputGraph.size())
return false;
inputGraph.normalize();
bool fail = false;

View File

@ -31,13 +31,6 @@ class TestExpandFileNode : public SimpleFileNode {
public:
TestExpandFileNode(StringRef path) : SimpleFileNode(path) {}
/// Returns the elements replacing this node
bool getReplacements(InputGraph::InputElementVectorT &result) override {
for (std::unique_ptr<InputElement> &elt : _expandElements)
result.push_back(std::move(elt));
return true;
}
void addElement(std::unique_ptr<InputElement> element) {
_expandElements.push_back(std::move(element));
}
@ -88,20 +81,3 @@ TEST_F(InputGraphTest, File) {
EXPECT_EQ("file1", getNext());
expectEnd();
}
// Node expansion tests
TEST_F(InputGraphTest, Normalize) {
_graph->addInputElement(createFile("file1"));
std::unique_ptr<TestExpandFileNode> expandFile(
new TestExpandFileNode("node"));
expandFile->addElement(createFile("file2"));
expandFile->addElement(createFile("file3"));
_graph->addInputElement(std::move(expandFile));
_graph->normalize();
EXPECT_EQ("file1", getNext());
EXPECT_EQ("file2", getNext());
EXPECT_EQ("file3", getNext());
expectEnd();
}