[lld] r205375 - Merge ELFGroup with Group.
Rui Ueyama
ruiu at google.com
Tue Apr 1 16:55:20 PDT 2014
Author: ruiu
Date: Tue Apr 1 18:55:20 2014
New Revision: 205375
URL: http://llvm.org/viewvc/llvm-project?rev=205375&view=rev
Log:
Merge ELFGroup with Group.
Group class is designed for GNU LD's --start-group and --end-group. There's
no obvious need to have two classes for it -- one as an abstract base class
and the other as a concrete class.
Modified:
lld/trunk/include/lld/Core/InputGraph.h
lld/trunk/include/lld/Driver/GnuLdInputGraph.h
lld/trunk/include/lld/Driver/WinLinkInputGraph.h
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/lib/Driver/GnuLdInputGraph.cpp
lld/trunk/unittests/DriverTests/InputGraphTest.cpp
Modified: lld/trunk/include/lld/Core/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=205375&r1=205374&r2=205375&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Tue Apr 1 18:55:20 2014
@@ -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<File &> getNextFile() override;
Modified: lld/trunk/include/lld/Driver/GnuLdInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/GnuLdInputGraph.h?rev=205375&r1=205374&r2=205375&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/GnuLdInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/GnuLdInputGraph.h Tue Apr 1 18:55:20 2014
@@ -92,21 +92,6 @@ private:
std::unique_ptr<const ArchiveLibraryFile> _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:
Modified: lld/trunk/include/lld/Driver/WinLinkInputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkInputGraph.h?rev=205375&r1=205374&r2=205375&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/WinLinkInputGraph.h (original)
+++ lld/trunk/include/lld/Driver/WinLinkInputGraph.h Tue Apr 1 18:55:20 2014
@@ -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<std::recursive_mutex> 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:
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=205375&r1=205374&r2=205375&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Tue Apr 1 18:55:20 2014
@@ -430,7 +430,7 @@ bool GnuLdDriver::parse(int argc, const
}
case OPT_start_group: {
- std::unique_ptr<Group> group(new ELFGroup(*ctx, index++));
+ std::unique_ptr<Group> group(new Group(index++));
groupStack.push(group.get());
inputGraph->addInputElement(std::move(group));
break;
Modified: lld/trunk/lib/Driver/GnuLdInputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdInputGraph.cpp?rev=205375&r1=205374&r2=205375&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdInputGraph.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdInputGraph.cpp Tue Apr 1 18:55:20 2014
@@ -79,8 +79,7 @@ error_code ELFGNULdScript::parse(const L
return ec;
for (const auto &c : _linkerScript->_commands) {
if (auto group = dyn_cast<script::Group>(c)) {
- std::unique_ptr<Group> groupStart(
- new ELFGroup(_elfLinkingContext, index++));
+ std::unique_ptr<Group> groupStart(new Group(index++));
for (auto &path : group->getPaths()) {
// TODO : Propagate Set WholeArchive/dashlPrefix
auto inputNode = new ELFFileNode(
Modified: lld/trunk/unittests/DriverTests/InputGraphTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/InputGraphTest.cpp?rev=205375&r1=205374&r2=205375&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/InputGraphTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/InputGraphTest.cpp Tue Apr 1 18:55:20 2014
@@ -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, AddNodeWithFilesA
// Create a group node with two elements
// an file node which looks like an archive and
// two file nodes
- std::unique_ptr<MyGroupNode> mygroup(new MyGroupNode(1));
+ std::unique_ptr<Group> mygroup(new Group(1));
std::unique_ptr<MyFileNode> myarchive(new MyFileNode("archive_file", 2));
std::vector<std::unique_ptr<File> > objfiles_group;
std::unique_ptr<SimpleFile> obj_1(new SimpleFile("objfile_1"));
@@ -253,7 +244,7 @@ TEST_F(InputGraphTest, AddNodeWithGroupI
// Create a group node with two elements
// an file node which looks like an archive and
// two file nodes
- std::unique_ptr<MyGroupNode> mygroup(new MyGroupNode(1));
+ std::unique_ptr<Group> mygroup(new Group(1));
std::unique_ptr<MyFileNode> myarchive(new MyFileNode("archive_file", 2));
std::vector<std::unique_ptr<File> > objfiles_group;
std::unique_ptr<SimpleFile> obj_1(new SimpleFile("objfile_1"));
More information about the llvm-commits
mailing list