PTH generation: Discard tokens that appear after and on the same line as '#endif'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64250 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/CacheTokens.cpp b/Driver/CacheTokens.cpp
index f652b75..23400e6 100644
--- a/Driver/CacheTokens.cpp
+++ b/Driver/CacheTokens.cpp
@@ -427,7 +427,8 @@
   
   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 @@
         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: {