[PATCH] D131701: [CodeGen][ObjC] Call synthesized copy constructor/assignment operator functions in getter/setter functions of non-trivial C struct properties

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 1 10:34:56 PDT 2022


rjmccall added inline comments.


================
Comment at: clang/lib/CodeGen/CGObjC.cpp:1429
+          GetAddrOfLocalVar(*setterMethod->param_begin()), ivar->getType());
+      callCStructCopyAssignmentOperator(Dst, Src);
+    } else {
----------------
When the method takes the structure by value, we're passed an owned copy with the responsibility to destroy it in the method, right?  Is there a way for us to do a destructive move-assignment here and suppress the normal destruction of the parameter?


================
Comment at: clang/test/CodeGenObjC/nontrivial-c-struct-property.m:39
+// CHECK: call void @__copy_assignment_8_8_s0(ptr %[[ADD_PTR]], ptr %[[NONATOMIC]])
+// CHECK: call void @__destructor_8_s0(ptr %[[NONATOMIC]])
+
----------------
Yeah, this is the pattern which it would be great to avoid if we can.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131701/new/

https://reviews.llvm.org/D131701



More information about the cfe-commits mailing list