2011-10-02 09:16:38 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
|
2011-07-06 06:38:59 +08:00
|
|
|
// rdar://9659270
|
|
|
|
|
|
|
|
@interface NSObject
|
2012-02-28 06:55:11 +08:00
|
|
|
- (id)copy; // expected-note {{method 'copy' declared here}}
|
|
|
|
- (id) test __attribute__((ns_returns_retained)); // expected-note {{method 'test' declared here}}
|
|
|
|
+ (id) new ; // expected-note {{method 'new' declared here}}
|
2011-07-06 06:38:59 +08:00
|
|
|
- (id) init __attribute__((ns_returns_not_retained));
|
|
|
|
- (id)PlusZero;
|
2012-02-28 06:55:11 +08:00
|
|
|
- (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method 'PlusOne' declared here}}
|
2017-03-17 00:36:11 +08:00
|
|
|
- (id)self;
|
2011-07-06 06:38:59 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface I : NSObject
|
|
|
|
{
|
|
|
|
SEL sel1;
|
|
|
|
}
|
|
|
|
- (id)performSelector:(SEL)aSelector;
|
|
|
|
- (id)performSelector:(SEL)aSelector withObject:(id)object;
|
|
|
|
- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
|
2017-03-23 18:46:05 +08:00
|
|
|
|
|
|
|
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(double)delay inModes:(I *)modes;
|
|
|
|
|
2011-07-06 06:38:59 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation I
|
|
|
|
- (id) Meth {
|
|
|
|
return [self performSelector : @selector(copy)]; // expected-error {{performSelector names a selector which retains the object}}
|
|
|
|
return [self performSelector : @selector(test)]; // expected-error {{performSelector names a selector which retains the object}}
|
|
|
|
return [self performSelector : @selector(new)]; // expected-error {{performSelector names a selector which retains the object}}
|
|
|
|
return [self performSelector : @selector(init)];
|
|
|
|
return [self performSelector : sel1]; // expected-warning {{performSelector may cause a leak because its selector is unknown}} \
|
|
|
|
// expected-note {{used here}}
|
2017-02-21 01:55:15 +08:00
|
|
|
return [self performSelector: (@selector(PlusZero))];
|
2011-07-06 06:38:59 +08:00
|
|
|
|
|
|
|
return [self performSelector : @selector(PlusZero)];
|
|
|
|
return [self performSelector : @selector(PlusOne)]; // expected-error {{performSelector names a selector which retains the object}}
|
2017-03-17 00:36:11 +08:00
|
|
|
|
2018-04-06 23:14:32 +08:00
|
|
|
// Avoid the unknown selector warning for more complicated performSelector
|
2017-03-23 18:46:05 +08:00
|
|
|
// variations because it produces too many false positives.
|
|
|
|
[self performSelector: sel1 withObject:0 afterDelay:0 inModes:0];
|
|
|
|
|
2017-03-17 00:36:11 +08:00
|
|
|
return [self performSelector: @selector(self)]; // No error, -self is not +1!
|
2011-07-06 06:38:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id)performSelector:(SEL)aSelector { return 0; }
|
|
|
|
- (id)performSelector:(SEL)aSelector withObject:(id)object { return 0; }
|
|
|
|
- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2 { return 0; }
|
2017-03-23 18:46:05 +08:00
|
|
|
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(double)delay inModes:(I *)modes { }
|
2011-07-06 06:38:59 +08:00
|
|
|
@end
|