diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-23 18:35:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-23 18:35:48 +0000 |
commit | 863c486fcb6162495a94fddf7ac8409de2638995 (patch) | |
tree | 7bc843ad55a6a870c6ac9d3a3591f3d727eb338f /lib/Lex/TokenLexer.cpp | |
parent | 17d527b051fbc3927b8a1b4ce4607a9b2ed445ee (diff) |
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%.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62855 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index c945843459..dd5352c1b6 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/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. } |