]> granicus.if.org Git - llvm/commitdiff
lld-link: Make /debugtype: option work better
authorNico Weber <nicolasweber@gmx.de>
Fri, 5 Jul 2019 11:28:31 +0000 (11:28 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 5 Jul 2019 11:28:31 +0000 (11:28 +0000)
- 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365182 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Option/Arg.h

index d3623a0c1e4b4c0e51a0b023e0da02225436bf19..8c4787051cf7f5943410e2c6abc64ceb9f07a827 100644 (file)
@@ -70,7 +70,15 @@ public:
   ~Arg();
 
   const Option &getOption() const { return Opt; }
+
+  /// Returns the used prefix and name of the option:
+  /// For `--foo=bar`, returns `--foo=`.
+  /// This is often the wrong function to call:
+  /// * Use `getValue()` to get `bar`.
+  /// * Use `getAsString()` to get a string suitable for printing an Arg in
+  ///   a diagnostic.
   StringRef getSpelling() const { return Spelling; }
+
   unsigned getIndex() const { return Index; }
 
   /// Return the base argument which generated this arg.