]> granicus.if.org Git - clang/commitdiff
When using a PTHLexer, use DiscardToEndOfLine() instead of ReadToEndOfLine().
authorTed Kremenek <kremenek@apple.com>
Wed, 19 Nov 2008 22:21:33 +0000 (22:21 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 19 Nov 2008 22:21:33 +0000 (22:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59668 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/PTHLexer.h
lib/Lex/PPDirectives.cpp
lib/Lex/PPMacroExpansion.cpp
lib/Lex/PTHLexer.cpp
lib/Lex/Pragma.cpp

index 2985b24cb5c5b53733ce54c7d873d1bd01d3e40f..bdaba760cf3ec0ff92351b6fdbebca9a68abe3e3 100644 (file)
@@ -56,6 +56,10 @@ public:
   /// 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
index a1216b15bccd5b918dd254b13b3a2dbefd9b5dd7..68f495749973d7fc2a1c3704155cd8f541035e2f 100644 (file)
@@ -473,10 +473,15 @@ void Preprocessor::HandleUserDiagnosticDirective(Token &Tok,
   // 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.
index 1d4d85a897375a189ee69bc24e4f0c2092acde87..abb21cb474530e9a2a0477b3e80bfae75d4571d3 100644 (file)
@@ -111,7 +111,7 @@ bool Preprocessor::isNextPPTokenLParen() {
     // 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];
index d22285cae5c6735c0c0ce1ef70db6841ddbc0da9..15d56039692a29c3abf098faaeb27dc68b2381ab 100644 (file)
@@ -76,3 +76,10 @@ void PTHLexer::setEOF(Token& Tok) {
   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.");
+}
index d4c5c6b8359dc706c243dca111a26b475c3b1ab6..0e0841da9a96e8d224f8952406254085b5fbf788 100644 (file)
@@ -193,8 +193,9 @@ void Preprocessor::HandlePragmaOnce(Token &OnceTok) {
 }
 
 void Preprocessor::HandlePragmaMark() {
-  assert(CurLexer && "No current lexer?");
-  CurLexer->ReadToEndOfLine();
+  assert(CurPPLexer && "No current lexer?");
+  if (CurLexer) CurLexer->ReadToEndOfLine();
+  else CurPTHLexer->DiscardToEndOfLine();
 }