This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG243bc7504965: [clang][cli] Accept option spelling as `Twine` (authored by jansvoboda11).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157035/new/ https://reviews.llvm.org/D157035 Files: clang/lib/Frontend/CompilerInvocation.cpp Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -192,10 +192,12 @@ /// unnecessary template instantiations and just ignore it with a variadic /// argument. static void denormalizeSimpleFlag(SmallVectorImpl<const char *> &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. + assert(*Spelling.getSingleStringRef().end() == '\0'); + Args.push_back(Spelling.getSingleStringRef().data()); } template <typename T> static constexpr bool is_uint64_t_convertible() { @@ -232,16 +234,19 @@ } static auto makeBooleanOptionDenormalizer(bool Value) { - return [Value](SmallVectorImpl<const char *> &Args, const char *Spelling, + return [Value](SmallVectorImpl<const char *> &Args, const Twine &Spelling, CompilerInvocation::StringAllocator, Option::OptionClass, unsigned, bool KeyPath) { - if (KeyPath == Value) - Args.push_back(Spelling); + if (KeyPath == Value) { + // Spelling is already allocated or a static string, no need to call SA. + assert(*Spelling.getSingleStringRef().end() == '\0'); + Args.push_back(Spelling.getSingleStringRef().data()); + } }; } static void denormalizeStringImpl(SmallVectorImpl<const char *> &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned, const Twine &Value) { @@ -249,7 +254,9 @@ 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. + assert(*Spelling.getSingleStringRef().end() == '\0'); + Args.push_back(Spelling.getSingleStringRef().data()); Args.push_back(SA(Value)); break; case Option::JoinedClass: @@ -264,7 +271,7 @@ template <typename T> static void -denormalizeString(SmallVectorImpl<const char *> &Args, const char *Spelling, +denormalizeString(SmallVectorImpl<const char *> &Args, const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex, T Value) { denormalizeStringImpl(Args, Spelling, SA, OptClass, TableIndex, Twine(Value)); @@ -309,7 +316,7 @@ } static void denormalizeSimpleEnumImpl(SmallVectorImpl<const char *> &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex, unsigned Value) { @@ -326,7 +333,7 @@ template <typename T> static void denormalizeSimpleEnum(SmallVectorImpl<const char *> &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex, T Value) { @@ -367,7 +374,7 @@ } static void denormalizeStringVector(SmallVectorImpl<const char *> &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex,
Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -192,10 +192,12 @@ /// unnecessary template instantiations and just ignore it with a variadic /// argument. static void denormalizeSimpleFlag(SmallVectorImpl<const char *> &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. + assert(*Spelling.getSingleStringRef().end() == '\0'); + Args.push_back(Spelling.getSingleStringRef().data()); } template <typename T> static constexpr bool is_uint64_t_convertible() { @@ -232,16 +234,19 @@ } static auto makeBooleanOptionDenormalizer(bool Value) { - return [Value](SmallVectorImpl<const char *> &Args, const char *Spelling, + return [Value](SmallVectorImpl<const char *> &Args, const Twine &Spelling, CompilerInvocation::StringAllocator, Option::OptionClass, unsigned, bool KeyPath) { - if (KeyPath == Value) - Args.push_back(Spelling); + if (KeyPath == Value) { + // Spelling is already allocated or a static string, no need to call SA. + assert(*Spelling.getSingleStringRef().end() == '\0'); + Args.push_back(Spelling.getSingleStringRef().data()); + } }; } static void denormalizeStringImpl(SmallVectorImpl<const char *> &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned, const Twine &Value) { @@ -249,7 +254,9 @@ 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. + assert(*Spelling.getSingleStringRef().end() == '\0'); + Args.push_back(Spelling.getSingleStringRef().data()); Args.push_back(SA(Value)); break; case Option::JoinedClass: @@ -264,7 +271,7 @@ template <typename T> static void -denormalizeString(SmallVectorImpl<const char *> &Args, const char *Spelling, +denormalizeString(SmallVectorImpl<const char *> &Args, const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex, T Value) { denormalizeStringImpl(Args, Spelling, SA, OptClass, TableIndex, Twine(Value)); @@ -309,7 +316,7 @@ } static void denormalizeSimpleEnumImpl(SmallVectorImpl<const char *> &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex, unsigned Value) { @@ -326,7 +333,7 @@ template <typename T> static void denormalizeSimpleEnum(SmallVectorImpl<const char *> &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex, T Value) { @@ -367,7 +374,7 @@ } static void denormalizeStringVector(SmallVectorImpl<const char *> &Args, - const char *Spelling, + const Twine &Spelling, CompilerInvocation::StringAllocator SA, Option::OptionClass OptClass, unsigned TableIndex,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits