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 @@ -192,10 +192,11 @@ /// unnecessary template instantiations and just ignore it with a variadic /// argument. static void denormalizeSimpleFlag(SmallVectorImpl &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator, Option::OptionClass, unsigned, /*T*/...) { - Args.push_back(Spelling); + // Spelling is already allocated or a static string, no need to call SA. + Args.push_back(Spelling.getSingleStringRef().data()); } template static constexpr bool is_uint64_t_convertible() { @@ -232,16 +233,17 @@ } static auto makeBooleanOptionDenormalizer(bool Value) { - return [Value](SmallVectorImpl &Args, const char *Spelling, + return [Value](SmallVectorImpl &Args, const Twine &Spelling, CompilerInvocation::StringAllocator, Option::OptionClass, unsigned, bool KeyPath) { if (KeyPath == Value) - Args.push_back(Spelling); + // Spelling is already allocated or a static string, no need to call SA. + Args.push_back(Spelling.getSingleStringRef().data()); }; } static void denormalizeStringImpl(SmallVectorImpl &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned, const Twine &Value) { @@ -249,7 +251,8 @@ case Option::SeparateClass: case Option::JoinedOrSeparateClass: case Option::JoinedAndSeparateClass: - Args.push_back(Spelling); + // Spelling is already allocated or a static string, no need to call SA. + Args.push_back(Spelling.getSingleStringRef().data()); Args.push_back(SA(Value)); break; case Option::JoinedClass: @@ -264,7 +267,7 @@ template static void -denormalizeString(SmallVectorImpl &Args, const char *Spelling, +denormalizeString(SmallVectorImpl &Args, const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex, T Value) { denormalizeStringImpl(Args, Spelling, SA, OptClass, TableIndex, Twine(Value)); @@ -309,7 +312,7 @@ } static void denormalizeSimpleEnumImpl(SmallVectorImpl &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex, unsigned Value) { @@ -326,7 +329,7 @@ template static void denormalizeSimpleEnum(SmallVectorImpl &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex, T Value) { @@ -367,7 +370,7 @@ } static void denormalizeStringVector(SmallVectorImpl &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex,