This is an archive of the discontinued LLVM Phabricator instance.

[ObjC] Follow-up r350768 and allow the use of unavailable methods that are declared in a parent class from within the @implementation context
ClosedPublic

Authored by arphaman on Jan 16 2019, 3:16 PM.

Details

Summary

This patch extends r350768 and allows the use of methods marked as unavailable that are declared in a parent class/category from within the @implementation of the class where the method is marked as unavailable.
This allows users to call init that's marked as unavailable even if they don't define it.

Diff Detail

Repository
rC Clang

Event Timeline

arphaman created this revision.Jan 16 2019, 3:16 PM
lib/Sema/SemaDeclAttr.cpp
7372–7373

Why not just always accept a use of an unavailable method so long as its declared in the interface?

i.e., doesn't it make sense to accept something like the following? It seems like you're going out of your way to reject it though:

@interface Base 
-(void)doAThing;
-(void)doAThingImpl __attribute__((unavailable));
@end

@implemenation Base
-(void)doAThing { [self doAThingImpl]; }
@end

@interface Derived1 : Base @end
@interface Derived2 : Base @end

@implementation Derived1 
-(void)doAThingImpl { ... }
@end

@implementation Derived2
-(void)doAThingImpl { ... }
@end
arphaman updated this revision to Diff 182191.Jan 16 2019, 4:56 PM

Follow Erik's suggestion and don't check for definition/declaration in parent class.

My understanding is that rL349841 accidentally started producing some spurious warnings/errors, rL350768 fixed some instances, and this change fixes more instances. Given that the first two changes are already in the 8.0 branch, should this be cherry-picked to 8.0 as well once it lands?

My understanding is that rL349841 accidentally started producing some spurious warnings/errors, rL350768 fixed some instances, and this change fixes more instances. Given that the first two changes are already in the 8.0 branch, should this be cherry-picked to 8.0 as well once it lands?

Yes.

erik.pilkington accepted this revision.Jan 16 2019, 8:51 PM

LGTM, thanks!

This revision is now accepted and ready to land.Jan 16 2019, 8:51 PM
This revision was automatically updated to reflect the committed changes.