[PATCH] D51189: [Sema][ObjC] Infer availability of +new from availability of -init

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 23 17:40:20 PDT 2018


arphaman added a subscriber: ributzka.
arphaman added a comment.

In https://reviews.llvm.org/D51189#1211763, @erik.pilkington wrote:

> In https://reviews.llvm.org/D51189#1211754, @arphaman wrote:
>
> > Hmm, I don't think this solution is ideal, we'd rather have an attribute somewhere for other consumers of availability annotations. Does MyObject have an implicit decl of `new`, or are we referring to `NSObject`s `new`? Ideally we would an attribute on a particular `new` instead, but that might not work.
>
>
> We're referring to NSObject's new. I don't think it's unreasonable to ask users who override init to be unavailable also override new with the same annotation, but it seems like extra boilerplate for something that we can easily infer in clang. What other consumers are you concerned about?


+ @ributzka 
One consumer is TAPI. It looks at the declarations present in the header file, so it won't be able to reason about the availability of `new` with the current implementation. We could potentially implicitly declare unavailable `new` in the interface if `init` is unavailable, but that wouldn't really too work with class categories (since `new` might be explicitly declared there). Maybe it's worth it though.


Repository:
  rC Clang

https://reviews.llvm.org/D51189





More information about the cfe-commits mailing list