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

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 25 17:59:12 PDT 2025


================
@@ -254,3 +254,27 @@ mlir::Type CIRGenTypes::convertTypeForMem(clang::QualType qualType,
 
   return convertedType;
 }
+
+bool CIRGenTypes::isZeroInitializable(clang::QualType t) {
+  if (t->getAs<PointerType>())
+    return astContext.getTargetNullPointerValue(t) == 0;
+
+  if (const auto *at = astContext.getAsArrayType(t)) {
+    if (isa<IncompleteArrayType>(at))
+      return true;
+
+    if (const auto *cat = dyn_cast<ConstantArrayType>(at))
+      if (astContext.getConstantArrayElementCount(cat) == 0)
+        return true;
+  }
+
+  if (const RecordType *rt = t->getAs<RecordType>()) {
+    cgm.errorNYI(SourceLocation(), "isZeroInitializable for RecordType", t);
----------------
andykaylor wrote:

Should we return false after the NYI case?

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


More information about the cfe-commits mailing list