[clang] [CIR] Report NYI for defaulted union copy/move assignment (PR #198918)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 23 13:01:16 PDT 2026


================
@@ -901,6 +901,36 @@ void CIRGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &args) {
   assert(!cir::MissingFeatures::incrementProfileCounter());
   assert(!cir::MissingFeatures::runCleanupsScope());
 
+  // For a memcpy-equivalent assignment operator, copy the whole object, then
+  // fall through to emit the trailing `return *this`.
+  if (assignOp->isMemcpyEquivalentSpecialMember(getContext())) {
+    CanQualType recordTy =
+        getContext().getCanonicalTagType(assignOp->getParent());
+    LValue dest = makeNaturalAlignAddrLValue(loadCXXThis(), recordTy);
+    mlir::Value srcPtr = builder.createLoad(getLoc(assignOp->getLocation()),
+                                            getAddrOfLocalVar(args.back()));
+    LValue src = makeNaturalAlignAddrLValue(srcPtr, recordTy);
+    emitAggregateAssign(dest, src, recordTy);
----------------
adams381 wrote:

Dropped the whole-object synthesis. Struct and array assignments already carry the per-field copies in their defaulted bodies (a builtin memcpy for arrays), so those go through the normal body emission unchanged -- only the union needed handling, and it's NYI here. I'll do the union AST fix in a separate PR.

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


More information about the cfe-commits mailing list