summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-26 03:46:22 +0000
committerChris Lattner <sabre@nondot.org>2009-01-26 03:46:22 +0000
commitdd9babc79a82804010381912d879eafbf4d8fe1a (patch)
tree584875de5c3a02b3828e819d921036781f6dcbfa /clang/lib/Lex
parent95b2a206ee4388f58cfdc28ec768e6c7998c80ed (diff)
downloadbcm5719-llvm-dd9babc79a82804010381912d879eafbf4d8fe1a.tar.gz
bcm5719-llvm-dd9babc79a82804010381912d879eafbf4d8fe1a.zip
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. llvm-svn: 62992
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/TokenLexer.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp
index ea4ce669d1d..3707ef1ed6f 100644
--- a/clang/lib/Lex/TokenLexer.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud