From: Ted Kremenek Date: Tue, 10 Feb 2009 22:43:16 +0000 (+0000) Subject: PTH generation: Discard tokens that appear after and on the same line as '#endif'. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=726080d8dc40d993521a42687342522da06d3aac;p=clang 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 f652b75054..23400e67c0 100644 --- a/Driver/CacheTokens.cpp +++ b/Driver/CacheTokens.cpp @@ -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: {