================ @@ -1144,20 +1144,25 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd, switch (Kind) { // ---- STRINGS ---- - case DiagnosticsEngine::ak_std_string: { - const std::string &S = getArgStdStr(ArgNo); - assert(ModifierLen == 0 && "No modifiers for strings yet"); - EscapeStringForDiagnostic(S, OutStr); - break; - } + case DiagnosticsEngine::ak_std_string: case DiagnosticsEngine::ak_c_string: { - const char *S = getArgCStr(ArgNo); - assert(ModifierLen == 0 && "No modifiers for strings yet"); - - // Don't crash if get passed a null pointer by accident. - if (!S) - S = "(null)"; + StringRef S = [&]() -> StringRef { + if (Kind == DiagnosticsEngine::ak_std_string) + return getArgStdStr(ArgNo); + const char *SZ = getArgCStr(ArgNo); + // Don't crash if get passed a null pointer by accident. + return SZ ? SZ : "(null)"; + }(); + bool Quoted = false; + if (ModifierIs(Modifier, ModifierLen, "quoted")) { + Quoted = true; + OutStr.push_back('\''); + } else { + assert(ModifierLen == 0 && "unknown modifier for string"); + } ---------------- cor3ntin wrote:
Do we want to assert we don't end up with double quotes? https://github.com/llvm/llvm-project/pull/134769 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits