aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/Parser.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-19 15:22:16 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-11-19 15:22:16 +0000
commit08b2c3743a29a2dddcf72e95f747760e213cdde7 (patch)
tree5c7f33ab3fe286c42643cfde7a88ec9979aa61b1 /lib/Parse/Parser.cpp
parentfad03b2b38a3baea4b67e79e676fee15078e3258 (diff)
Fix this:
With this snippet: void f(a::b); An assert is hit: Assertion failed: CachedTokens[CachedLexPos-1].getLocation() == Tok.getAnnotationEndLoc() && "The annotation should be until the most recent cached token", file ..\..\lib\Lex\PPCaching.cpp, line 98 Introduce Preprocessor::RevertCachedTokens that reverts a specific number of tokens when backtracking is enabled. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59636 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/Parser.cpp')
-rw-r--r--lib/Parse/Parser.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 86526cc158..861609ce75 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -731,9 +731,12 @@ void Parser::TryAnnotateTypeOrScopeToken() {
if (SS.isNotEmpty()) {
// A C++ scope specifier that isn't followed by a typename.
- // Push the current token back into the token stream and use an annotation
- // scope token for current token.
- PP.EnterToken(Tok);
+ // Push the current token back into the token stream (or revert it if it is
+ // cached) and use an annotation scope token for current token.
+ if (PP.isBacktrackEnabled())
+ PP.RevertCachedTokens(1);
+ else
+ PP.EnterToken(Tok);
Tok.setKind(tok::annot_cxxscope);
Tok.setAnnotationValue(SS.getScopeRep());
Tok.setAnnotationRange(SS.getRange());
@@ -754,9 +757,12 @@ void Parser::TryAnnotateScopeToken() {
CXXScopeSpec SS;
ParseCXXScopeSpecifier(SS);
- // Push the current token back into the token stream and use an annotation
- // scope token for current token.
- PP.EnterToken(Tok);
+ // Push the current token back into the token stream (or revert it if it is
+ // cached) and use an annotation scope token for current token.
+ if (PP.isBacktrackEnabled())
+ PP.RevertCachedTokens(1);
+ else
+ PP.EnterToken(Tok);
Tok.setKind(tok::annot_cxxscope);
Tok.setAnnotationValue(SS.getScopeRep());
Tok.setAnnotationRange(SS.getRange());