PPCaching.cpp (208954) | PPCaching.cpp (210299) |
---|---|
1//===--- PPCaching.cpp - Handle caching lexed tokens ----------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 31 unchanged lines hidden (view full) --- 40void Preprocessor::Backtrack() { 41 assert(!BacktrackPositions.empty() 42 && "EnableBacktrackAtThisPos was not called!"); 43 CachedLexPos = BacktrackPositions.back(); 44 BacktrackPositions.pop_back(); 45} 46 47void Preprocessor::CachingLex(Token &Result) { | 1//===--- PPCaching.cpp - Handle caching lexed tokens ----------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 31 unchanged lines hidden (view full) --- 40void Preprocessor::Backtrack() { 41 assert(!BacktrackPositions.empty() 42 && "EnableBacktrackAtThisPos was not called!"); 43 CachedLexPos = BacktrackPositions.back(); 44 BacktrackPositions.pop_back(); 45} 46 47void Preprocessor::CachingLex(Token &Result) { |
48 if (!InCachingLexMode()) 49 return; 50 |
|
48 if (CachedLexPos < CachedTokens.size()) { 49 Result = CachedTokens[CachedLexPos++]; 50 return; 51 } 52 53 ExitCachingLexMode(); 54 Lex(Result); 55 56 if (!isBacktrackEnabled()) { 57 // All cached tokens were consumed. 58 CachedTokens.clear(); 59 CachedLexPos = 0; 60 return; 61 } 62 | 51 if (CachedLexPos < CachedTokens.size()) { 52 Result = CachedTokens[CachedLexPos++]; 53 return; 54 } 55 56 ExitCachingLexMode(); 57 Lex(Result); 58 59 if (!isBacktrackEnabled()) { 60 // All cached tokens were consumed. 61 CachedTokens.clear(); 62 CachedLexPos = 0; 63 return; 64 } 65 |
63 // We should cache the lexed token. 64 | 66 // Cache the lexed token. |
65 EnterCachingLexMode(); | 67 EnterCachingLexMode(); |
66 if (Result.isNot(tok::eof)) { 67 CachedTokens.push_back(Result); 68 ++CachedLexPos; 69 } | 68 CachedTokens.push_back(Result); 69 ++CachedLexPos; |
70} 71 72void Preprocessor::EnterCachingLexMode() { 73 if (InCachingLexMode()) 74 return; 75 76 PushIncludeMacroStack(); 77} --- 35 unchanged lines hidden --- | 70} 71 72void Preprocessor::EnterCachingLexMode() { 73 if (InCachingLexMode()) 74 return; 75 76 PushIncludeMacroStack(); 77} --- 35 unchanged lines hidden --- |