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

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 2 04:05:57 PST 2024


tbaederr wrote:

> This I think qualifies as a serious problem as it introduces a crash which may occur in _any_ existent codebase. Anyone using the compiler at trunk and encountering the crash has no way to know how to deal with it.

Since we don't have a reproducer, the danger is that we revert the commit but never get such a reproducer, leaving us in a state where we can never re-commit safely.


If you have some sort of internal deployment, why not revert the commit locally? Or just apply something like
```diff
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -1350,7 +1350,7 @@ void TextDiagnostic::emitSnippetAndCaret(
   // emit, starting from the first line.
   std::unique_ptr<SmallVector<StyleRange>[]> SourceStyles =
       highlightLines(BufStart, Lines.first, Lines.second, PP, LangOpts,
-                     DiagOpts->ShowColors, FID, SM);
+                     false, FID, SM);

   SmallVector<LineRange> LineRanges =
       prepareAndFilterRanges(Ranges, SM, Lines, FID, LangOpts);
```

That is, unless https://github.com/llvm/llvm-project/commit/6d1d2c67e7597dc417c097d5027558b0159ed2e2 actually fixed the problem already, which would be good to check.





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


More information about the cfe-commits mailing list