summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Lexer.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/Lexer.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/Lexer.cpp')
-rw-r--r--clang/lib/Lex/Lexer.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index fca8fd4eb16..3174a059174 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -558,6 +558,10 @@ FinishIdentifier:
// identifier table.
IdentifierInfo *II = PP->LookUpIdentifierInfo(Result, IdStart);
+ // Change the kind of this identifier to the appropriate token kind, e.g.
+ // turning "for" into a keyword.
+ Result.setKind(II->getTokenID());
+
// Finally, now that we know we have an identifier, pass this off to the
// preprocessor, which may macro expand it or something.
if (II->isHandleIdentifierCase())
OpenPOWER on IntegriCloud