[clang] [CIR] Unblock simple C++ structure support (PR #138368)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon May 5 11:10:07 PDT 2025


================
@@ -365,10 +365,15 @@ mlir::Attribute ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &d) {
   if (!d.hasLocalStorage()) {
     QualType ty = cgm.getASTContext().getBaseElementType(d.getType());
     if (ty->isRecordType())
-      if (d.getInit() && isa<CXXConstructExpr>(d.getInit())) {
-        cgm.errorNYI(d.getInit()->getBeginLoc(),
-                     "tryEmitPrivateForVarInit CXXConstructExpr");
-        return {};
+      if (const CXXConstructExpr *e =
+              dyn_cast_or_null<CXXConstructExpr>(d.getInit())) {
+        const CXXConstructorDecl *cd = e->getConstructor();
----------------
erichkeane wrote:

Ok, glad to know.  Sometimes the `decl` elements of an expr can be null in subtle situations.

As far as elidable.  There is a `CXXConstructExpr::isElidable` that I'm surprised we don't have to express here, since the idea is that we could skip the construction.

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


More information about the cfe-commits mailing list