Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaObjC / arc-peformselector.m
blob1e140e8a2f9b14fb5a26d6f88d51daeb1ab94013
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
3 @interface NSObject
4 - (id)copy; // expected-note {{method 'copy' declared here}}
5 - (id) test __attribute__((ns_returns_retained)); // expected-note {{method 'test' declared here}}
6 + (id) new ; // expected-note {{method 'new' declared here}}
7 - (id) init __attribute__((ns_returns_not_retained));
8 - (id)PlusZero;
9 - (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method 'PlusOne' declared here}}
10 - (id)self;
11 @end
13 @interface I : NSObject
15   SEL sel1;
17 - (id)performSelector:(SEL)aSelector;
18 - (id)performSelector:(SEL)aSelector withObject:(id)object;
19 - (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
21 - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(double)delay inModes:(I *)modes;
23 @end
25 @implementation I
26 - (id) Meth {
27   return [self performSelector : @selector(copy)]; // expected-error {{performSelector names a selector which retains the object}}
28   return [self performSelector : @selector(test)]; // expected-error {{performSelector names a selector which retains the object}}
29   return [self performSelector : @selector(new)]; // expected-error {{performSelector names a selector which retains the object}}
30   return [self performSelector : @selector(init)];
31   return [self performSelector : sel1]; // expected-warning {{performSelector may cause a leak because its selector is unknown}} \
32                                         // expected-note {{used here}}
33   return [self performSelector: (@selector(PlusZero))];
35   return [self performSelector : @selector(PlusZero)];
36   return [self performSelector : @selector(PlusOne)]; // expected-error {{performSelector names a selector which retains the object}}
38   // Avoid the unknown selector warning for more complicated performSelector
39   // variations because it produces too many false positives.
40   [self performSelector: sel1 withObject:0 afterDelay:0 inModes:0];
42   return [self performSelector: @selector(self)]; // No error, -self is not +1!
45 - (id)performSelector:(SEL)aSelector { return 0; }
46 - (id)performSelector:(SEL)aSelector withObject:(id)object { return 0; }
47 - (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2 { return 0; }
48 - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(double)delay inModes:(I *)modes { }
49 @end