summaryrefslogtreecommitdiffstats
path: root/clang/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
commit63ff81c4e1fe13a2f8db43bc6350f354772aa112 (patch)
tree36e4333b5a93a2de1b07bf5f3c071a53f0c9cc00 /clang/lib/Lex/PTHLexer.cpp
parentbe4fb8a25fef0550780036b85aa5cde749ec81f3 (diff)
downloadbcm5719-llvm-63ff81c4e1fe13a2f8db43bc6350f354772aa112.tar.gz
bcm5719-llvm-63ff81c4e1fe13a2f8db43bc6350f354772aa112.zip
Change PTHLexer::getSourceLocation() to not call GetToken() and instead just read the file offset in the token data buffer directly.
llvm-svn: 61170
Diffstat (limited to 'clang/lib/Lex/PTHLexer.cpp')
-rw-r--r--clang/lib/Lex/PTHLexer.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Lex/PTHLexer.cpp b/clang/lib/Lex/PTHLexer.cpp
index a107a381190..9a883b01722 100644
--- a/clang/lib/Lex/PTHLexer.cpp
+++ b/clang/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.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud