https://github.com/AnonMiraj 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 1/3] [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; } >From 6b10451215deb075dd35ba506be63fa50c75c03b Mon Sep 17 00:00:00 2001 From: Anonmiraj <[email protected]> Date: Fri, 10 Jul 2026 04:44:23 +0300 Subject: [PATCH 2/3] fix ci --- clang/lib/Lex/Preprocessor.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index e24367ece2cb5..ee19d067d7eb7 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -103,7 +103,9 @@ Preprocessor::Preprocessor(const PreprocessorOptions &PPOpts, OwnsHeaderSearch = OwnsHeaders; // Only record check points if we might highlight diagnostic snippets. - RecordCheckPoints = getDiagnostics().getDiagnosticOptions().ShowColors; + RecordCheckPoints = + getDiagnostics().getDiagnosticOptions().getShowColors() != + ShowColorsKind::Off; // Default to discarding comments. KeepComments = false; >From 2c3ec968254745bdef0acf0d21a3c3eff7aa52b0 Mon Sep 17 00:00:00 2001 From: Anonmiraj <[email protected]> Date: Fri, 10 Jul 2026 04:47:27 +0300 Subject: [PATCH 3/3] fix formatting --- clang/lib/Lex/Preprocessor.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index ee19d067d7eb7..5ee53a93732bb 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -103,9 +103,8 @@ Preprocessor::Preprocessor(const PreprocessorOptions &PPOpts, OwnsHeaderSearch = OwnsHeaders; // Only record check points if we might highlight diagnostic snippets. - RecordCheckPoints = - getDiagnostics().getDiagnosticOptions().getShowColors() != - ShowColorsKind::Off; + RecordCheckPoints = getDiagnostics().getDiagnosticOptions().getShowColors() != + ShowColorsKind::Off; // Default to discarding comments. KeepComments = false; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
