[clang] [clang][ExprConst] Add early exit in `evaluateDestruction()` (PR #205476)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 24 08:08:57 PDT 2026


================
@@ -21707,6 +21707,12 @@ bool Expr::EvaluateAsInitializer(const ASTContext &Ctx, const VarDecl *VD,
 
 bool VarDecl::evaluateDestruction(
     SmallVectorImpl<PartialDiagnosticAt> &Notes) const {
+
+  if (getType()->isPointerOrReferenceType()) {
+    ensureEvaluatedStmt()->HasConstantDestruction = true;
+    return true;
+  }
+
----------------
tbaederr wrote:

Nope, this is also called for arrays.
I think it should work to short circuit for non-records and array of non-record element type.

https://github.com/llvm/llvm-project/pull/205476


More information about the cfe-commits mailing list