Skip to content

Commit

Permalink
[clang][NFC] Clean up Expr::EvaluateAsConstantExpr (#130498)
Browse files Browse the repository at this point in the history
The Info.EnableNewConstInterp case is already handled above.
  • Loading branch information
tbaederr authored Mar 10, 2025
1 parent 6e8d7e2 commit 35f273a
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16903,24 +16903,19 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx,
APValue::LValueBase Base(&BaseMTE);
Info.setEvaluatingDecl(Base, Result.Val);

if (Info.EnableNewConstInterp) {
if (!Info.Ctx.getInterpContext().evaluateAsRValue(Info, this, Result.Val))
return false;
} else {
LValue LVal;
LVal.set(Base);
// C++23 [intro.execution]/p5
// A full-expression is [...] a constant-expression
// So we need to make sure temporary objects are destroyed after having
// evaluating the expression (per C++23 [class.temporary]/p4).
FullExpressionRAII Scope(Info);
if (!::EvaluateInPlace(Result.Val, Info, LVal, this) ||
Result.HasSideEffects || !Scope.destroy())
return false;
LValue LVal;
LVal.set(Base);
// C++23 [intro.execution]/p5
// A full-expression is [...] a constant-expression
// So we need to make sure temporary objects are destroyed after having
// evaluating the expression (per C++23 [class.temporary]/p4).
FullExpressionRAII Scope(Info);
if (!::EvaluateInPlace(Result.Val, Info, LVal, this) ||
Result.HasSideEffects || !Scope.destroy())
return false;

if (!Info.discardCleanups())
llvm_unreachable("Unhandled cleanup; missing full expression marker?");
}
if (!Info.discardCleanups())
llvm_unreachable("Unhandled cleanup; missing full expression marker?");

if (!CheckConstantExpression(Info, getExprLoc(), getStorageType(Ctx, this),
Result.Val, Kind))
Expand Down

0 comments on commit 35f273a

Please sign in to comment.