diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-10 22:43:16 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-10 22:43:16 +0000 |
commit | 726080d8dc40d993521a42687342522da06d3aac (patch) | |
tree | 95b9c5de7e091ba746a0302879d48d49adac1ef2 /Driver | |
parent | b99b0c0e292544eb1f4feeaf9c2664d12329d558 (diff) | |
download | clang-726080d8dc40d993521a42687342522da06d3aac.tar.gz |
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
Diffstat (limited to 'Driver')
-rw-r--r-- | Driver/CacheTokens.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
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: { |