[cfe-commits] r59668 - in /cfe/trunk: include/clang/Lex/PTHLexer.h lib/Lex/PPDirectives.cpp lib/Lex/PPMacroExpansion.cpp lib/Lex/PTHLexer.cpp lib/Lex/Pragma.cpp

Ted Kremenek kremenek at apple.com
Wed Nov 19 14:21:33 PST 2008


Author: kremenek
Date: Wed Nov 19 16:21:33 2008
New Revision: 59668

URL: http://llvm.org/viewvc/llvm-project?rev=59668&view=rev
Log:
When using a PTHLexer, use DiscardToEndOfLine() instead of ReadToEndOfLine().

Modified:
    cfe/trunk/include/clang/Lex/PTHLexer.h
    cfe/trunk/lib/Lex/PPDirectives.cpp
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
    cfe/trunk/lib/Lex/PTHLexer.cpp
    cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/include/clang/Lex/PTHLexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PTHLexer.h?rev=59668&r1=59667&r2=59668&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/PTHLexer.h (original)
+++ cfe/trunk/include/clang/Lex/PTHLexer.h Wed Nov 19 16:21:33 2008
@@ -56,6 +56,10 @@
   /// the virtual location encodes where we should *claim* the characters came
   /// from.  Currently this is only used by _Pragma handling.
   SourceLocation getFileLoc() const { return FileLoc; }
+  
+  /// ReadToEndOfLine - Read the rest of the current preprocessor line as an
+  /// uninterpreted string.  This switches the lexer out of directive mode.
+  void DiscardToEndOfLine();
 };
 
 }  // end namespace clang

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=59668&r1=59667&r2=59668&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Nov 19 16:21:33 2008
@@ -473,10 +473,15 @@
   // tokens.  For example, this is allowed: "#warning `   'foo".  GCC does
   // collapse multiple consequtive white space between tokens, but this isn't
   // specified by the standard.
-  std::string Message = CurLexer->ReadToEndOfLine();
-
-  unsigned DiagID = isWarning ? diag::pp_hash_warning : diag::err_pp_hash_error;
-  Diag(Tok, DiagID) << Message;
+  
+  if (CurLexer) {
+    std::string Message = CurLexer->ReadToEndOfLine();
+    unsigned DiagID = isWarning ? diag::pp_hash_warning : diag::err_pp_hash_error;
+    Diag(Tok, DiagID) << Message;
+  }
+  else {
+    CurPTHLexer->DiscardToEndOfLine();
+  }    
 }
 
 /// HandleIdentSCCSDirective - Handle a #ident/#sccs directive.

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=59668&r1=59667&r2=59668&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Nov 19 16:21:33 2008
@@ -111,7 +111,7 @@
     // We have run off the end.  If it's a source file we don't
     // examine enclosing ones (C99 5.1.1.2p4).  Otherwise walk up the
     // macro stack.
-    if (CurLexer)
+    if (CurPPLexer)
       return false;
     for (unsigned i = IncludeMacroStack.size(); i != 0; --i) {
       IncludeStackInfo &Entry = IncludeMacroStack[i-1];

Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=59668&r1=59667&r2=59668&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Wed Nov 19 16:21:33 2008
@@ -76,3 +76,10 @@
   Tok = Tokens[NumTokens]; // NumTokens is already adjusted, so this isn't
                            // an overflow.
 }
+
+void PTHLexer::DiscardToEndOfLine() {
+  assert(ParsingPreprocessorDirective && ParsingFilename == false &&
+         "Must be in a preprocessing directive!");
+  
+  assert (0 && "Not implemented.");
+}

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=59668&r1=59667&r2=59668&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Wed Nov 19 16:21:33 2008
@@ -193,8 +193,9 @@
 }
 
 void Preprocessor::HandlePragmaMark() {
-  assert(CurLexer && "No current lexer?");
-  CurLexer->ReadToEndOfLine();
+  assert(CurPPLexer && "No current lexer?");
+  if (CurLexer) CurLexer->ReadToEndOfLine();
+  else CurPTHLexer->DiscardToEndOfLine();
 }
 
 





More information about the cfe-commits mailing list