[llvm] r365186 - Make joined instances of JoinedOrSeparate flags point to the unaliased args, like all other arg types do

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


Author: nico
Date: Fri Jul  5 04:45:24 2019
New Revision: 365186

URL: http://llvm.org/viewvc/llvm-project?rev=365186&view=rev
Log:
Make joined instances of JoinedOrSeparate flags point to the unaliased args, like all other arg types do

This fixes an 8-year-old regression. r105763 made it so that aliases
always refer to the unaliased option – but it missed the "joined" branch
of JoinedOrSeparate flags. (r162231 then made the Args classes
non-virtual, and r169344 moved them from clang to llvm.)

Back then, there was no JoinedOrSeparate flag that was an alias, so it
wasn't observable. Now /U in CLCompatOptions is a JoinedOrSeparate alias
in clang, and warn_slash_u_filename incorrectly used the aliased arg id
(using the unaliased one isn't really a regression since that warning
checks if the undefined macro contains slash or backslash and only then
emits the warning – and no valid use will pass "-Ufoo/bar" or similar).

Also, lld has many JoinedOrSeparate aliases, and due to this bug it had
to explicitly call `getUnaliasedOption()` in a bunch of places, even
though that shouldn't be necessary by design. After this fix in Option,
these calls really don't have an effect any more, so remove them.

No intended behavior change.

(I accidentally fixed this bug while working on PR29106 but then
wondered why the warn_slash_u_filename broke. When I figured it out, I
thought it would make sense to land this in a separate commit.)

Differential Revision: https://reviews.llvm.org/D64156

Modified:
    llvm/trunk/lib/Option/Option.cpp

Modified: llvm/trunk/lib/Option/Option.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/Option.cpp?rev=365186&r1=365185&r2=365186&view=diff
==============================================================================
--- llvm/trunk/lib/Option/Option.cpp (original)
+++ llvm/trunk/lib/Option/Option.cpp Fri Jul  5 04:45:24 2019
@@ -207,7 +207,7 @@ Arg *Option::accept(const ArgList &Args,
     // FIXME: Avoid strlen.
     if (ArgSize != strlen(Args.getArgString(Index))) {
       const char *Value = Args.getArgString(Index) + ArgSize;
-      return new Arg(*this, Spelling, Index++, Value);
+      return new Arg(UnaliasedOption, Spelling, Index++, Value);
     }
 
     // Otherwise it must be separate.




More information about the llvm-commits mailing list