aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Lex/PPCaching.cpp18
-rw-r--r--test/Preprocessor/_Pragma-in-macro-arg.c2
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/Lex/PPCaching.cpp b/lib/Lex/PPCaching.cpp
index 0d5e34f0bf..6f4c189b4f 100644
--- a/lib/Lex/PPCaching.cpp
+++ b/lib/Lex/PPCaching.cpp
@@ -57,17 +57,21 @@ void Preprocessor::CachingLex(Token &Result) {
ExitCachingLexMode();
Lex(Result);
- if (!isBacktrackEnabled()) {
+ if (isBacktrackEnabled()) {
+ // Cache the lexed token.
+ EnterCachingLexMode();
+ CachedTokens.push_back(Result);
+ ++CachedLexPos;
+ return;
+ }
+
+ if (CachedLexPos < CachedTokens.size()) {
+ EnterCachingLexMode();
+ } else {
// All cached tokens were consumed.
CachedTokens.clear();
CachedLexPos = 0;
- return;
}
-
- // Cache the lexed token.
- EnterCachingLexMode();
- CachedTokens.push_back(Result);
- ++CachedLexPos;
}
void Preprocessor::EnterCachingLexMode() {
diff --git a/test/Preprocessor/_Pragma-in-macro-arg.c b/test/Preprocessor/_Pragma-in-macro-arg.c
index 99a33a9e1b..2877bcb7bf 100644
--- a/test/Preprocessor/_Pragma-in-macro-arg.c
+++ b/test/Preprocessor/_Pragma-in-macro-arg.c
@@ -15,7 +15,7 @@ B(_Pragma("clang diagnostic ignored \"-Wparentheses\""))
// This should be ignored..
INACTIVE(_Pragma("clang diagnostic ignored \"-Wconversion\""))
-#define IGNORE_CONV _Pragma("clang diagnostic ignored \"-Wconversion\"")
+#define IGNORE_CONV _Pragma("clang diagnostic ignored \"-Wconversion\"") _Pragma("clang diagnostic ignored \"-Wconversion\"")
// ..as should this.
INACTIVE(IGNORE_CONV)