[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 20 10:54:31 PDT 2023


Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/66514/clang at github.com>


================
@@ -1288,11 +1291,33 @@ void TextDiagnostic::emitSnippet(StringRef SourceLine,
 
   // Print the source line one character at a time.
   bool PrintReversed = false;
+  bool HighlightingEnabled = DiagOpts->ShowColors;
   size_t I = 0;
   while (I < SourceLine.size()) {
     auto [Str, WasPrintable] =
         printableTextForNextCharacter(SourceLine, &I, DiagOpts->TabStop);
 
+    // Just stop highlighting anything for this line if we found a non-printable
+    // character.
----------------
zygoloid wrote:

Instead, can we switch to a different text color for the cases where we print a non-printable character as `<U+1234>`? Eg, black text on red background.

https://github.com/llvm/llvm-project/pull/66514


More information about the cfe-commits mailing list