@@ -17312,8 +17312,7 @@ bool Expr::EvalResult::isGlobalLValue() const {
17312
17312
/// comma, etc
17313
17313
17314
17314
// 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.
17317
17316
//
17318
17317
// Note that to reduce code duplication, this helper does no evaluation
17319
17318
// itself; the caller checks whether the expression is evaluatable, and
@@ -17777,46 +17776,38 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
17777
17776
/// Evaluate an expression as a C++11 integral constant expression.
17778
17777
static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx,
17779
17778
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())
17784
17781
return false;
17785
- }
17786
17782
17787
17783
APValue Result;
17788
- if (!E->isCXX11ConstantExpr(Ctx, &Result, Loc ))
17784
+ if (!E->isCXX11ConstantExpr(Ctx, &Result))
17789
17785
return false;
17790
17786
17791
- if (!Result.isInt()) {
17792
- if (Loc) *Loc = E->getExprLoc();
17787
+ if (!Result.isInt())
17793
17788
return false;
17794
- }
17795
17789
17796
17790
if (Value) *Value = Result.getInt();
17797
17791
return true;
17798
17792
}
17799
17793
17800
- bool Expr::isIntegerConstantExpr(const ASTContext &Ctx,
17801
- SourceLocation *Loc) const {
17794
+ bool Expr::isIntegerConstantExpr(const ASTContext &Ctx) const {
17802
17795
assert(!isValueDependent() &&
17803
17796
"Expression evaluator can't be called on a dependent expression.");
17804
17797
17805
17798
ExprTimeTraceScope TimeScope(this, Ctx, "isIntegerConstantExpr");
17806
17799
17807
17800
if (Ctx.getLangOpts().CPlusPlus11)
17808
- return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr, Loc );
17801
+ return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, nullptr);
17809
17802
17810
17803
ICEDiag D = CheckICE(this, Ctx);
17811
- if (D.Kind != IK_ICE) {
17812
- if (Loc) *Loc = D.Loc;
17804
+ if (D.Kind != IK_ICE)
17813
17805
return false;
17814
- }
17815
17806
return true;
17816
17807
}
17817
17808
17818
17809
std::optional<llvm::APSInt>
17819
- Expr::getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc ) const {
17810
+ Expr::getIntegerConstantExpr(const ASTContext &Ctx) const {
17820
17811
if (isValueDependent()) {
17821
17812
// Expression evaluator can't succeed on a dependent expression.
17822
17813
return std::nullopt;
@@ -17825,12 +17816,12 @@ Expr::getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc) const {
17825
17816
APSInt Value;
17826
17817
17827
17818
if (Ctx.getLangOpts().CPlusPlus11) {
17828
- if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc ))
17819
+ if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value))
17829
17820
return Value;
17830
17821
return std::nullopt;
17831
17822
}
17832
17823
17833
- if (!isIntegerConstantExpr(Ctx, Loc ))
17824
+ if (!isIntegerConstantExpr(Ctx))
17834
17825
return std::nullopt;
17835
17826
17836
17827
// The only possible side-effects here are due to UB discovered in the
@@ -17855,8 +17846,7 @@ bool Expr::isCXX98IntegralConstantExpr(const ASTContext &Ctx) const {
17855
17846
return CheckICE(this, Ctx).Kind == IK_ICE;
17856
17847
}
17857
17848
17858
- bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result,
17859
- SourceLocation *Loc) const {
17849
+ bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result) const {
17860
17850
assert(!isValueDependent() &&
17861
17851
"Expression evaluator can't be called on a dependent expression.");
17862
17852
@@ -17877,15 +17867,7 @@ bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result,
17877
17867
// call us on arbitrary full-expressions should generally not care.
17878
17868
Info.discardCleanups() && !Status.HasSideEffects;
17879
17869
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();
17889
17871
}
17890
17872
17891
17873
bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
0 commit comments