]> granicus.if.org Git - clang/commitdiff
PTHLexer:
authorTed Kremenek <kremenek@apple.com>
Thu, 20 Nov 2008 19:49:00 +0000 (19:49 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 20 Nov 2008 19:49:00 +0000 (19:49 +0000)
- 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

include/clang/Lex/PTHLexer.h
lib/Lex/PTHLexer.cpp

index 8315a22f3f18905f0978f567f8f05c4845c4149f..6f53c61750584f92d5b7914a5682f455b07eceac 100644 (file)
@@ -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; }
index 16aca4aacbe09f8c91540a14b811b6c81f4403d5..a88470bbad69eeed5da14e4990537f67bf56bc53 100644 (file)
@@ -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()) {