diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h index 76677dd519e0..45caf53bdb22 100644 --- a/lld/include/lld/Core/InputGraph.h +++ b/lld/include/lld/Core/InputGraph.h @@ -202,6 +202,14 @@ public: elem->resetNextIndex(); } + /// \brief Parse the group members. + error_code parse(const LinkingContext &ctx, raw_ostream &diag) override { + for (auto &ei : _elements) + if (error_code ec = ei->parse(ctx, diag)) + return ec; + return error_code::success(); + } + uint32_t getResolveState() const override; void setResolveState(uint32_t) override; ErrorOr getNextFile() override; diff --git a/lld/include/lld/Driver/GnuLdInputGraph.h b/lld/include/lld/Driver/GnuLdInputGraph.h index d8142f5d76c5..522af99079c0 100644 --- a/lld/include/lld/Driver/GnuLdInputGraph.h +++ b/lld/include/lld/Driver/GnuLdInputGraph.h @@ -92,21 +92,6 @@ private: std::unique_ptr _archiveFile; }; -/// \brief Represents a ELF control node -class ELFGroup : public Group { -public: - ELFGroup(const ELFLinkingContext &, int64_t ordinal) - : Group(ordinal) {} - - /// \brief Parse the group members. - error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override { - for (auto &ei : _elements) - if (error_code ec = ei->parse(ctx, diagnostics)) - return ec; - return error_code::success(); - } -}; - /// \brief Parse GNU Linker scripts. class GNULdScript : public FileNode { public: diff --git a/lld/include/lld/Driver/WinLinkInputGraph.h b/lld/include/lld/Driver/WinLinkInputGraph.h index e5b816ca26d1..2ead1706b896 100644 --- a/lld/include/lld/Driver/WinLinkInputGraph.h +++ b/lld/include/lld/Driver/WinLinkInputGraph.h @@ -61,12 +61,9 @@ public: PECOFFGroup(PECOFFLinkingContext &ctx) : Group(0), _ctx(ctx) {} /// \brief Parse the group members. - error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override { + error_code parse(const LinkingContext &ctx, raw_ostream &diag) override { std::lock_guard lock(_ctx.getMutex()); - for (auto &elem : _elements) - if (error_code ec = elem->parse(ctx, diagnostics)) - return ec; - return error_code::success(); + return Group::parse(ctx, diag); } private: diff --git a/lld/lib/Driver/GnuLdDriver.cpp b/lld/lib/Driver/GnuLdDriver.cpp index fc7dbffa505b..473125338374 100644 --- a/lld/lib/Driver/GnuLdDriver.cpp +++ b/lld/lib/Driver/GnuLdDriver.cpp @@ -430,7 +430,7 @@ bool GnuLdDriver::parse(int argc, const char *argv[], } case OPT_start_group: { - std::unique_ptr group(new ELFGroup(*ctx, index++)); + std::unique_ptr group(new Group(index++)); groupStack.push(group.get()); inputGraph->addInputElement(std::move(group)); break; diff --git a/lld/lib/Driver/GnuLdInputGraph.cpp b/lld/lib/Driver/GnuLdInputGraph.cpp index f65dcc5f178a..cd3eb8787f20 100644 --- a/lld/lib/Driver/GnuLdInputGraph.cpp +++ b/lld/lib/Driver/GnuLdInputGraph.cpp @@ -79,8 +79,7 @@ error_code ELFGNULdScript::parse(const LinkingContext &ctx, return ec; for (const auto &c : _linkerScript->_commands) { if (auto group = dyn_cast(c)) { - std::unique_ptr groupStart( - new ELFGroup(_elfLinkingContext, index++)); + std::unique_ptr groupStart(new Group(index++)); for (auto &path : group->getPaths()) { // TODO : Propagate Set WholeArchive/dashlPrefix auto inputNode = new ELFFileNode( diff --git a/lld/unittests/DriverTests/InputGraphTest.cpp b/lld/unittests/DriverTests/InputGraphTest.cpp index 4621528b52fa..cb88c939945a 100644 --- a/lld/unittests/DriverTests/InputGraphTest.cpp +++ b/lld/unittests/DriverTests/InputGraphTest.cpp @@ -38,15 +38,6 @@ public: void resetNextIndex() override { FileNode::resetNextIndex(); } }; -class MyGroupNode : public Group { -public: - MyGroupNode(int64_t ordinal) : Group(ordinal) {} - - error_code parse(const LinkingContext &, raw_ostream &) override { - return error_code::success(); - } -}; - class MyExpandFileNode : public SimpleFileNode { public: MyExpandFileNode(StringRef path, int64_t ordinal) @@ -164,7 +155,7 @@ TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) { // Create a group node with two elements // an file node which looks like an archive and // two file nodes - std::unique_ptr mygroup(new MyGroupNode(1)); + std::unique_ptr mygroup(new Group(1)); std::unique_ptr myarchive(new MyFileNode("archive_file", 2)); std::vector > objfiles_group; std::unique_ptr obj_1(new SimpleFile("objfile_1")); @@ -253,7 +244,7 @@ TEST_F(InputGraphTest, AddNodeWithGroupIteration) { // Create a group node with two elements // an file node which looks like an archive and // two file nodes - std::unique_ptr mygroup(new MyGroupNode(1)); + std::unique_ptr mygroup(new Group(1)); std::unique_ptr myarchive(new MyFileNode("archive_file", 2)); std::vector > objfiles_group; std::unique_ptr obj_1(new SimpleFile("objfile_1"));