diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -338,7 +338,7 @@ : Flag<["-"], flag.Spelling>, Flags, HelpText, MarshallingInfoBooleanFlag, + other.RecordName>, ImpliedByAnyOf {} // Generates TableGen records for two command line flags that control the same diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -197,12 +197,11 @@ }; } -static auto makeBooleanOptionDenormalizer(bool Value, - const char *OtherSpelling) { - return [Value, OtherSpelling]( - SmallVectorImpl &Args, const char *Spelling, - CompilerInvocation::StringAllocator, unsigned, bool KeyPath) { - Args.push_back(KeyPath == Value ? Spelling : OtherSpelling); +static auto makeBooleanOptionDenormalizer(bool Value) { + return [Value](SmallVectorImpl &Args, const char *Spelling, + CompilerInvocation::StringAllocator, unsigned, bool KeyPath) { + if (KeyPath == Value) + Args.push_back(Spelling); }; } diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp --- a/clang/unittests/Frontend/CompilerInvocationTest.cpp +++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp @@ -269,7 +269,7 @@ Invocation.generateCC1CommandLine(GeneratedArgs, *this); - ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdebug-pass-manager"))); + ASSERT_EQ(count(GeneratedArgs, StringRef("-fdebug-pass-manager")), 1); ASSERT_THAT(GeneratedArgs, Not(Contains(StrEq("-fno-debug-pass-manager")))); } diff --git a/llvm/include/llvm/Option/OptParser.td b/llvm/include/llvm/Option/OptParser.td --- a/llvm/include/llvm/Option/OptParser.td +++ b/llvm/include/llvm/Option/OptParser.td @@ -176,10 +176,10 @@ // Marshalling info for booleans. Applied to the flag setting keypath to false. class MarshallingInfoBooleanFlag + code other_value, code other_name> : MarshallingInfoFlag { code Normalizer = "makeBooleanOptionNormalizer("#value#", "#other_value#", OPT_"#other_name#")"; - code Denormalizer = "makeBooleanOptionDenormalizer("#value#", \""#other_spelling#"\")"; + code Denormalizer = "makeBooleanOptionDenormalizer("#value#")"; } // Mixins for additional marshalling attributes.