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

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


================
@@ -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,
----------------
alexfh wrote:

I've got a (still quite hairy and not shareable) reproducer that requires the use of a number of defines on the command line to actually cause an assertion failure (`-D_Q1 -D_Q2 -D_Q3 -D_Q4 -D_Q5 -D_Q6 -D_Q7 -D_Q8 -D_Q9 -D_Q10 -D_Q11 -D_Q12 -D_Q13  -D_Q14  -D_Q15 -D_Q16 -D_Q17 -D_Q18 -D_Q19`). Removing any of the defines makes the crash disappear.

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


More information about the cfe-commits mailing list