diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp b/contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp index 9cf72cf..4451302 100644 --- a/contrib/llvm/tools/clang/lib/Lex/PPExpressions.cpp +++ b/contrib/llvm/tools/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(); - Result.Val.setIsUnsigned(false); // Result is signed intmax_t. + 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,11 +142,7 @@ 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); - Callbacks->Defined(macroToken, MD, + Callbacks->Defined(macroToken, Macro, SourceRange(beginLoc, PeekTok.getLocation())); } @@ -310,7 +304,9 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, // Set the value. Val = Literal.getValue(); // Set the signedness. UTF-16 and UTF-32 are always unsigned - if (!Literal.isUTF16() && !Literal.isUTF32()) + if (Literal.isWide()) + Val.setIsUnsigned(!TargetInfo::isTypeSigned(TI.getWCharType())); + else if (!Literal.isUTF16() && !Literal.isUTF32()) Val.setIsUnsigned(!PP.getLangOpts().CharIsSigned); if (Result.Val.getBitWidth() > Val.getBitWidth()) { @@ -732,8 +728,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec, /// EvaluateDirectiveExpression - Evaluate an integer constant expression that /// may occur after a #if or #elif directive. If the expression is equivalent /// to "!defined(X)" return X in IfNDefMacro. -bool Preprocessor:: -EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { +bool Preprocessor::EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true); // Save the current state of 'DisableMacroExpansion' and reset it to false. If // 'DisableMacroExpansion' is true, then we must be in a macro argument list |