Preprocessor: support defined() with operator names for MS compatibility
Also flesh out missing tests, improve diagnostic QOI and fix a couple of corner
cases found in the process.
Fixes PR10606.
llvm-svn: 209276
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 8be7a54..2260bf9 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -81,7 +81,6 @@
/// EvaluateDefined - Process a 'defined(sym)' expression.
static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
bool ValueLive, Preprocessor &PP) {
- IdentifierInfo *II;
SourceLocation beginLoc(PeekTok.getLocation());
Result.setBegin(beginLoc);
@@ -102,14 +101,13 @@
PP.setCodeCompletionReached();
PP.LexUnexpandedNonComment(PeekTok);
}
-
+
// If we don't have a pp-identifier now, this is an error.
- if ((II = PeekTok.getIdentifierInfo()) == nullptr) {
- PP.Diag(PeekTok, diag::err_pp_defined_requires_identifier);
+ if (PP.CheckMacroName(PeekTok, 0))
return true;
- }
// Otherwise, we got an identifier, is it defined to something?
+ IdentifierInfo *II = PeekTok.getIdentifierInfo();
Result.Val = II->hasMacroDefinition();
Result.Val.setIsUnsigned(false); // Result is signed intmax_t.