aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-11-20 19:49:00 +0000
committerTed Kremenek <kremenek@apple.com>2008-11-20 19:49:00 +0000
commit89d7ee9619d2dbdfa8d956a695c612a104a92cad (patch)
tree27eedb024cc9e5ac39aa32d480a596799f41cc94
parent24b93f2debe1fdb98c7b03a79486a02bf8b9c9e4 (diff)
PTHLexer:
- Move PTHLexer::GetToken() to be inside PTHLexer.cpp. - When lexing in raw mode, null out identifiers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59744 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Lex/PTHLexer.h2
-rw-r--r--lib/Lex/PTHLexer.cpp12
2 files changed, 13 insertions, 1 deletions
diff --git a/include/clang/Lex/PTHLexer.h b/include/clang/Lex/PTHLexer.h
index 8315a22f3f..6f53c61750 100644
--- a/include/clang/Lex/PTHLexer.h
+++ b/include/clang/Lex/PTHLexer.h
@@ -68,7 +68,7 @@ private:
/// GetToken - Returns the next token. This method does not advance the
/// PTHLexer to the next token.
- Token GetToken() { return Tokens[CurTokenIdx]; }
+ Token GetToken();
/// AdvanceToken - Advances the PTHLexer to the next token.
void AdvanceToken() { ++CurTokenIdx; }
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index 16aca4aacb..a88470bbad 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -27,6 +27,18 @@ PTHLexer::PTHLexer(Preprocessor& pp, SourceLocation fileloc,
assert(Tokens[LastTokenIdx].is(tok::eof));
}
+Token PTHLexer::GetToken() {
+ Token Tok = Tokens[CurTokenIdx];
+
+ // If we are in raw mode, zero out identifier pointers. This is
+ // needed for 'pragma poison'. Note that this requires that the Preprocessor
+ // can go back to the original source when it calls getSpelling().
+ if (LexingRawMode && Tok.is(tok::identifier))
+ Tok.setIdentifierInfo(0);
+
+ return Tok;
+}
+
void PTHLexer::Lex(Token& Tok) {
LexNextToken:
if (AtLastToken()) {