diff options
Diffstat (limited to 'lib/Lex/PPCaching.cpp')
-rw-r--r-- | lib/Lex/PPCaching.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/Lex/PPCaching.cpp b/lib/Lex/PPCaching.cpp index 986341b..6f4c189 100644 --- a/lib/Lex/PPCaching.cpp +++ b/lib/Lex/PPCaching.cpp @@ -42,6 +42,7 @@ void Preprocessor::Backtrack() { && "EnableBacktrackAtThisPos was not called!"); CachedLexPos = BacktrackPositions.back(); BacktrackPositions.pop_back(); + recomputeCurLexerKind(); } void Preprocessor::CachingLex(Token &Result) { @@ -56,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() { @@ -74,8 +79,7 @@ void Preprocessor::EnterCachingLexMode() { return; PushIncludeMacroStack(); - if (CurLexerKind != CLK_LexAfterModuleImport) - CurLexerKind = CLK_CachingLexer; + CurLexerKind = CLK_CachingLexer; } |