[clang] [CIR][Upstream] Local initialization for ArrayType (PR #132974)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 31 09:57:46 PDT 2025


================
@@ -103,6 +113,36 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
         getContext(), mlir::cast<cir::PointerType>(type), valueAttr);
   }
 
+  mlir::TypedAttr getConstNullPtrAttr(mlir::Type t) {
+    assert(mlir::isa<cir::PointerType>(t) && "expected cir.ptr");
+    return getConstPtrAttr(t, 0);
+  }
+
+  mlir::TypedAttr getZeroAttr(mlir::Type t) {
+    return cir::ZeroAttr::get(getContext(), t);
+  }
+
+  mlir::TypedAttr getZeroInitAttr(mlir::Type ty) {
+    if (mlir::isa<cir::IntType>(ty))
+      return cir::IntAttr::get(ty, 0);
+    if (auto fltType = mlir::dyn_cast<cir::SingleType>(ty))
----------------
andykaylor wrote:

Let merge the zero-init change first and rebase this one to get the changes there.

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


More information about the cfe-commits mailing list