aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PTHLexer.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-12-11 22:41:47 +0000
committerTed Kremenek <kremenek@apple.com>2008-12-11 22:41:47 +0000
commitcd223444d1680290efe11da657faafc9a1ac14ba (patch)
tree4faa8458cecfd2a342b51dfb90dbfaff712d6e3a /lib/Lex/PTHLexer.cpp
parentd8c4e15138e69a51754cc259c8a592cc47950c8e (diff)
PTHLexer: Keep track of the location of the last '#' token and provide the means to jump ahead in the token stream.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60905 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PTHLexer.cpp')
-rw-r--r--lib/Lex/PTHLexer.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index ebbc96801f..3afbb5b717 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -28,7 +28,8 @@ using namespace clang;
PTHLexer::PTHLexer(Preprocessor& pp, SourceLocation fileloc, const char* D,
PTHManager& PM)
- : PreprocessorLexer(&pp, fileloc), TokBuf(D), PTHMgr(PM),
+ : PreprocessorLexer(&pp, fileloc), TokBuf(D), CurPtr(D), LastHashTokPtr(0),
+ PTHMgr(PM),
NeedsFetching(true) {
// Make sure the EofToken is completely clean.
EofToken.startToken();
@@ -82,6 +83,8 @@ LexNextToken:
if (Tok.is(tok::hash)) {
if (Tok.isAtStartOfLine() && !LexingRawMode) {
+ LastHashTokPtr = CurPtr;
+
PP->HandleDirective(Tok);
if (PP->isCurrentLexer(this))
@@ -163,20 +166,20 @@ void PTHLexer::ReadToken(Token& T) {
T.startToken();
// Read the type of the token.
- T.setKind((tok::TokenKind) Read8(TokBuf));
+ T.setKind((tok::TokenKind) Read8(CurPtr));
// Set flags. This is gross, since we are really setting multiple flags.
- T.setFlag((Token::TokenFlags) Read8(TokBuf));
+ T.setFlag((Token::TokenFlags) Read8(CurPtr));
// Set the IdentifierInfo* (if any).
- T.setIdentifierInfo(PTHMgr.ReadIdentifierInfo(TokBuf));
+ T.setIdentifierInfo(PTHMgr.ReadIdentifierInfo(CurPtr));
// Set the SourceLocation. Since all tokens are constructed using a
// raw lexer, they will all be offseted from the same FileID.
- T.setLocation(SourceLocation::getFileLoc(FileID, Read32(TokBuf)));
+ T.setLocation(SourceLocation::getFileLoc(FileID, Read32(CurPtr)));
// Finally, read and set the length of the token.
- T.setLength(Read32(TokBuf));
+ T.setLength(Read32(CurPtr));
}
//===----------------------------------------------------------------------===//