diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2020-12-09 13:26:39 +0100 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2020-12-16 09:44:54 +0100 |
commit | f2661bed185e14a8f5aa9a54565a8b938a7a10aa (patch) | |
tree | 50563a8d305686eaefc5abd916a54ffcf6cae797 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 95114f21f5bf1704672dadb45ca7c25efca72e03 (diff) | |
download | llvm-f2661bed185e14a8f5aa9a54565a8b938a7a10aa.zip llvm-f2661bed185e14a8f5aa9a54565a8b938a7a10aa.tar.gz llvm-f2661bed185e14a8f5aa9a54565a8b938a7a10aa.tar.bz2 |
[clang][cli] Prevent double denormalization
If both flags created through BoolOption are CC1Option and the keypath has a non-default or non-implied value, the denormalizer gets called twice. If the denormalizer has the ability to generate both flags, we can end up generating the same flag twice.
Reviewed By: dexonsmith, Bigcheese
Differential Revision: https://reviews.llvm.org/D93094
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 1a863a7..bdadaa9 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -197,12 +197,11 @@ static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue, }; } -static auto makeBooleanOptionDenormalizer(bool Value, - const char *OtherSpelling) { - return [Value, OtherSpelling]( - SmallVectorImpl<const char *> &Args, const char *Spelling, - CompilerInvocation::StringAllocator, unsigned, bool KeyPath) { - Args.push_back(KeyPath == Value ? Spelling : OtherSpelling); +static auto makeBooleanOptionDenormalizer(bool Value) { + return [Value](SmallVectorImpl<const char *> &Args, const char *Spelling, + CompilerInvocation::StringAllocator, unsigned, bool KeyPath) { + if (KeyPath == Value) + Args.push_back(Spelling); }; } |