[clang] [CIR] Add array new cookie support (PR #163649)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 17 14:43:33 PDT 2025


================
@@ -367,7 +379,50 @@ void CIRGenFunction::emitNewArrayInitializer(
   if (!e->hasInitializer())
     return;
 
-  cgm.errorNYI(e->getSourceRange(), "emitNewArrayInitializer");
+  unsigned initListElements = 0;
+
+  const Expr *init = e->getInitializer();
+  const InitListExpr *ile = dyn_cast<InitListExpr>(init);
+  if (ile) {
+    cgm.errorNYI(ile->getSourceRange(), "emitNewArrayInitializer: init list");
+    return;
+  }
+
+  // If all elements have already been initialized, skip any further
+  // initialization.
+  auto constOp = dyn_cast<cir::ConstantOp>(numElements.getDefiningOp());
----------------
andykaylor wrote:

```suggestion
  auto constOp = mlir::dyn_cast<cir::ConstantOp>(numElements.getDefiningOp());
```

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


More information about the cfe-commits mailing list