[clang] [CIR] Upstream local initialization for VectorType (PR #138107)

Amr Hesham via cfe-commits cfe-commits at lists.llvm.org
Thu May 1 13:51:25 PDT 2025


================
@@ -1584,6 +1586,47 @@ mlir::Value ScalarExprEmitter::VisitMemberExpr(MemberExpr *e) {
   return emitLoadOfLValue(e);
 }
 
+mlir::Value ScalarExprEmitter::VisitInitListExpr(InitListExpr *e) {
+  const unsigned numInitElements = e->getNumInits();
+
+  if (e->hadArrayRangeDesignator()) {
+    cgf.cgm.errorNYI(e->getSourceRange(), "ArrayRangeDesignator");
+    return {};
+  }
+
+  if (numInitElements == 0) {
+    cgf.cgm.errorNYI(e->getSourceRange(), "InitListExpr with 0 init elements");
+    return {};
+  }
+
+  if (e->getType()->isVectorType()) {
+    const auto vectorType =
+        mlir::cast<cir::VectorType>(cgf.convertType(e->getType()));
+
+    SmallVector<mlir::Value, 16> elements;
+    for (Expr *init : e->inits()) {
----------------
AmrDeveloper wrote:

We can't because we need to pass it to Visit function which take `Expr` not `const Expr`

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


More information about the cfe-commits mailing list