This fixes a bug where the getter/setter functions were doing a trivial copy instead of calling the synthesized functions that copy non-trivial C struct types.
This fixes https://github.com/llvm/llvm-project/issues/56680.
Paths
| Differential D131701
[CodeGen][ObjC] Call synthesized copy constructor/assignment operator functions in getter/setter functions of non-trivial C struct properties ClosedPublic Authored by ahatanak on Aug 11 2022, 10:51 AM.
Details Summary This fixes a bug where the getter/setter functions were doing a trivial copy instead of calling the synthesized functions that copy non-trivial C struct types. This fixes https://github.com/llvm/llvm-project/issues/56680.
Diff Detail
Event TimelineComment Actions There is another bug where an object isn't destructed when a non-trivial C struct property is set. I plan to send a patch that fixes the bug after this.
Comment Actions Call the move assignment operator in the setter instead of calling the copy assignment operator and the destructor. Comment Actions Can we check for the right conditions when emitting the setter body and just deactivate the cleanup? This revision is now accepted and ready to land.Oct 13 2022, 9:28 AM This revision was landed with ongoing or failed builds.Oct 14 2022, 10:41 AM Closed by commit rG28f7087c9163: [CodeGen][ObjC] Call synthesized copy constructor/assignment operator (authored by ahatanak). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 467835 clang/lib/CodeGen/CGObjC.cpp
clang/test/CodeGenObjC/nontrivial-c-struct-property.m
|
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?