From d5bb5c2bfeda4b9ae6e998ba02a5e81fe6423590 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 13 Jan 2015 05:59:17 +0000 Subject: [PATCH] Remove dead code. Now every InputElement has exactly one File in it, so "expand" method is now no-op. llvm-svn: 225769 --- lld/include/lld/Core/InputGraph.h | 11 +---------- lld/lib/Core/InputGraph.cpp | 18 ------------------ lld/lib/Driver/Driver.cpp | 1 - lld/unittests/DriverTests/InputGraphTest.cpp | 24 ------------------------ 4 files changed, 1 insertion(+), 53 deletions(-) diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h index 234b7a2..65eb060 100644 --- a/lld/include/lld/Core/InputGraph.h +++ b/lld/include/lld/Core/InputGraph.h @@ -63,9 +63,6 @@ public: /// \brief Adds a node at the beginning of the InputGraph void addInputElementFront(std::unique_ptr); - /// 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(); diff --git a/lld/lib/Core/InputGraph.cpp b/lld/lib/Core/InputGraph.cpp index e8ab07c..1ecd1eb 100644 --- a/lld/lib/Core/InputGraph.cpp +++ b/lld/lib/Core/InputGraph.cpp @@ -49,16 +49,6 @@ InputElement *InputGraph::getNextInputElement() { return elem; } -void InputGraph::normalize() { - std::vector> vec; - for (std::unique_ptr &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 : _files) - result.push_back(llvm::make_unique(_path, std::move(file))); - return true; -} - std::error_code FileNode::parse(const LinkingContext &, raw_ostream &) { for (std::unique_ptr &file : _files) if (std::error_code ec = file->parse()) diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp index 4d0fe6e..d97cff4 100644 --- a/lld/lib/Driver/Driver.cpp +++ b/lld/lib/Driver/Driver.cpp @@ -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; diff --git a/lld/unittests/DriverTests/InputGraphTest.cpp b/lld/unittests/DriverTests/InputGraphTest.cpp index 5c14213..a870a9c 100644 --- a/lld/unittests/DriverTests/InputGraphTest.cpp +++ b/lld/unittests/DriverTests/InputGraphTest.cpp @@ -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 &elt : _expandElements) - result.push_back(std::move(elt)); - return true; - } - void addElement(std::unique_ptr 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 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(); -} -- 2.7.4