https://github.com/vbvictor updated https://github.com/llvm/llvm-project/pull/174295
>From 53071edc614cb6372b0396f48655dfc0ff7c9cab Mon Sep 17 00:00:00 2001 From: Victor Baranov <[email protected]> Date: Sun, 4 Jan 2026 01:36:24 +0300 Subject: [PATCH 1/2] [clang-tidy][NFC] Simplify 'utils::lexer::findNextTokenSkippingComments' --- clang-tools-extra/clang-tidy/utils/LexerUtils.cpp | 15 --------------- clang-tools-extra/clang-tidy/utils/LexerUtils.h | 9 ++++++--- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp index 6e93871289ed9..3bb807c985b9a 100644 --- a/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.cpp @@ -75,21 +75,6 @@ SourceLocation findNextTerminator(SourceLocation Start, const SourceManager &SM, return findNextAnyTokenKind(Start, SM, LangOpts, tok::comma, tok::semi); } -std::optional<Token> -findNextTokenSkippingComments(SourceLocation Start, const SourceManager &SM, - const LangOptions &LangOpts) { - while (Start.isValid()) { - std::optional<Token> CurrentToken = - Lexer::findNextToken(Start, SM, LangOpts); - if (!CurrentToken || !CurrentToken->is(tok::comment)) - return CurrentToken; - - Start = CurrentToken->getLocation(); - } - - return std::nullopt; -} - bool rangeContainsExpansionsOrDirectives(SourceRange Range, const SourceManager &SM, const LangOptions &LangOpts) { diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.h b/clang-tools-extra/clang-tidy/utils/LexerUtils.h index c5fb646c0efd9..5f409f8a116b6 100644 --- a/clang-tools-extra/clang-tidy/utils/LexerUtils.h +++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.h @@ -89,6 +89,7 @@ SourceLocation findNextAnyTokenKind(SourceLocation Start, } } +// Finds next token that's including a comment. inline std::optional<Token> findNextTokenIncludingComments(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts) { @@ -96,9 +97,11 @@ findNextTokenIncludingComments(SourceLocation Start, const SourceManager &SM, } // Finds next token that's not a comment. -std::optional<Token> findNextTokenSkippingComments(SourceLocation Start, - const SourceManager &SM, - const LangOptions &LangOpts); +inline std::optional<Token> +findNextTokenSkippingComments(SourceLocation Start, const SourceManager &SM, + const LangOptions &LangOpts) { + return Lexer::findNextToken(Start, SM, LangOpts, false); +} /// Re-lex the provide \p Range and return \c false if either a macro spans /// multiple tokens, a pre-processor directive or failure to retrieve the >From cd1022e1d6d95427837994efd8609f28ad405730 Mon Sep 17 00:00:00 2001 From: Baranov Victor <[email protected]> Date: Sun, 4 Jan 2026 02:19:13 +0300 Subject: [PATCH 2/2] Update clang-tools-extra/clang-tidy/utils/LexerUtils.h Co-authored-by: Victor Chernyakin <[email protected]> --- clang-tools-extra/clang-tidy/utils/LexerUtils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-tidy/utils/LexerUtils.h b/clang-tools-extra/clang-tidy/utils/LexerUtils.h index 5f409f8a116b6..e698ef68441ce 100644 --- a/clang-tools-extra/clang-tidy/utils/LexerUtils.h +++ b/clang-tools-extra/clang-tidy/utils/LexerUtils.h @@ -89,7 +89,7 @@ SourceLocation findNextAnyTokenKind(SourceLocation Start, } } -// Finds next token that's including a comment. +// Finds next token, possibly a comment. inline std::optional<Token> findNextTokenIncludingComments(SourceLocation Start, const SourceManager &SM, const LangOptions &LangOpts) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
