aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PTHLexer.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-12-17 23:36:32 +0000
committerTed Kremenek <kremenek@apple.com>2008-12-17 23:36:32 +0000
commit30a12ec2a7f331d9e08acabe7cda853aaa7ba54b (patch)
treebcb639b9080408ba85dfa90c1adff1714397155e /lib/Lex/PTHLexer.cpp
parentdaeee815169f37f2a49f80af7bd104722672ad97 (diff)
Change PTHLexer::getSourceLocation() to not call GetToken() and instead just read the file offset in the token data buffer directly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61170 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PTHLexer.cpp')
-rw-r--r--lib/Lex/PTHLexer.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index a107a38119..9a883b0172 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -262,6 +262,21 @@ bool PTHLexer::SkipBlock() {
return isEndif;
}
+SourceLocation PTHLexer::getSourceLocation() {
+ // getLocation is not on the hot path. It is used to get the location of
+ // the next token when transitioning back to this lexer when done
+ // handling a #included file. Just read the necessary data from the token
+ // data buffer to construct the SourceLocation object.
+ // NOTE: This is a virtual function; hence it is defined out-of-line.
+ const char* p = CurPtr + (1 + 1 + 4);
+ uint32_t offset =
+ ((uint32_t) ((uint8_t) p[0]))
+ | (((uint32_t) ((uint8_t) p[1])) << 8)
+ | (((uint32_t) ((uint8_t) p[2])) << 16)
+ | (((uint32_t) ((uint8_t) p[3])) << 24);
+ return SourceLocation::getFileLoc(FileID, offset);
+}
+
//===----------------------------------------------------------------------===//
// Token reconstruction from the PTH file.
//===----------------------------------------------------------------------===//