https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/204926
>From 6f15db3e1232d7f18f6732a1338960b3aa22b49e Mon Sep 17 00:00:00 2001 From: Anonmiraj <[email protected]> Date: Sat, 20 Jun 2026 14:41:32 +0300 Subject: [PATCH] [clang][Diagnostics] Only record lexer check points when colors are enabled --- clang/include/clang/Lex/Preprocessor.h | 3 +++ clang/lib/Lex/Preprocessor.cpp | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 8b684e85eb1c1..9f592892f9218 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -381,6 +381,9 @@ class Preprocessor { llvm::DenseMap<FileID, SmallVector<const char *>> CheckPoints; unsigned CheckPointCounter = 0; + /// Whether to record lexer check points for diagnostic snippet highlighting. + bool RecordCheckPoints = false; + /// Whether we're importing a standard C++20 named Modules. bool ImportingCXXNamedModules = false; diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 1e21b4a94cea3..f58d8589c1afd 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -101,6 +101,9 @@ Preprocessor::Preprocessor(const PreprocessorOptions &PPOpts, CurSubmoduleState(&NullSubmoduleState) { OwnsHeaderSearch = OwnsHeaders; + // Only record check points if we might highlight diagnostic snippets. + RecordCheckPoints = getDiagnostics().getDiagnosticOptions().ShowColors; + // Default to discarding comments. KeepComments = false; KeepMacroComments = false; @@ -1011,7 +1014,8 @@ void Preprocessor::Lex(Token &Result) { } } - if (CurLexer && ++CheckPointCounter == CheckPointStepSize) { + if (RecordCheckPoints && CurLexer && + ++CheckPointCounter == CheckPointStepSize) { CheckPoints[CurLexer->getFileID()].push_back(CurLexer->BufferPtr); CheckPointCounter = 0; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
