[clang] a986f5e - Fix clang crash when printing highlighted code in diagnostic (after #66514) (#80442)

via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 2 07:31:48 PST 2024


Author: alexfh
Date: 2024-02-02T16:31:45+01:00
New Revision: a986f5e218ab8a68097fcc1fd3234b8743839ef8

URL: https://github.com/llvm/llvm-project/commit/a986f5e218ab8a68097fcc1fd3234b8743839ef8
DIFF: https://github.com/llvm/llvm-project/commit/a986f5e218ab8a68097fcc1fd3234b8743839ef8.diff

LOG: Fix clang crash when printing highlighted code in diagnostic (after #66514) (#80442)

Implements the fix proposed by Evgeny Eltsin on
https://github.com/llvm/llvm-project/pull/66514#issuecomment-1924039038.

No test case provided, since the bug is extremely sensitive to the
preprocessor
state (headers, macros, including the ones defined on command line), and
it
turned out to be non-trivial to create an isolated test.

Added: 
    

Modified: 
    clang/lib/Frontend/TextDiagnostic.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp
index 627a7641308a1..10240d7ee6f2e 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -1349,7 +1349,7 @@ void TextDiagnostic::emitSnippetAndCaret(
   // Prepare source highlighting information for the lines we're about to
   // emit, starting from the first line.
   std::unique_ptr<SmallVector<StyleRange>[]> SourceStyles =
-      highlightLines(BufStart, Lines.first, Lines.second, PP, LangOpts,
+      highlightLines(BufData, Lines.first, Lines.second, PP, LangOpts,
                      DiagOpts->ShowColors, FID, SM);
 
   SmallVector<LineRange> LineRanges =


        


More information about the cfe-commits mailing list