[lld] r188318 - [PECOFF] Handle "--" option explicitly

Hans Wennborg hans at hanshq.net
Tue Aug 13 14:44:45 PDT 2013


Author: hans
Date: Tue Aug 13 16:44:44 2013
New Revision: 188318

URL: http://llvm.org/viewvc/llvm-project?rev=188318&view=rev
Log:
[PECOFF] Handle "--" option explicitly

This used to be handled automagically by the option parsing library,
but after LLVM r188314, we should handle it ourselves.

No functionality change, but adds a test.

Modified:
    lld/trunk/lib/Driver/WinLinkDriver.cpp
    lld/trunk/lib/Driver/WinLinkOptions.td
    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp

Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=188318&r1=188317&r2=188318&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Tue Aug 13 16:44:44 2013
@@ -428,6 +428,14 @@ bool WinLinkDriver::parse(int argc, cons
     inputPaths.push_back((*it)->getValue());
   }
 
+  // Arguments after "--" are interpreted as filenames even if they
+  // start with a hypen or a slash. This is not compatible with link.exe
+  // but useful for us to test lld on Unix.
+  if (llvm::opt::Arg *dashdash = parsedArgs->getLastArg(OPT_DASH_DASH)) {
+    for (const StringRef value : dashdash->getValues())
+      inputPaths.push_back(value);
+  }
+
   // Add input files specified via the command line.
   for (const StringRef path : inputPaths)
     context.appendInputFileOrLibrary(path);

Modified: lld/trunk/lib/Driver/WinLinkOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkOptions.td?rev=188318&r1=188317&r2=188318&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkOptions.td (original)
+++ lld/trunk/lib/Driver/WinLinkOptions.td Tue Aug 13 16:44:44 2013
@@ -51,3 +51,5 @@ def nologo : F<"nologo">;
 
 def help : F<"help">;
 def help_q : F<"?">, Alias<help>;
+
+def DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>;

Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=188318&r1=188317&r2=188318&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Tue Aug 13 16:44:44 2013
@@ -221,4 +221,15 @@ TEST_F(WinLinkParserTest, Nologo) {
   EXPECT_EQ("a.obj", inputFile(0));
 }
 
+TEST_F(WinLinkParserTest, DashDash) {
+  EXPECT_FALSE(parse("link.exe", "/subsystem:console", "/out:a.exe",
+        "a.obj", "--", "b.obj", "-c.obj", nullptr));
+  EXPECT_EQ(llvm::COFF::IMAGE_SUBSYSTEM_WINDOWS_CUI, _context.getSubsystem());
+  EXPECT_EQ("a.exe", _context.outputPath());
+  EXPECT_EQ(3, inputFileCount());
+  EXPECT_EQ("a.obj", inputFile(0));
+  EXPECT_EQ("b.obj", inputFile(1));
+  EXPECT_EQ("-c.obj", inputFile(2));
+}
+
 } // end anonymous namespace





More information about the llvm-commits mailing list