summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-02-10 22:43:16 +0000
committerTed Kremenek <kremenek@apple.com>2009-02-10 22:43:16 +0000
commitc7d6964a38b05a1baf12684cd5991c953abdd4c1 (patch)
treee859ec2a3f73ccb2ffc86ae19afd455044755449
parentf70f089286c77d297e6c5eb9a820315b9907a0b6 (diff)
downloadbcm5719-llvm-c7d6964a38b05a1baf12684cd5991c953abdd4c1.tar.gz
bcm5719-llvm-c7d6964a38b05a1baf12684cd5991c953abdd4c1.zip
PTH generation: Discard tokens that appear after and on the same line as '#endif'.
llvm-svn: 64250
-rw-r--r--clang/Driver/CacheTokens.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/Driver/CacheTokens.cpp b/clang/Driver/CacheTokens.cpp
index f652b750545..23400e67c0d 100644
--- a/clang/Driver/CacheTokens.cpp
+++ b/clang/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: {
OpenPOWER on IntegriCloud