diff options
Diffstat (limited to 'clang/lib/Lex/PPExpressions.cpp')
-rw-r--r-- | clang/lib/Lex/PPExpressions.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp index a6f16f80b79..9246fb188f1 100644 --- a/clang/lib/Lex/PPExpressions.cpp +++ b/clang/lib/Lex/PPExpressions.cpp @@ -108,15 +108,13 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, // Otherwise, we got an identifier, is it defined to something? IdentifierInfo *II = PeekTok.getIdentifierInfo(); - Result.Val = II->hasMacroDefinition(); + Preprocessor::MacroDefinition Macro = PP.getMacroDefinition(II); + Result.Val = !!Macro; Result.Val.setIsUnsigned(false); // Result is signed intmax_t. - MacroDirective *Macro = nullptr; // If there is a macro, mark it used. - if (Result.Val != 0 && ValueLive) { - Macro = PP.getMacroDirective(II); - PP.markMacroAsUsed(Macro->getMacroInfo()); - } + if (Result.Val != 0 && ValueLive) + PP.markMacroAsUsed(Macro.getMacroInfo()); // Save macro token for callback. Token macroToken(PeekTok); @@ -144,10 +142,8 @@ static bool EvaluateDefined(PPValue &Result, Token &PeekTok, DefinedTracker &DT, // Invoke the 'defined' callback. if (PPCallbacks *Callbacks = PP.getPPCallbacks()) { - MacroDirective *MD = Macro; - // Pass the MacroInfo for the macro name even if the value is dead. - if (!MD && Result.Val != 0) - MD = PP.getMacroDirective(II); + // FIXME: Tell callbacks about module macros. + MacroDirective *MD = Macro.getLocalDirective(); Callbacks->Defined(macroToken, MD, SourceRange(beginLoc, PeekTok.getLocation())); } |