diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp --- a/clang/lib/Format/FormatTokenLexer.cpp +++ b/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;