aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2023-11-15 08:29:22 +0100
committerGitHub <noreply@github.com>2023-11-15 08:29:22 +0100
commitf5b378b0d6e516a55fceee79d97c2cbfe58e7845 (patch)
tree1b9a633ef3e6f72d9f7a7efd7c081ac05a2e6cd5 /clang/lib/AST/ExprConstant.cpp
parente2f8ec72555cf42fc74468c9ff686d29434780af (diff)
downloadllvm-f5b378b0d6e516a55fceee79d97c2cbfe58e7845.zip
llvm-f5b378b0d6e516a55fceee79d97c2cbfe58e7845.tar.gz
llvm-f5b378b0d6e516a55fceee79d97c2cbfe58e7845.tar.bz2
[clang] Use new interpreter in EvaluateAsConstantExpr if requested (#70763)
EvaluateAsConstantExpr() uses ::EvaluateInPlace() directly, which does not use the new interpreter if requested. Do it here, which is the same pattern we use in EvaluateAsInitializer.
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 4aa8045..373972e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15672,12 +15672,14 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx,
// this doesn't escape.
MaterializeTemporaryExpr BaseMTE(T, const_cast<Expr*>(this), true);
APValue::LValueBase Base(&BaseMTE);
-
Info.setEvaluatingDecl(Base, Result.Val);
- LValue LVal;
- LVal.set(Base);
- {
+ 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
@@ -15686,10 +15688,10 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx,
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))