summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/TokenLexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-23 18:35:48 +0000
committerChris Lattner <sabre@nondot.org>2009-01-23 18:35:48 +0000
commit1f6c7fe6a87583eecb49b00b02fbb529f45bac90 (patch)
treef033cee511fbeea6fd88d18c89a223beace87831 /clang/lib/Lex/TokenLexer.cpp
parent9db60a38e9be06f1cef1522028ece1af64e945a1 (diff)
downloadbcm5719-llvm-1f6c7fe6a87583eecb49b00b02fbb529f45bac90.tar.gz
bcm5719-llvm-1f6c7fe6a87583eecb49b00b02fbb529f45bac90.zip
This is a follow-up to r62675:
Refactor how the preprocessor changes a token from being an tok::identifier to a keyword (e.g. tok::kw_for). Instead of doing this in HandleIdentifier, hoist this common case out into the caller, so that every keyword doesn't have to go through HandleIdentifier. This drops time in HandleIdentifier from 1.25ms to .62ms, and speeds up clang -Eonly with PTH by about 1%. llvm-svn: 62855
Diffstat (limited to 'clang/lib/Lex/TokenLexer.cpp')
-rw-r--r--clang/lib/Lex/TokenLexer.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp
index c945843459f..dd5352c1b61 100644
--- a/clang/lib/Lex/TokenLexer.cpp
+++ b/clang/lib/Lex/TokenLexer.cpp
@@ -326,9 +326,14 @@ void TokenLexer::Lex(Token &Tok) {
}
// Handle recursive expansion!
- if (Tok.getIdentifierInfo() && !DisableMacroExpansion &&
- Tok.getIdentifierInfo()->isHandleIdentifierCase())
- PP.HandleIdentifier(Tok);
+ if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
+ // Change the kind of this identifier to the appropriate token kind, e.g.
+ // turning "for" into a keyword.
+ Tok.setKind(II->getTokenID());
+
+ if (!DisableMacroExpansion && II->isHandleIdentifierCase())
+ PP.HandleIdentifier(Tok);
+ }
// Otherwise, return a normal token.
}
OpenPOWER on IntegriCloud