summaryrefslogtreecommitdiffstats
path: root/lib/Lex/TokenLexer.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-08-23 21:02:38 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-08-23 21:02:38 +0000
commit499ea5550d6e2fc5cfbd33b47f06d92ce25d7a13 (patch)
tree94419faa6f8fefb0ef783f2c0bcf637ca4643d8b /lib/Lex/TokenLexer.cpp
parent5d579e7b0463a2e65328df85e4fed8e07799fd9e (diff)
Introduce SourceManager::isInSLocAddrSpace and use it in TokenLexer instead of isInFileID
since it is a bit more efficient. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r--lib/Lex/TokenLexer.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp
index 66712e827d..85c03f4e96 100644
--- a/lib/Lex/TokenLexer.cpp
+++ b/lib/Lex/TokenLexer.cpp
@@ -55,12 +55,12 @@ void TokenLexer::Init(Token &Tok, SourceLocation ELEnd, MacroArgs *Actuals) {
// definition. Tokens that get lexed directly from the definition will
// have their locations pointing inside this chunk. This is to avoid
// creating separate source location entries for each token.
- SourceLocation macroStart = SM.getExpansionLoc(Tokens[0].getLocation());
- MacroDefStartInfo = SM.getDecomposedLoc(macroStart);
- MacroExpansionStart = SM.createExpansionLoc(macroStart,
+ MacroDefStart = SM.getExpansionLoc(Tokens[0].getLocation());
+ MacroDefLength = Macro->getDefinitionLength(SM);
+ MacroExpansionStart = SM.createExpansionLoc(MacroDefStart,
ExpandLocStart,
ExpandLocEnd,
- Macro->getDefinitionLength(SM));
+ MacroDefLength);
}
// If this is a function-like macro, expand the arguments and change
@@ -647,14 +647,11 @@ TokenLexer::getExpansionLocForMacroDefLoc(SourceLocation loc) const {
assert(loc.isValid() && loc.isFileID());
SourceManager &SM = PP.getSourceManager();
- assert(SM.isInFileID(loc,
- MacroDefStartInfo.first, MacroDefStartInfo.second,
- Macro->getDefinitionLength(SM)));
-
- unsigned relativeOffset;
- SM.isInFileID(loc,
- MacroDefStartInfo.first, MacroDefStartInfo.second,
- Macro->getDefinitionLength(SM), &relativeOffset);
+ assert(SM.isInSLocAddrSpace(loc, MacroDefStart, MacroDefLength) &&
+ "Expected loc to come from the macro definition");
+
+ unsigned relativeOffset = 0;
+ SM.isInSLocAddrSpace(loc, MacroDefStart, MacroDefLength, &relativeOffset);
return MacroExpansionStart.getFileLocWithOffset(relativeOffset);
}