diff options
author | Rui Ueyama <ruiu@google.com> | 2014-05-06 23:52:19 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-05-06 23:52:19 +0000 |
commit | 360860933939865abd8a7d470847c0a67fc472c5 (patch) | |
tree | 37f65f49fbe83cff0d6157e72dd3260438187b01 /lld/unittests/DriverTests | |
parent | dff3ef80bbd499fb28651fc7990524fd2a612764 (diff) | |
download | bcm5719-llvm-360860933939865abd8a7d470847c0a67fc472c5.tar.gz bcm5719-llvm-360860933939865abd8a7d470847c0a67fc472c5.zip |
Expand nested input elements.
Previously only the toplevel elements were expanded by expandElements().
Now we recursively call getReplacements() to expand input elements even
if they are in, say, in a group.
llvm-svn: 208144
Diffstat (limited to 'lld/unittests/DriverTests')
-rw-r--r-- | lld/unittests/DriverTests/InputGraphTest.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lld/unittests/DriverTests/InputGraphTest.cpp b/lld/unittests/DriverTests/InputGraphTest.cpp index 8914cfa4ca4..c2b4a8ee8b4 100644 --- a/lld/unittests/DriverTests/InputGraphTest.cpp +++ b/lld/unittests/DriverTests/InputGraphTest.cpp @@ -38,12 +38,11 @@ class TestExpandFileNode : public SimpleFileNode { public: TestExpandFileNode(StringRef path) : SimpleFileNode(path) {} - /// Returns true as we want to expand this file - bool shouldExpand() const override { return true; } - /// Returns the elements replacing this node - range<InputGraph::InputElementIterT> expandElements() override { - return make_range(_expandElements.begin(), _expandElements.end()); + 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) { @@ -173,7 +172,15 @@ TEST_F(InputGraphTest, Normalize) { expandFile->addElement(createFile1("file3")); expandFile->addElement(createFile1("file4")); _graph->addInputElement(std::move(expandFile)); - _graph->addInputElement(createFile2("file5", "file6")); + + std::unique_ptr<Group> group(new Group()); + std::unique_ptr<TestExpandFileNode> expandFile2( + new TestExpandFileNode("node")); + expandFile2->addElement(createFile1("file5")); + group->addFile(std::move(expandFile2)); + _graph->addInputElement(std::move(group)); + + _graph->addInputElement(createFile1("file6")); _graph->normalize(); EXPECT_EQ("file1", getNext()); |