[clang] [clang] Fix parenthesized list initialization of arrays not working with `new` (PR #76976)

Mital Ashok via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 08:36:51 PST 2024


================
@@ -1073,7 +1075,7 @@ void CodeGenFunction::EmitNewArrayInitializer(
       return;
     }
 
-    InitListElements = ILE->getNumInits();
+    InitListElements = ILE ? ILE->getNumInits() : CPLIE->getInitExprs().size();
----------------
MitalAshok wrote:

```suggestion
    ArrayRef<const Expr *> InitExprs = ILE ? ILE->inits() : CPLIE->getInitExprs();
    InitListElements = InitExprs.size();
```

If you move this up from below it can look cleaner

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


More information about the cfe-commits mailing list