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; }
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; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits