attr-deprecated-replacement-fixit.m
8.89 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -verify -fsyntax-only %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --implicit-check-not fix-it: %s
// RUN: cp %s %t
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DIGNORE_UNSUCCESSFUL_RENAMES -fixit -x objective-c %t
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DIGNORE_UNSUCCESSFUL_RENAMES -Werror -x objective-c %t
#if !__has_feature(attribute_deprecated_with_replacement)
#error "Missing __has_feature"
#endif
#if !__has_feature(attribute_availability_with_replacement)
#error "Missing __has_feature"
#endif
#define DEPRECATED(replacement) __attribute__((deprecated("message", replacement)))
@protocol SuccessfulMultiParameterRenames
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 DEPRECATED("multi_new:parameter_new:replace_new_ment:");
- (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3;
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)varArgs:(int)params, ... DEPRECATED("renameVarArgs:");
- (void)renameVarArgs:(int)params, ...;
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)leadingMinus:(int)param DEPRECATED("-leadingMinusRenamed:");
- (void)leadingMinusRenamed:(int)param;
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)leadingPlus:(int)param DEPRECATED("+leadingPlusRenamed:");
- (void)leadingPlusRenamed:(int)param;
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)sourceEmptyName:(int)param1 :(int)param2 DEPRECATED("renameEmptyName:toNonEmpty:");
- (void)renameEmptyName:(int)param1 toNonEmpty:(int)param2;
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)target:(int)param1 willBecomeEmpty:(int)param2 emptyName:(int)param3 DEPRECATED("target::emptyName:");
- (void)target:(int)param1 :(int)param2 emptyName:(int)param3;
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)extra:(int)param1 whiteSpace:(int)param2 DEPRECATED("renameExtra:whiteSpace:");
- (void)renameExtra:(int)param1 whiteSpace:(int)param2;
// Test renaming that was producing valid code earlier is still producing valid
// code. The difference is that now we detect different number of parameters.
//
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)singleArgumentRegression:(int)param DEPRECATED("renameSingleArgument");
- (void)renameSingleArgument:(int)param;
@end
void successfulRenames(id<SuccessfulMultiParameterRenames> object) {
[object multi:0 parameter:1 replacement:2]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:16}:"multi_new"
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:19-[[@LINE-2]]:28}:"parameter_new"
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:31-[[@LINE-3]]:42}:"replace_new_ment"
[object varArgs:1, 2, 3, 0]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:18}:"renameVarArgs"
[object leadingMinus:0]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:23}:"leadingMinusRenamed"
[object leadingPlus:0]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:22}:"leadingPlusRenamed"
[object sourceEmptyName:0 :1]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:26}:"renameEmptyName"
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:29-[[@LINE-2]]:29}:"toNonEmpty"
[object target:0 willBecomeEmpty:1 emptyName:2]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:17}:"target"
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:20-[[@LINE-2]]:35}:""
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:38-[[@LINE-3]]:47}:"emptyName"
[object extra: 0 whiteSpace: 1]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:16}:"renameExtra"
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:23-[[@LINE-2]]:33}:"whiteSpace"
[object singleArgumentRegression:0]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:35}:"renameSingleArgument"
}
#ifndef IGNORE_UNSUCCESSFUL_RENAMES
@protocol UnsuccessfulMultiParameterRenames
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)differentNumberOfParameters:(int)param DEPRECATED("rename:hasMoreParameters:");
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)differentNumber:(int)param1 ofParameters:(int)param2 DEPRECATED("renameHasLessParameters:");
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)methodLike:(int)param1 replacement:(int)param2 DEPRECATED("noColon:atTheEnd");
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)freeFormText DEPRECATED("Use something else");
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)freeFormTextReplacementStartsAsMethod DEPRECATED("-Use something different");
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)replacementHasSingleSkipCharacter DEPRECATED("-");
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)replacementHasInvalid:(int)param1 slotName:(int)param2 DEPRECATED("renameWith:1nonIdentifier:");
@end
void unsuccessfulRenames(id<UnsuccessfulMultiParameterRenames> object) {
[object differentNumberOfParameters:0]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:38}:"rename:hasMoreParameters:"
[object differentNumber:0 ofParameters:1]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:26}:"renameHasLessParameters:"
[object methodLike:0 replacement:1]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:21}:"noColon:atTheEnd"
[object freeFormText]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:23}:"Use something else"
[object freeFormTextReplacementStartsAsMethod]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:48}:"-Use something different"
[object replacementHasSingleSkipCharacter]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:44}:"-"
[object replacementHasInvalid:0 slotName:1]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:32}:"renameWith:1nonIdentifier:"
}
#endif // IGNORE_UNSUCCESSFUL_RENAMES
// Make sure classes are treated the same way as protocols.
__attribute__((objc_root_class))
@interface Interface
// expected-note@+1 {{has been explicitly marked deprecated here}}
+ (void)classMethod:(int)param1 replacement:(int)param2 DEPRECATED("renameClassMethod:replace_new_ment:");
+ (void)renameClassMethod:(int)param1 replace_new_ment:(int)param2;
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 DEPRECATED("multi_new:parameter_new:replace_new_ment:");
- (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3;
@end
@implementation Interface
+ (void)classMethod:(int)param1 replacement:(int)param2 {}
+ (void)renameClassMethod:(int)param1 replace_new_ment:(int)param2 {}
- (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 {}
- (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3 {}
- (void)usage {
[Interface classMethod:0 replacement:1]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:25}:"renameClassMethod"
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:28-[[@LINE-2]]:39}:"replace_new_ment"
[self multi:0 parameter:1 replacement:2]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"multi_new"
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:17-[[@LINE-2]]:26}:"parameter_new"
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:29-[[@LINE-3]]:40}:"replace_new_ment"
}
@end
// Make sure availability attribute is handled the same way as deprecation attribute.
@protocol AvailabilityAttributeRenames
// expected-note@+1 {{has been explicitly marked deprecated here}}
- (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 __attribute__((availability(macosx,deprecated=9.0,replacement="multi_new:parameter_new:replace_new_ment:")));
- (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3;
@end
void availabilityAttributeRenames(id<AvailabilityAttributeRenames> object) {
[object multi:0 parameter:1 replacement:2]; // expected-warning {{is deprecated}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:16}:"multi_new"
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:19-[[@LINE-2]]:28}:"parameter_new"
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:31-[[@LINE-3]]:42}:"replace_new_ment"
}