aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Lex/PTHLexer.h4
-rw-r--r--lib/Lex/PTHLexer.cpp15
2 files changed, 17 insertions, 2 deletions
diff --git a/include/clang/Lex/PTHLexer.h b/include/clang/Lex/PTHLexer.h
index 34e0b8a9fb..b5655ffb81 100644
--- a/include/clang/Lex/PTHLexer.h
+++ b/include/clang/Lex/PTHLexer.h
@@ -90,8 +90,8 @@ public:
/// getSourceLocation - Return a source location for the token in
/// the current file.
- SourceLocation getSourceLocation() { return GetToken().getLocation(); }
-
+ SourceLocation getSourceLocation();
+
/// SkipBlock - Used by Preprocessor to skip the current conditional block.
bool SkipBlock();
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.
//===----------------------------------------------------------------------===//