[PATCH] D137960: [Lexer] Speedup LexTokenInternal
serge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 16 06:57:58 PST 2022
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!");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137960.475818.patch
Type: text/x-patch
Size: 1490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221116/ef84b4f9/attachment-0001.bin>
More information about the cfe-commits
mailing list