This revision was automatically updated to reflect the committed changes. Closed by commit rGcb3f8d53e6c3: [Lexer] Speedup LexTokenInternal (authored by serge-sans-paille).
Changed prior to commit: https://reviews.llvm.org/D137960?vs=475699&id=475818#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137960/new/ https://reviews.llvm.org/D137960 Files: clang/include/clang/Lex/Token.h clang/lib/Lex/Lexer.cpp Index: clang/lib/Lex/Lexer.cpp =================================================================== --- clang/lib/Lex/Lexer.cpp +++ clang/lib/Lex/Lexer.cpp @@ -3516,10 +3516,9 @@ /// token, not a normal token, as such, it is an internal interface. It assumes /// that the Flags of result have been cleared before calling this. bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) { -LexNextToken: - // New token, can't need cleaning yet. - Result.clearFlag(Token::NeedsCleaning); - Result.setIdentifierInfo(nullptr); +LexStart: + assert(!Result.needsCleaning() && "Result doesn't need cleaning"); + assert(!Result.hasPtrData() && "Result has been reset"); // CurPtr - Cache BufferPtr in an automatic variable. const char *CurPtr = BufferPtr; @@ -4301,6 +4300,10 @@ // We parsed the directive; lex a token with the new state. return false; + +LexNextToken: + Result.clearFlag(Token::NeedsCleaning); + goto LexStart; } const char *Lexer::convertDependencyDirectiveToken( Index: clang/include/clang/Lex/Token.h =================================================================== --- clang/include/clang/Lex/Token.h +++ clang/include/clang/Lex/Token.h @@ -175,6 +175,8 @@ Loc = SourceLocation().getRawEncoding(); } + bool hasPtrData() const { return PtrData != nullptr; } + IdentifierInfo *getIdentifierInfo() const { assert(isNot(tok::raw_identifier) && "getIdentifierInfo() on a tok::raw_identifier token!");
Index: clang/lib/Lex/Lexer.cpp =================================================================== --- clang/lib/Lex/Lexer.cpp +++ clang/lib/Lex/Lexer.cpp @@ -3516,10 +3516,9 @@ /// token, not a normal token, as such, it is an internal interface. It assumes /// that the Flags of result have been cleared before calling this. bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) { -LexNextToken: - // New token, can't need cleaning yet. - Result.clearFlag(Token::NeedsCleaning); - Result.setIdentifierInfo(nullptr); +LexStart: + assert(!Result.needsCleaning() && "Result doesn't need cleaning"); + assert(!Result.hasPtrData() && "Result has been reset"); // CurPtr - Cache BufferPtr in an automatic variable. const char *CurPtr = BufferPtr; @@ -4301,6 +4300,10 @@ // We parsed the directive; lex a token with the new state. return false; + +LexNextToken: + Result.clearFlag(Token::NeedsCleaning); + goto LexStart; } const char *Lexer::convertDependencyDirectiveToken( Index: clang/include/clang/Lex/Token.h =================================================================== --- clang/include/clang/Lex/Token.h +++ clang/include/clang/Lex/Token.h @@ -175,6 +175,8 @@ Loc = SourceLocation().getRawEncoding(); } + bool hasPtrData() const { return PtrData != nullptr; } + IdentifierInfo *getIdentifierInfo() const { assert(isNot(tok::raw_identifier) && "getIdentifierInfo() on a tok::raw_identifier token!");
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits