bool DisableMacroExpansion : 1; // True if macro expansion is disabled.
bool InMacroArgs : 1; // True if parsing fn macro invocation args.
- /// CacheTokens - True when the lexed tokens are cached for backtracking.
- bool CacheTokens : 1;
-
/// Identifiers - This is mapping/lookup information for all identifiers in
/// the program, including program keywords.
IdentifierTable Identifiers;
/// isBacktrackEnabled - True if EnableBacktrackAtThisPos() was called and
/// caching of tokens is on.
- bool isBacktrackEnabled() const { return CacheTokens; }
+ bool isBacktrackEnabled() const { return !BacktrackPositions.empty(); }
/// Lex - To lex a token from the preprocessor, just pull a token from the
/// current lexer or macro object.
/// be called multiple times and CommitBacktrackedTokens/Backtrack calls will
/// be combined with the EnableBacktrackAtThisPos calls in reverse order.
void Preprocessor::EnableBacktrackAtThisPos() {
- CacheTokens = true;
BacktrackPositions.push_back(CachedLexPos);
EnterCachingLexMode();
}
assert(!BacktrackPositions.empty()
&& "EnableBacktrackAtThisPos was not called!");
BacktrackPositions.pop_back();
- CacheTokens = !BacktrackPositions.empty();
}
/// Backtrack - Make Preprocessor re-lex the tokens that were lexed since
&& "EnableBacktrackAtThisPos was not called!");
CachedLexPos = BacktrackPositions.back();
BacktrackPositions.pop_back();
- CacheTokens = !BacktrackPositions.empty();
}
void Preprocessor::CachingLex(Token &Result) {
ExitCachingLexMode();
Lex(Result);
- if (!CacheTokens) {
+ if (!isBacktrackEnabled()) {
// All cached tokens were consumed.
CachedTokens.clear();
CachedLexPos = 0;