diff options
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 993b64b..244fd92 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -17312,8 +17312,7 @@ bool Expr::EvalResult::isGlobalLValue() const { /// comma, etc // CheckICE - This function does the fundamental ICE checking: the returned -// ICEDiag contains an ICEKind indicating whether the expression is an ICE, -// and a (possibly null) SourceLocation indicating the location of the problem. +// ICEDiag contains an ICEKind indicating whether the expression is an ICE. // // Note that to reduce code duplication, this helper does no evaluation // itself; the caller checks whether the expression is evaluatable, and @@ -17777,46 +17776,38 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) { /// Evaluate an expression as a C++11 integral constant expression. static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx, const Expr *E, - llvm::APSInt *Value, - SourceLocation *Loc) { - if (!E->getType()->isIntegralOrUnscopedEnumerationType()) { - if (Loc) *Loc = E->getExprLoc(); + llvm::APSInt *Value) { + if (!E->getType()->isIntegralOrUnscopedEnumerationType()) return false; - } APValue Result; - if (!E->isCXX11ConstantExpr(Ctx, &Result, Loc)) + if (!E->isCXX11ConstantExpr(Ctx, &Result)) return false; - if (!Result.isInt()) { - if (Loc) *Loc = E->getExprLoc(); + if (!Result.isInt()) return false; - } if (Value) *Value = Result.getInt(); return true; } -bool Expr::isIntegerConstantExpr(const ASTContext &Ctx, - SourceLocation *Loc) const { +bool Expr::isIntegerConstantExpr(const ASTContext &Ctx) const { assert(!isValueDependent() && "Expression evaluator can't be called on a dependent expression."); ExprTimeTraceScope TimeScope(this, Ctx, "isIntegerConstantExpr"); if (Ctx.getLangOpts().CPlusPlus11) - return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr, Loc); + return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr); ICEDiag D = CheckICE(this, Ctx); - if (D.Kind != IK_ICE) { - if (Loc) *Loc = D.Loc; + if (D.Kind != IK_ICE) return false; - } return true; } std::optional<llvm::APSInt> -Expr::getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc) const { +Expr::getIntegerConstantExpr(const ASTContext &Ctx) const { if (isValueDependent()) { // Expression evaluator can't succeed on a dependent expression. return std::nullopt; @@ -17825,12 +17816,12 @@ Expr::getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc) const { APSInt Value; if (Ctx.getLangOpts().CPlusPlus11) { - if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc)) + if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value)) return Value; return std::nullopt; } - if (!isIntegerConstantExpr(Ctx, Loc)) + if (!isIntegerConstantExpr(Ctx)) return std::nullopt; // The only possible side-effects here are due to UB discovered in the @@ -17855,8 +17846,7 @@ bool Expr::isCXX98IntegralConstantExpr(const ASTContext &Ctx) const { return CheckICE(this, Ctx).Kind == IK_ICE; } -bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result, - SourceLocation *Loc) const { +bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result) const { assert(!isValueDependent() && "Expression evaluator can't be called on a dependent expression."); @@ -17877,15 +17867,7 @@ bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result, // call us on arbitrary full-expressions should generally not care. Info.discardCleanups() && !Status.HasSideEffects; - if (!Diags.empty()) { - IsConstExpr = false; - if (Loc) *Loc = Diags[0].first; - } else if (!IsConstExpr) { - // FIXME: This shouldn't happen. - if (Loc) *Loc = getExprLoc(); - } - - return IsConstExpr; + return IsConstExpr && Diags.empty(); } bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx, |