sstwcw created this revision. sstwcw added reviewers: HazardyKnusperkeks, MyDeveloperDay, curdeius, owenpan. Herald added a project: All. sstwcw requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
The setLength function checks for the token kind which could be uninitialized in the previous version. The problem was introduced in 2e32ff106e <https://reviews.llvm.org/rG2e32ff106e740c76601004493816d0ed7c483056>. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D128607 Files: clang/lib/Format/FormatTokenLexer.cpp Index: clang/lib/Format/FormatTokenLexer.cpp =================================================================== --- clang/lib/Format/FormatTokenLexer.cpp +++ clang/lib/Format/FormatTokenLexer.cpp @@ -1128,11 +1128,12 @@ return false; size_t Len = Matches[0].size(); - Tok.setLength(Len); - Tok.setLocation(Lex->getSourceLocation(Start, Len)); // The kind has to be an identifier so we can match it against those defined - // in Keywords. + // in Keywords. The kind has to be set before the length because the setLength + // function checks that the kind is not an annotation. Tok.setKind(tok::raw_identifier); + Tok.setLength(Len); + Tok.setLocation(Lex->getSourceLocation(Start, Len)); Tok.setRawIdentifierData(Start); Lex->seek(Lex->getCurrentBufferOffset() + Len, /*IsAtStartofline=*/false); return true;
Index: clang/lib/Format/FormatTokenLexer.cpp =================================================================== --- clang/lib/Format/FormatTokenLexer.cpp +++ clang/lib/Format/FormatTokenLexer.cpp @@ -1128,11 +1128,12 @@ return false; size_t Len = Matches[0].size(); - Tok.setLength(Len); - Tok.setLocation(Lex->getSourceLocation(Start, Len)); // The kind has to be an identifier so we can match it against those defined - // in Keywords. + // in Keywords. The kind has to be set before the length because the setLength + // function checks that the kind is not an annotation. Tok.setKind(tok::raw_identifier); + Tok.setLength(Len); + Tok.setLocation(Lex->getSourceLocation(Start, Len)); Tok.setRawIdentifierData(Start); Lex->seek(Lex->getCurrentBufferOffset() + Len, /*IsAtStartofline=*/false); return true;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits