[clang] [CIR] Refactor global variable emission and initialization (PR #138222)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri May 2 13:10:20 PDT 2025


================
@@ -118,7 +210,26 @@ class ConstExprEmitter
   }
 
   mlir::Attribute VisitInitListExpr(InitListExpr *ile, QualType t) {
-    cgm.errorNYI(ile->getBeginLoc(), "ConstExprEmitter::VisitInitListExpr");
+    if (ile->isTransparent())
+      return Visit(ile->getInit(0), t);
+
+    if (ile->getType()->isArrayType()) {
+      // If we return null here, the non-constant initializer will take care of
+      // it, but we would prefer to handle it here.
+      assert(!cir::MissingFeatures::constEmitterArrayILE());
+      return {};
+    }
+
+    if (ile->getType()->isRecordType())
+      cgm.errorNYI(ile->getBeginLoc(), "ConstExprEmitter: record ILE");
----------------
andykaylor wrote:

I've been using MissingFeature for places where we need to do something but either can't check for the conditions where we need to do it yet (because the check uses constructs that haven't been upstreamed yet) or we don't want to issue an error (as in the other two cases here). So, I don't think it would add anything here.

I'll add the explicit return.

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


More information about the cfe-commits mailing list