]> granicus.if.org Git - clang/commitdiff
Remove Preprocessor::CacheTokens boolean data member. The same functionality can...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 19 Nov 2008 14:23:14 +0000 (14:23 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 19 Nov 2008 14:23:14 +0000 (14:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59631 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Preprocessor.h
lib/Lex/PPCaching.cpp
lib/Lex/Preprocessor.cpp

index 999ba3b4f3db0c6a1f609f12c520840fd42d8be8..9af53bf4947441671e25492e194fa8775130b4f3 100644 (file)
@@ -73,9 +73,6 @@ class Preprocessor {
   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;
@@ -323,7 +320,7 @@ public:
 
   /// 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.
index 1f39088d7f0b6988dff16d9e907c5a31a95cb1b3..ed67754e6e7d8f86f27fbcd29e849fb1e0159159 100644 (file)
@@ -24,7 +24,6 @@ using namespace clang;
 /// 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();
 }
@@ -34,7 +33,6 @@ void Preprocessor::CommitBacktrackedTokens() {
   assert(!BacktrackPositions.empty()
          && "EnableBacktrackAtThisPos was not called!");
   BacktrackPositions.pop_back();
-  CacheTokens = !BacktrackPositions.empty();
 }
 
 /// Backtrack - Make Preprocessor re-lex the tokens that were lexed since
@@ -44,7 +42,6 @@ void Preprocessor::Backtrack() {
          && "EnableBacktrackAtThisPos was not called!");
   CachedLexPos = BacktrackPositions.back();
   BacktrackPositions.pop_back();
-  CacheTokens = !BacktrackPositions.empty();
 }
 
 void Preprocessor::CachingLex(Token &Result) {
@@ -56,7 +53,7 @@ void Preprocessor::CachingLex(Token &Result) {
   ExitCachingLexMode();
   Lex(Result);
 
-  if (!CacheTokens) {
+  if (!isBacktrackEnabled()) {
     // All cached tokens were consumed.
     CachedTokens.clear();
     CachedLexPos = 0;
index 2d4d3a7324d58bd27d00eb38b2c2d3d5f968a302..5e973269945b10163e588a69d74854a31334e46f 100644 (file)
@@ -69,7 +69,6 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts,
   InMacroArgs = false;
   NumCachedTokenLexers = 0;
 
-  CacheTokens = false;
   CachedLexPos = 0;
 
   // "Poison" __VA_ARGS__, which can only appear in the expansion of a macro.