[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:12:47 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (alexfh)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/80442.diff
1 Files Affected:
- (modified) clang/lib/Frontend/TextDiagnostic.cpp (+1-1)
``````````diff
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 =
``````````
</details>
https://github.com/llvm/llvm-project/pull/80442
More information about the cfe-commits
mailing list