diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-04-04 02:57:01 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-04-04 02:57:01 +0000 |
commit | 4a1049c8a2292e796f452ff5bf128aa3e095f1a0 (patch) | |
tree | 76b6d2d21686c68225b2ad0f2cc26aea09dd2520 /clang/lib/Lex/PPCaching.cpp | |
parent | b73bc9af60367d5a0b11764082e561fade422194 (diff) | |
download | bcm5719-llvm-4a1049c8a2292e796f452ff5bf128aa3e095f1a0.tar.gz bcm5719-llvm-4a1049c8a2292e796f452ff5bf128aa3e095f1a0.zip |
[preprocessor] In Preprocessor::CachingLex() check whether there were more tokens
cached during the non-cached lex, otherwise we are going to drop them.
Fixes a bogus "_Pragma takes a parenthesized string literal" error when
expanding consecutive _Pragmas in a macro argument.
Part of rdar://11168596
llvm-svn: 153994
Diffstat (limited to 'clang/lib/Lex/PPCaching.cpp')
-rw-r--r-- | clang/lib/Lex/PPCaching.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/clang/lib/Lex/PPCaching.cpp b/clang/lib/Lex/PPCaching.cpp index 0d5e34f0bfe..6f4c189b4f6 100644 --- a/clang/lib/Lex/PPCaching.cpp +++ b/clang/lib/Lex/PPCaching.cpp @@ -57,17 +57,21 @@ void Preprocessor::CachingLex(Token &Result) { ExitCachingLexMode(); Lex(Result); - if (!isBacktrackEnabled()) { + if (isBacktrackEnabled()) { + // Cache the lexed token. + EnterCachingLexMode(); + CachedTokens.push_back(Result); + ++CachedLexPos; + return; + } + + if (CachedLexPos < CachedTokens.size()) { + EnterCachingLexMode(); + } else { // All cached tokens were consumed. CachedTokens.clear(); CachedLexPos = 0; - return; } - - // Cache the lexed token. - EnterCachingLexMode(); - CachedTokens.push_back(Result); - ++CachedLexPos; } void Preprocessor::EnterCachingLexMode() { |