================
@@ -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");
+      }
----------------
mizvekov wrote:

That's not impossible, but we suffer from the problem generally, and is one 
reason we should be pointing to things, not printing them.

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

Reply via email to