[clang] [clang][initlist] handle incomplete array type in Constant Expr Calculation (PR #155080)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 23 02:07:41 PDT 2025


================
@@ -4030,9 +4030,13 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
     if (ObjType->isArrayType()) {
       // Next subobject is an array element.
       const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType);
-      assert(CAT && "vla in literal type?");
+      const IncompleteArrayType *IAT =
+          Info.Ctx.getAsIncompleteArrayType(ObjType);
+      const ArrayType *AT = CAT ? static_cast<const ArrayType *>(CAT)
+                                : static_cast<const ArrayType *>(IAT);
+      assert(AT && "vla in literal type?");
----------------
cor3ntin wrote:

I think using getAsArrayType() and asserting the type is either `ConstantArrayType` or `IncompleteArrayType` would simplify that code a bit

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


More information about the cfe-commits mailing list