[preprocessor] In Preprocessor::CachingLex() check whether there were more tokens

cached during the non-cached lex, otherwise we are going to drop them.

Fixes a bogus "_Pragma takes a parenthesized string literal" error when
expanding consecutive _Pragmas in a macro argument.

Part of rdar://11168596

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153994 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Argyrios Kyrtzidis 2012-04-04 02:57:01 +00:00
Родитель e14ba2cec3
Коммит a06642a3a3
2 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@ -57,17 +57,21 @@ void Preprocessor::CachingLex(Token &Result) {
ExitCachingLexMode();
Lex(Result);
if (!isBacktrackEnabled()) {
// All cached tokens were consumed.
CachedTokens.clear();
CachedLexPos = 0;
if (isBacktrackEnabled()) {
// Cache the lexed token.
EnterCachingLexMode();
CachedTokens.push_back(Result);
++CachedLexPos;
return;
}
// Cache the lexed token.
EnterCachingLexMode();
CachedTokens.push_back(Result);
++CachedLexPos;
if (CachedLexPos < CachedTokens.size()) {
EnterCachingLexMode();
} else {
// All cached tokens were consumed.
CachedTokens.clear();
CachedLexPos = 0;
}
}
void Preprocessor::EnterCachingLexMode() {

Просмотреть файл

@ -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)