aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PPCaching.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lex/PPCaching.cpp')
-rw-r--r--lib/Lex/PPCaching.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Lex/PPCaching.cpp b/lib/Lex/PPCaching.cpp
index 53aa09c13040..c3f0eeab5848 100644
--- a/lib/Lex/PPCaching.cpp
+++ b/lib/Lex/PPCaching.cpp
@@ -36,7 +36,7 @@ void Preprocessor::CommitBacktrackedTokens() {
}
/// Backtrack - Make Preprocessor re-lex the tokens that were lexed since
-/// EnableBacktrackAtThisPos() was previously called.
+/// EnableBacktrackAtThisPos() was previously called.
void Preprocessor::Backtrack() {
assert(!BacktrackPositions.empty()
&& "EnableBacktrackAtThisPos was not called!");
@@ -102,7 +102,8 @@ void Preprocessor::AnnotatePreviousCachedTokens(const Token &Tok) {
assert((BacktrackPositions.empty() || BacktrackPositions.back() < i) &&
"The backtrack pos points inside the annotated tokens!");
// Replace the cached tokens with the single annotation token.
- CachedTokens.erase(AnnotBegin + 1, CachedTokens.begin() + CachedLexPos);
+ if (i < CachedLexPos)
+ CachedTokens.erase(AnnotBegin + 1, CachedTokens.begin() + CachedLexPos);
*AnnotBegin = Tok;
CachedLexPos = i;
return;