[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:10:29 PST 2024
https://github.com/alexfh created https://github.com/llvm/llvm-project/pull/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.
>From 2a1a539d94a9214e09e877710a3f866a260d0371 Mon Sep 17 00:00:00 2001
From: Alexander Kornienko <alexfh at google.com>
Date: Fri, 2 Feb 2024 16:03:56 +0100
Subject: [PATCH] Fix clang crash when printing highlighted code in diagnostic
(after #66514)
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.
---
clang/lib/Frontend/TextDiagnostic.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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