potentially-direct-selector.m
7.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// RUN: %clang_cc1 %s -Wpotentially-direct-selector -verify
// RUN: %clang_cc1 %s -Wstrict-potentially-direct-selector -verify=expected,strict
#define NS_DIRECT __attribute__((objc_direct))
__attribute__((objc_root_class))
@interface Dummies
-(void)inBase;
-(void)inBaseImpl;
-(void)inBaseCat;
-(void)inBaseCatImpl;
-(void)inDerived;
-(void)inDerivedImpl;
-(void)inDerivedCat;
-(void)inDerivedCatImpl;
+(void)inBaseClass;
+(void)inDerivedClass;
+(void)inDerivedCatClass;
@end
__attribute__((objc_root_class))
@interface Base
-(void)inBase NS_DIRECT; // expected-note + {{direct method}}
+(void)inBaseClass NS_DIRECT; // expected-note + {{direct method}}
@end
@implementation Base
-(void)inBaseImpl NS_DIRECT { // expected-note + {{direct method}}
}
-(void)inBase {}
+(void)inBaseClass {}
@end
@interface Base (Cat)
-(void)inBaseCat NS_DIRECT; // expected-note + {{direct method}}
@end
@implementation Base (Cat)
-(void)inBaseCatImpl NS_DIRECT { // expected-note + {{direct method}}
}
-(void)inBaseCat {}
@end
@interface Derived : Base
-(void)inDerived NS_DIRECT; // expected-note + {{direct method}}
+(void)inDerivedClass NS_DIRECT; // expected-note + {{direct method}}
@end
@implementation Derived
-(void)inDerivedImpl NS_DIRECT { // expected-note + {{direct method}}
}
-(void)inDerived {}
+(void)inDerivedClass {}
@end
@interface Derived (Cat)
-(void)inDerivedCat NS_DIRECT; // expected-note + {{direct method}}
+(void)inDerivedCatClass NS_DIRECT; // expected-note + {{direct method}}
@end
@implementation Derived (Cat)
-(void)inDerivedCatImpl NS_DIRECT { // expected-note + {{direct method}}
}
-(void)inDerivedCat {}
+(void)inDerivedCatClass {}
-(void)test1 {
(void)@selector(inBase); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseCat); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerived); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCat); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedClass); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseClass); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCatClass); // expected-warning{{@selector expression formed with potentially direct selector}}
}
@end
void test2() {
(void)@selector(inBase); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseCat); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedClass); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseClass); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCatClass); // strict-warning{{@selector expression formed with potentially direct selector}}
}
@interface OnlyBase : Base @end
@implementation OnlyBase
-(void)test3 {
(void)@selector(inBase); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseCat); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedClass); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseClass); // expected-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCatClass); // strict-warning{{@selector expression formed with potentially direct selector}}
}
@end
__attribute__((objc_root_class))
@interface Unrelated @end
@implementation Unrelated
-(void)test4 {
(void)@selector(inBase); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseCat); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedClass); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inBaseClass); // strict-warning{{@selector expression formed with potentially direct selector}}
(void)@selector(inDerivedCatClass); // strict-warning{{@selector expression formed with potentially direct selector}}
}
@end
@implementation Dummies
-(void)inBase {}
-(void)inBaseImpl {}
-(void)inBaseCat {}
-(void)inBaseCatImpl {}
-(void)inDerived {}
-(void)inDerivedImpl {}
-(void)inDerivedCat {}
-(void)inDerivedCatImpl {}
+(void)inBaseClass {}
+(void)inDerivedClass {}
+(void)inDerivedCatClass {}
-(void)test5 {
(void)@selector(inBase);
(void)@selector(inBaseImpl);
(void)@selector(inBaseCat);
(void)@selector(inBaseCatImpl);
(void)@selector(inDerived);
(void)@selector(inDerivedImpl);
(void)@selector(inDerivedCat);
(void)@selector(inDerivedCatImpl);
(void)@selector(inDerivedClass);
(void)@selector(inBaseClass);
(void)@selector(inDerivedCatClass);
}
@end