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 | a06642a3a3a8a9c82d6c636cd3f2c18c4fac66c4 (patch) | |
tree | 501ef0aaa02065df28ddbd7a85608d12eab50ee5 /lib/Lex/PPCaching.cpp | |
parent | e14ba2cec3807df892917171b590bac25b779b46 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153994 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPCaching.cpp')
-rw-r--r-- | lib/Lex/PPCaching.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/Lex/PPCaching.cpp b/lib/Lex/PPCaching.cpp index 0d5e34f0bf..6f4c189b4f 100644 --- a/lib/Lex/PPCaching.cpp +++ b/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() { |