@@ -17312,8 +17312,7 @@ bool Expr::EvalResult::isGlobalLValue() const {
1731217312/// comma, etc
1731317313
1731417314// CheckICE - This function does the fundamental ICE checking: the returned
17315- // ICEDiag contains an ICEKind indicating whether the expression is an ICE,
17316- // and a (possibly null) SourceLocation indicating the location of the problem.
17315+ // ICEDiag contains an ICEKind indicating whether the expression is an ICE.
1731717316//
1731817317// Note that to reduce code duplication, this helper does no evaluation
1731917318// itself; the caller checks whether the expression is evaluatable, and
@@ -17777,46 +17776,38 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
1777717776/// Evaluate an expression as a C++11 integral constant expression.
1777817777static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx,
1777917778 const Expr *E,
17780- llvm::APSInt *Value,
17781- SourceLocation *Loc) {
17782- if (!E->getType()->isIntegralOrUnscopedEnumerationType()) {
17783- if (Loc) *Loc = E->getExprLoc();
17779+ llvm::APSInt *Value) {
17780+ if (!E->getType()->isIntegralOrUnscopedEnumerationType())
1778417781 return false;
17785- }
1778617782
1778717783 APValue Result;
17788- if (!E->isCXX11ConstantExpr(Ctx, &Result, Loc ))
17784+ if (!E->isCXX11ConstantExpr(Ctx, &Result))
1778917785 return false;
1779017786
17791- if (!Result.isInt()) {
17792- if (Loc) *Loc = E->getExprLoc();
17787+ if (!Result.isInt())
1779317788 return false;
17794- }
1779517789
1779617790 if (Value) *Value = Result.getInt();
1779717791 return true;
1779817792}
1779917793
17800- bool Expr::isIntegerConstantExpr(const ASTContext &Ctx,
17801- SourceLocation *Loc) const {
17794+ bool Expr::isIntegerConstantExpr(const ASTContext &Ctx) const {
1780217795 assert(!isValueDependent() &&
1780317796 "Expression evaluator can't be called on a dependent expression.");
1780417797
1780517798 ExprTimeTraceScope TimeScope(this, Ctx, "isIntegerConstantExpr");
1780617799
1780717800 if (Ctx.getLangOpts().CPlusPlus11)
17808- return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr, Loc );
17801+ return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr);
1780917802
1781017803 ICEDiag D = CheckICE(this, Ctx);
17811- if (D.Kind != IK_ICE) {
17812- if (Loc) *Loc = D.Loc;
17804+ if (D.Kind != IK_ICE)
1781317805 return false;
17814- }
1781517806 return true;
1781617807}
1781717808
1781817809std::optional<llvm::APSInt>
17819- Expr::getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc ) const {
17810+ Expr::getIntegerConstantExpr(const ASTContext &Ctx) const {
1782017811 if (isValueDependent()) {
1782117812 // Expression evaluator can't succeed on a dependent expression.
1782217813 return std::nullopt;
@@ -17825,12 +17816,12 @@ Expr::getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc) const {
1782517816 APSInt Value;
1782617817
1782717818 if (Ctx.getLangOpts().CPlusPlus11) {
17828- if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc ))
17819+ if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value))
1782917820 return Value;
1783017821 return std::nullopt;
1783117822 }
1783217823
17833- if (!isIntegerConstantExpr(Ctx, Loc ))
17824+ if (!isIntegerConstantExpr(Ctx))
1783417825 return std::nullopt;
1783517826
1783617827 // The only possible side-effects here are due to UB discovered in the
@@ -17855,8 +17846,7 @@ bool Expr::isCXX98IntegralConstantExpr(const ASTContext &Ctx) const {
1785517846 return CheckICE(this, Ctx).Kind == IK_ICE;
1785617847}
1785717848
17858- bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result,
17859- SourceLocation *Loc) const {
17849+ bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result) const {
1786017850 assert(!isValueDependent() &&
1786117851 "Expression evaluator can't be called on a dependent expression.");
1786217852
@@ -17877,15 +17867,7 @@ bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result,
1787717867 // call us on arbitrary full-expressions should generally not care.
1787817868 Info.discardCleanups() && !Status.HasSideEffects;
1787917869
17880- if (!Diags.empty()) {
17881- IsConstExpr = false;
17882- if (Loc) *Loc = Diags[0].first;
17883- } else if (!IsConstExpr) {
17884- // FIXME: This shouldn't happen.
17885- if (Loc) *Loc = getExprLoc();
17886- }
17887-
17888- return IsConstExpr;
17870+ return IsConstExpr && Diags.empty();
1788917871}
1789017872
1789117873bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
0 commit comments