[PATCH] D55865: [ObjC] Add a new attribute to opt-out of implicit callee retain/release in ARC

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 21 11:52:53 PST 2018

aaron.ballman added inline comments.

Comment at: clang/test/SemaObjC/externally-retained.m:14
+  EXT_RET int (^d)() = ^{return 0;};
+  EXT_RET ObjCTy *e = 0;
erik.pilkington wrote:
> aaron.ballman wrote:
> > Should this be useful for function pointer parameters as well? e.g.,
> > ```
> > typedef void (*fp)(EXT_RET __strong ObjCTy *);
> > 
> > void f(__strong ObjCTy *);
> > 
> > void g(EXT_RET ObjCTy *Ptr) {
> >   fp Fn = f; // Good idea? Bad idea?
> >   Fn(Ptr); // Which behavior "wins" in this call?
> > }
> > ```
> The attribute doesn't have any effect on the caller side, so when used with a function pointer type the attribute doesn't really do anything (the function definition always "wins").
Perhaps we should warn (and drop the attribute) if you try to write it on a parameter in a function pointer type rather than a function declaration? That way users won't think code like the above does anything useful. Alternatively, we could warn if there was a mismatch between markings (so the attribute is still a noop with function pointer types, but the consistent markings make that benign).



More information about the cfe-commits mailing list