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

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 6 16:31:35 PDT 2018


erik.pilkington added a comment.

In https://reviews.llvm.org/D51189#1211910, @steven_wu wrote:

> I feel like this is a much tricky situation than just new and init. Following example is the same situation.
>
>   __attribute__((objc_root_class))
>   @interface NSObject
>   - (void) foo;
>   - (void) bar;
>   @end
>  
>   @implementation NSObject
>   - (void) foo {}
>   - (void) bar { [self foo]; }
>   @end
>  
>   @interface MyObject : NSObject
>   - (void) foo __attribute__((unavailable));
>   @end
>  
>   void test(MyObject *obj) {
>     [obj bar];
>   }
>
>
> We can do something about [NSObject new] because we know it's implementation but we have to live with more general cases.


I agree that the general case is impossible to properly diagnose, but I think its totally reasonable for us to special case this pattern with NSObject.



================
Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6951
+                                 std::string *Message,
+                                 ObjCInterfaceDecl *ClassMessageReceiver) {
   AvailabilityResult Result = D->getAvailability(Message);
----------------
arphaman wrote:
> Please be consistent with the name, you are using `ClassMessageReceiver`, `ClassReceiver` and `Receiver` in different arguments in this patch.
Sure, sorry. I canonicalized on ClassReceiver.


https://reviews.llvm.org/D51189





More information about the cfe-commits mailing list