[ObjC][Sema] Avoid ARC performSelector error for 'self' selector

The instance method 'self' does not actually return an over-retained object,
so we shouldn't report an error when it's used with 'performSelector'.

rdar://31071620

llvm-svn: 297961
This commit is contained in:
Alex Lorenz 2017-03-16 16:36:11 +00:00
parent 8508e87998
commit 3e54835ad7
2 changed files with 3 additions and 1 deletions

View File

@ -3010,7 +3010,6 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
case OMF_copy:
case OMF_mutableCopy:
case OMF_new:
case OMF_self:
case OMF_init:
// Issue error, unless ns_returns_not_retained.
if (!SelMethod->hasAttr<NSReturnsNotRetainedAttr>()) {

View File

@ -8,6 +8,7 @@
- (id) init __attribute__((ns_returns_not_retained));
- (id)PlusZero;
- (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method 'PlusOne' declared here}}
- (id)self;
@end
@interface I : NSObject
@ -31,6 +32,8 @@
return [self performSelector : @selector(PlusZero)];
return [self performSelector : @selector(PlusOne)]; // expected-error {{performSelector names a selector which retains the object}}
return [self performSelector: @selector(self)]; // No error, -self is not +1!
}
- (id)performSelector:(SEL)aSelector { return 0; }