]> granicus.if.org Git - clang/commitdiff
PTH generation: Discard tokens that appear after and on the same line as '#endif'.
authorTed Kremenek <kremenek@apple.com>
Tue, 10 Feb 2009 22:43:16 +0000 (22:43 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 10 Feb 2009 22:43:16 +0000 (22:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64250 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/CacheTokens.cpp

index f652b750545968073f90e32df67ed669fb1a2941..23400e67c0d73898a7260ae156f5d27de0d10c65 100644 (file)
@@ -427,7 +427,8 @@ PCHEntry PTHWriter::LexTokens(Lexer& L) {
   
   do {
     L.LexFromRawLexer(Tok);
-    
+  NextToken:
+
     if ((Tok.isAtStartOfLine() || Tok.is(tok::eof)) &&
         ParsingPreprocessorDirective) {
       // Insert an eom token into the token cache.  It has the same
@@ -513,7 +514,15 @@ PCHEntry PTHWriter::LexTokens(Lexer& L) {
         PPStartCond.pop_back();        
         // Add the new entry to PPCond.      
         PPCond.push_back(std::make_pair(HashOff, index));
-        break;
+        EmitToken(Tok);
+        
+        // Some files have gibberish on the same line as '#endif'.
+        // Discard these tokens.
+        do L.LexFromRawLexer(Tok); while (!Tok.is(tok::eof) &&
+                                          !Tok.isAtStartOfLine());
+        // We have the next token in hand.
+        // Don't immediately lex the next one.
+        goto NextToken;        
       }
       case tok::pp_elif:
       case tok::pp_else: {