[clang] [CIR] Add support for array cleanups (PR #150499)

Morris Hafner via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 25 08:51:39 PDT 2025


================
@@ -649,6 +649,41 @@ void CIRGenFunction::emitNullabilityCheck(LValue lhs, mlir::Value rhs,
   assert(!cir::MissingFeatures::sanitizers());
 }
 
+/// Destroys all the elements of the given array, beginning from last to first.
+/// The array cannot be zero-length.
+///
+/// \param begin - a type* denoting the first element of the array
+/// \param end - a type* denoting one past the end of the array
+/// \param elementType - the element type of the array
+/// \param destroyer - the function to call to destroy elements
+void CIRGenFunction::emitArrayDestroy(mlir::Value begin, mlir::Value end,
+                                      QualType elementType,
+                                      CharUnits elementAlign,
+                                      Destroyer *destroyer,
+                                      bool checkZeroLength) {
+  assert(!elementType->isArrayType());
+  if (checkZeroLength)
+    cgm.errorNYI("emitArrayDestroy: check for zero length");
----------------
mmha wrote:

We turn `ArrayDtor` into a loop in LoweringPrepare. I don't think we ever need to insert a branch here.

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


More information about the cfe-commits mailing list