annotate clang/test/SemaObjC/arc-peformselector.m @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
anatofuz
parents:
diff changeset
2 // rdar://9659270
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 @interface NSObject
anatofuz
parents:
diff changeset
5 - (id)copy; // expected-note {{method 'copy' declared here}}
anatofuz
parents:
diff changeset
6 - (id) test __attribute__((ns_returns_retained)); // expected-note {{method 'test' declared here}}
anatofuz
parents:
diff changeset
7 + (id) new ; // expected-note {{method 'new' declared here}}
anatofuz
parents:
diff changeset
8 - (id) init __attribute__((ns_returns_not_retained));
anatofuz
parents:
diff changeset
9 - (id)PlusZero;
anatofuz
parents:
diff changeset
10 - (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method 'PlusOne' declared here}}
anatofuz
parents:
diff changeset
11 - (id)self;
anatofuz
parents:
diff changeset
12 @end
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 @interface I : NSObject
anatofuz
parents:
diff changeset
15 {
anatofuz
parents:
diff changeset
16 SEL sel1;
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18 - (id)performSelector:(SEL)aSelector;
anatofuz
parents:
diff changeset
19 - (id)performSelector:(SEL)aSelector withObject:(id)object;
anatofuz
parents:
diff changeset
20 - (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(double)delay inModes:(I *)modes;
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 @end
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 @implementation I
anatofuz
parents:
diff changeset
27 - (id) Meth {
anatofuz
parents:
diff changeset
28 return [self performSelector : @selector(copy)]; // expected-error {{performSelector names a selector which retains the object}}
anatofuz
parents:
diff changeset
29 return [self performSelector : @selector(test)]; // expected-error {{performSelector names a selector which retains the object}}
anatofuz
parents:
diff changeset
30 return [self performSelector : @selector(new)]; // expected-error {{performSelector names a selector which retains the object}}
anatofuz
parents:
diff changeset
31 return [self performSelector : @selector(init)];
anatofuz
parents:
diff changeset
32 return [self performSelector : sel1]; // expected-warning {{performSelector may cause a leak because its selector is unknown}} \
anatofuz
parents:
diff changeset
33 // expected-note {{used here}}
anatofuz
parents:
diff changeset
34 return [self performSelector: (@selector(PlusZero))];
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 return [self performSelector : @selector(PlusZero)];
anatofuz
parents:
diff changeset
37 return [self performSelector : @selector(PlusOne)]; // expected-error {{performSelector names a selector which retains the object}}
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 // Avoid the unknown selector warning for more complicated performSelector
anatofuz
parents:
diff changeset
40 // variations because it produces too many false positives.
anatofuz
parents:
diff changeset
41 [self performSelector: sel1 withObject:0 afterDelay:0 inModes:0];
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 return [self performSelector: @selector(self)]; // No error, -self is not +1!
anatofuz
parents:
diff changeset
44 }
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 - (id)performSelector:(SEL)aSelector { return 0; }
anatofuz
parents:
diff changeset
47 - (id)performSelector:(SEL)aSelector withObject:(id)object { return 0; }
anatofuz
parents:
diff changeset
48 - (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2 { return 0; }
anatofuz
parents:
diff changeset
49 - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(double)delay inModes:(I *)modes { }
anatofuz
parents:
diff changeset
50 @end