From f2661bed185e14a8f5aa9a54565a8b938a7a10aa Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Wed, 9 Dec 2020 13:26:39 +0100 Subject: [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 --- clang/lib/Frontend/CompilerInvocation.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') 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 &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); }; } -- cgit v1.1