[PATCH] D138035: Fix clang-tidy util findNextTokenSkippingComments
Martin Bidlingmaier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 15 07:04:04 PST 2022
mbid created this revision.
Herald added a subscriber: carlosgalvezp.
Herald added a reviewer: njames93.
Herald added a project: All.
mbid requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.
The function did not update the Start source location, resulting in an
infinite loop if the first token was a comment token.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138035
Files:
clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
Index: clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
===================================================================
--- clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
@@ -81,9 +81,13 @@
const SourceManager &SM,
const LangOptions &LangOpts) {
Optional<Token> CurrentToken;
- do {
+ while (true) {
CurrentToken = Lexer::findNextToken(Start, SM, LangOpts);
- } while (CurrentToken && CurrentToken->is(tok::comment));
+ if (!CurrentToken || !CurrentToken->is(tok::comment)) {
+ break;
+ }
+ Start = CurrentToken->getLastLoc();
+ }
return CurrentToken;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138035.475464.patch
Type: text/x-patch
Size: 742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221115/390147f9/attachment.bin>
More information about the cfe-commits
mailing list