diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-26 03:46:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-26 03:46:22 +0000 |
commit | b99bdadf9ace3e8c793e12e9bb447501f86b4f72 (patch) | |
tree | b9e59f5c65eed3d7356e94284bec8904ead82f54 /lib/Lex/TokenLexer.cpp | |
parent | 1d24259b5f13663d015c096d5500dcf0ea5ff568 (diff) |
Only resolve a macro's instantiation loc once per macro, instead of once
per token lexed from it. This speeds up clang on c99-intconst-1.c from
the GCC testsuite from 3.64s to 2.66s (36%). This reduces the number of
binary search FileID lookups from 251570522 to 114175649 on this testcase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index ea4ce669d1..3707ef1ed6 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -31,7 +31,14 @@ void TokenLexer::Init(Token &Tok, MacroArgs *Actuals) { Macro = PP.getMacroInfo(Tok.getIdentifierInfo()); ActualArgs = Actuals; CurToken = 0; + InstantiateLoc = Tok.getLocation(); + + // If the instantiation loc is not already a FileID, resolve it here. If we + // don't do this, we end up doing it once per token lexed. + if (!InstantiateLoc.isFileID()) + InstantiateLoc = PP.getSourceManager().getInstantiationLoc(InstantiateLoc); + AtStartOfLine = Tok.isAtStartOfLine(); HasLeadingSpace = Tok.hasLeadingSpace(); Tokens = &*Macro->tokens_begin(); |