[lld] r195289 - [PECOFF] Do not check if library is already added.

Rui Ueyama ruiu at google.com
Wed Nov 20 16:43:46 PST 2013


Author: ruiu
Date: Wed Nov 20 18:43:46 2013
New Revision: 195289

URL: http://llvm.org/viewvc/llvm-project?rev=195289&view=rev
Log:
[PECOFF] Do not check if library is already added.

Modified:
    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp

Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=195289&r1=195288&r2=195289&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Wed Nov 20 18:43:46 2013
@@ -203,11 +203,6 @@ public:
     return _noDefaultLibs.count(path) == 1;
   }
 
-  void addDefaultLib(StringRef path) { _defaultLibs.insert(path); }
-  bool hasDefaultLib(StringRef path) const {
-    return _defaultLibs.count(path) == 1;
-  }
-
   void setNoDefaultLibAll(bool val) { _noDefaultLibAll = val; }
   bool getNoDefaultLibAll() const { return _noDefaultLibAll; }
 
@@ -300,11 +295,6 @@ private:
   // The set to store /nodefaultlib arguments.
   std::set<std::string> _noDefaultLibs;
 
-  // A set containing all the library files specified by /defaultlib. This is to
-  // keep track what files are already added to the input graph, in order to
-  // prevent adding the same file more than once to the input graph.
-  std::set<std::string> _defaultLibs;
-
   std::vector<StringRef> _inputSearchPaths;
   std::unique_ptr<Reader> _reader;
   std::unique_ptr<Writer> _writer;

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=195289&r1=195288&r2=195289&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Wed Nov 20 18:43:46 2013
@@ -910,15 +910,11 @@ WinLinkDriver::parse(int argc, const cha
 
   // Add the libraries specified by /defaultlib unless they are already added
   // nor blacklisted by /nodefaultlib.
-  if (!ctx.getNoDefaultLibAll()) {
-    for (const StringRef path : defaultLibs) {
-      if (!ctx.hasNoDefaultLib(path) && !ctx.hasDefaultLib(path)) {
+  if (!ctx.getNoDefaultLibAll())
+    for (const StringRef path : defaultLibs)
+      if (!ctx.hasNoDefaultLib(path))
         inputElements.push_back(std::unique_ptr<InputElement>(
             new PECOFFLibraryNode(ctx, path)));
-	ctx.addDefaultLib(path);
-      }
-    }
-  }
 
   if (inputElements.empty() && !isReadingDirectiveSection) {
     diagnostics << "No input files\n";

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=195289&r1=195288&r2=195289&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Wed Nov 20 18:43:46 2013
@@ -294,9 +294,10 @@ TEST_F(WinLinkParserTest, DefaultLib) {
 TEST_F(WinLinkParserTest, DefaultLibDuplicates) {
   EXPECT_TRUE(parse("link.exe", "/defaultlib:user32.lib",
                     "/defaultlib:user32.lib", "a.obj", nullptr));
-  EXPECT_EQ(2, inputFileCount());
+  EXPECT_EQ(3, inputFileCount());
   EXPECT_EQ("a.obj", inputFile(0));
   EXPECT_EQ("user32.lib", inputFile(1));
+  EXPECT_EQ("user32.lib", inputFile(2));
 }
 
 TEST_F(WinLinkParserTest, NoDefaultLib) {





More information about the llvm-commits mailing list