[lld] r227367 - ELF: add a unit test for --as-needed.
Rui Ueyama
ruiu at google.com
Wed Jan 28 13:01:24 PST 2015
Author: ruiu
Date: Wed Jan 28 15:01:24 2015
New Revision: 227367
URL: http://llvm.org/viewvc/llvm-project?rev=227367&view=rev
Log:
ELF: add a unit test for --as-needed.
Modified:
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=227367&r1=227366&r2=227367&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Wed Jan 28 15:01:24 2015
@@ -613,7 +613,9 @@ bool GnuLdDriver::parse(int argc, const
ErrorOr<StringRef> pathOrErr = findFile(*ctx, path, dashL);
if (std::error_code ec = pathOrErr.getError()) {
auto file = llvm::make_unique<ErrorFile>(path, ec);
- ctx->getNodes().push_back(llvm::make_unique<FileNode>(std::move(file)));
+ auto node = llvm::make_unique<FileNode>(std::move(file));
+ node->setAsNeeded(asNeeded);
+ ctx->getNodes().push_back(std::move(node));
break;
}
StringRef realpath = pathOrErr.get();
Modified: lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp?rev=227367&r1=227366&r2=227367&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp Wed Jan 28 15:01:24 2015
@@ -147,6 +147,19 @@ TEST_F(GnuLdParserTest, DefsymMisssingVa
EXPECT_FALSE(parse("ld", "a.o", "--defsym=sym=", nullptr));
}
+// --as-needed
+
+TEST_F(GnuLdParserTest, AsNeeded) {
+ EXPECT_TRUE(parse("ld", "a.o", "--as-needed", "b.o", "c.o",
+ "--no-as-needed", "d.o", nullptr));
+ std::vector<std::unique_ptr<Node>> &nodes = _context->getNodes();
+ EXPECT_EQ((size_t)4, nodes.size());
+ EXPECT_FALSE(cast<FileNode>(nodes[0].get())->asNeeded());
+ EXPECT_TRUE(cast<FileNode>(nodes[1].get())->asNeeded());
+ EXPECT_TRUE(cast<FileNode>(nodes[2].get())->asNeeded());
+ EXPECT_FALSE(cast<FileNode>(nodes[3].get())->asNeeded());
+}
+
// Linker script
TEST_F(GnuLdParserTest, LinkerScriptGroup) {
More information about the llvm-commits
mailing list