[clang] [CIR] Upstream support for emitting constructors (PR #143639)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 11 11:32:51 PDT 2025


================
@@ -496,6 +496,47 @@ cir::FuncOp CIRGenFunction::generateCode(clang::GlobalDecl gd, cir::FuncOp fn,
   return fn;
 }
 
+void CIRGenFunction::emitConstructorBody(FunctionArgList &args) {
+  assert(!cir::MissingFeatures::sanitizers());
+  const auto *ctor = cast<CXXConstructorDecl>(curGD.getDecl());
+  CXXCtorType ctorType = curGD.getCtorType();
+
+  assert((cgm.getTarget().getCXXABI().hasConstructorVariants() ||
+          ctorType == Ctor_Complete) &&
+         "can only generate complete ctor for this ABI");
+
+  if (ctorType == Ctor_Complete && isConstructorDelegationValid(ctor) &&
+      cgm.getTarget().getCXXABI().hasConstructorVariants()) {
+    emitDelegateCXXConstructorCall(ctor, Ctor_Base, args, ctor->getEndLoc());
+    return;
+  }
----------------
andykaylor wrote:

I took your question as referring to the case where we emit the C1 constructor as a delegate constructor call. If you were referring to constructors that delegate in the source code, that isn't handled by this PR.

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


More information about the cfe-commits mailing list