[lld] r365182 - lld-link: Make /debugtype: option work better

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 5 04:28:31 PDT 2019


Author: nico
Date: Fri Jul  5 04:28:31 2019
New Revision: 365182

URL: http://llvm.org/viewvc/llvm-project?rev=365182&view=rev
Log:
lld-link: Make /debugtype: option work better

- The code tried to pass false to split()'s KeepEmpty parameter, but
  instead passed it to MaxSplit. As a result, it would never split on
  commas. This has been broken since the flag was added in r278056.

- The code used getSpelling() for getting the argument's values, but
  getSpelling() always returns the `/debugtype:` prefix without any
  values. So if any /debugtype: flag was passed, it always resulted in
  an "unknown option:" warning. (The warning code then used the correct
  getValue() for printing the invalid option, so the warning looked
  kind of like it made sense.) This regressed in r342894.

Slightly improve the test coverage of this feature (but since I don't
know what this flag actually does, there's still no test for the correct
semantics), and add a comment to getSpelling() explaining what it does.

Modified:
    lld/trunk/COFF/Driver.cpp
    lld/trunk/test/COFF/invalid-debug-type.test

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=365182&r1=365181&r2=365182&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Fri Jul  5 04:28:31 2019
@@ -642,7 +642,8 @@ static unsigned parseDebugTypes(const op
 
   if (auto *A = Args.getLastArg(OPT_debugtype)) {
     SmallVector<StringRef, 3> Types;
-    A->getSpelling().split(Types, ',', /*KeepEmpty=*/false);
+    StringRef(A->getValue())
+        .split(Types, ',', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 
     for (StringRef Type : Types) {
       unsigned V = StringSwitch<unsigned>(Type.lower())
@@ -651,7 +652,7 @@ static unsigned parseDebugTypes(const op
                        .Case("fixup", static_cast<unsigned>(DebugType::Fixup))
                        .Default(0);
       if (V == 0) {
-        warn("/debugtype: unknown option: " + Twine(A->getValue()));
+        warn("/debugtype: unknown option '" + Type + "'");
         continue;
       }
       DebugTypes |= V;

Modified: lld/trunk/test/COFF/invalid-debug-type.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/invalid-debug-type.test?rev=365182&r1=365181&r2=365182&view=diff
==============================================================================
--- lld/trunk/test/COFF/invalid-debug-type.test (original)
+++ lld/trunk/test/COFF/invalid-debug-type.test Fri Jul  5 04:28:31 2019
@@ -1,6 +1,11 @@
 # RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj
 # RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj
-# RUN: lld-link /debug /debugtype:invalid /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \
-# RUN:   %t1.obj %t2.obj 2>&1 | FileCheck %s
+# RUN: lld-link /debug /debugtype:invalid /pdb:%t.pdb /dll /out:%t.dll \
+# RUN:     /entry:main /nodefaultlib %t1.obj %t2.obj 2>&1 | FileCheck %s
+# CHECK: /debugtype: unknown option 'invalid'
 
-# CHECK: /debugtype: unknown option: invalid
\ No newline at end of file
+# RUN: lld-link /debug /debugtype:invalid,foo /pdb:%t.pdb /dll /out:%t.dll \
+# RUN:     /entry:main /nodefaultlib %t1.obj %t2.obj 2>&1 | \
+# RUN:     FileCheck --check-prefix=TWO %s
+# TWO: /debugtype: unknown option 'invalid'
+# TWO: /debugtype: unknown option 'foo'




More information about the llvm-commits mailing list