[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / SemaObjC / attr-deprecated-replacement-fixit.m
blob9d0fcf91a2e07fd5ab45c8318baec7c8088a5892
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -verify -fsyntax-only %s
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --implicit-check-not fix-it: %s
3 // RUN: cp %s %t
4 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DIGNORE_UNSUCCESSFUL_RENAMES -fixit -x objective-c %t
5 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DIGNORE_UNSUCCESSFUL_RENAMES -Werror -x objective-c %t
7 #if !__has_feature(attribute_deprecated_with_replacement)
8 #error "Missing __has_feature"
9 #endif
11 #if !__has_feature(attribute_availability_with_replacement)
12 #error "Missing __has_feature"
13 #endif
15 #define DEPRECATED(replacement) __attribute__((deprecated("message", replacement)))
17 @protocol SuccessfulMultiParameterRenames
18 // expected-note@+1 {{has been explicitly marked deprecated here}}
19 - (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 DEPRECATED("multi_new:parameter_new:replace_new_ment:");
20 - (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3;
22 // expected-note@+1 {{has been explicitly marked deprecated here}}
23 - (void)varArgs:(int)params, ... DEPRECATED("renameVarArgs:");
24 - (void)renameVarArgs:(int)params, ...;
26 // expected-note@+1 {{has been explicitly marked deprecated here}}
27 - (void)leadingMinus:(int)param DEPRECATED("-leadingMinusRenamed:");
28 - (void)leadingMinusRenamed:(int)param;
30 // expected-note@+1 {{has been explicitly marked deprecated here}}
31 - (void)leadingPlus:(int)param DEPRECATED("+leadingPlusRenamed:");
32 - (void)leadingPlusRenamed:(int)param;
34 // expected-note@+1 {{has been explicitly marked deprecated here}}
35 - (void)sourceEmptyName:(int)param1 :(int)param2 DEPRECATED("renameEmptyName:toNonEmpty:");
36 - (void)renameEmptyName:(int)param1 toNonEmpty:(int)param2;
38 // expected-note@+1 {{has been explicitly marked deprecated here}}
39 - (void)target:(int)param1 willBecomeEmpty:(int)param2 emptyName:(int)param3 DEPRECATED("target::emptyName:");
40 - (void)target:(int)param1 :(int)param2 emptyName:(int)param3;
42 // expected-note@+1 {{has been explicitly marked deprecated here}}
43 - (void)extra:(int)param1 whiteSpace:(int)param2 DEPRECATED("renameExtra:whiteSpace:");
44 - (void)renameExtra:(int)param1 whiteSpace:(int)param2;
46 // Test renaming that was producing valid code earlier is still producing valid
47 // code. The difference is that now we detect different number of parameters.
49 // expected-note@+1 {{has been explicitly marked deprecated here}}
50 - (void)singleArgumentRegression:(int)param DEPRECATED("renameSingleArgument");
51 - (void)renameSingleArgument:(int)param;
52 @end
54 void successfulRenames(id<SuccessfulMultiParameterRenames> object) {
55   [object multi:0 parameter:1 replacement:2]; // expected-warning {{is deprecated}}
56   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:16}:"multi_new"
57   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:19-[[@LINE-2]]:28}:"parameter_new"
58   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:31-[[@LINE-3]]:42}:"replace_new_ment"
60   [object varArgs:1, 2, 3, 0]; // expected-warning {{is deprecated}}
61   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:18}:"renameVarArgs"
63   [object leadingMinus:0]; // expected-warning {{is deprecated}}
64   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:23}:"leadingMinusRenamed"
66   [object leadingPlus:0]; // expected-warning {{is deprecated}}
67   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:22}:"leadingPlusRenamed"
69   [object sourceEmptyName:0 :1]; // expected-warning {{is deprecated}}
70   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:26}:"renameEmptyName"
71   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:29-[[@LINE-2]]:29}:"toNonEmpty"
73   [object target:0 willBecomeEmpty:1 emptyName:2]; // expected-warning {{is deprecated}}
74   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:17}:"target"
75   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:20-[[@LINE-2]]:35}:""
76   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:38-[[@LINE-3]]:47}:"emptyName"
78   [object extra: 0    whiteSpace:   1]; // expected-warning {{is deprecated}}
79   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:16}:"renameExtra"
80   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:23-[[@LINE-2]]:33}:"whiteSpace"
82   [object singleArgumentRegression:0]; // expected-warning {{is deprecated}}
83   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:35}:"renameSingleArgument"
86 #ifndef IGNORE_UNSUCCESSFUL_RENAMES
87 @protocol UnsuccessfulMultiParameterRenames
88 // expected-note@+1 {{has been explicitly marked deprecated here}}
89 - (void)differentNumberOfParameters:(int)param DEPRECATED("rename:hasMoreParameters:");
91 // expected-note@+1 {{has been explicitly marked deprecated here}}
92 - (void)differentNumber:(int)param1 ofParameters:(int)param2 DEPRECATED("renameHasLessParameters:");
94 // expected-note@+1 {{has been explicitly marked deprecated here}}
95 - (void)methodLike:(int)param1 replacement:(int)param2 DEPRECATED("noColon:atTheEnd");
97 // expected-note@+1 {{has been explicitly marked deprecated here}}
98 - (void)freeFormText DEPRECATED("Use something else");
100 // expected-note@+1 {{has been explicitly marked deprecated here}}
101 - (void)freeFormTextReplacementStartsAsMethod DEPRECATED("-Use something different");
103 // expected-note@+1 {{has been explicitly marked deprecated here}}
104 - (void)replacementHasSingleSkipCharacter DEPRECATED("-");
106 // expected-note@+1 {{has been explicitly marked deprecated here}}
107 - (void)replacementHasInvalid:(int)param1 slotName:(int)param2 DEPRECATED("renameWith:1nonIdentifier:");
108 @end
110 void unsuccessfulRenames(id<UnsuccessfulMultiParameterRenames> object) {
111   [object differentNumberOfParameters:0]; // expected-warning {{is deprecated}}
112   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:38}:"rename:hasMoreParameters:"
114   [object differentNumber:0 ofParameters:1]; // expected-warning {{is deprecated}}
115   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:26}:"renameHasLessParameters:"
117   [object methodLike:0 replacement:1]; // expected-warning {{is deprecated}}
118   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:21}:"noColon:atTheEnd"
120   [object freeFormText]; // expected-warning {{is deprecated}}
121   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:23}:"Use something else"
123   [object freeFormTextReplacementStartsAsMethod]; // expected-warning {{is deprecated}}
124   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:48}:"-Use something different"
126   [object replacementHasSingleSkipCharacter]; // expected-warning {{is deprecated}}
127   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:44}:"-"
129   [object replacementHasInvalid:0 slotName:1]; // expected-warning {{is deprecated}}
130   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:32}:"renameWith:1nonIdentifier:"
132 #endif // IGNORE_UNSUCCESSFUL_RENAMES
134 // Make sure classes are treated the same way as protocols.
135 __attribute__((objc_root_class))
136 @interface Interface
137 // expected-note@+1 {{has been explicitly marked deprecated here}}
138 + (void)classMethod:(int)param1 replacement:(int)param2 DEPRECATED("renameClassMethod:replace_new_ment:");
139 + (void)renameClassMethod:(int)param1 replace_new_ment:(int)param2;
141 // expected-note@+1 {{has been explicitly marked deprecated here}}
142 - (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 DEPRECATED("multi_new:parameter_new:replace_new_ment:");
143 - (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3;
144 @end
146 @implementation Interface
147 + (void)classMethod:(int)param1 replacement:(int)param2 {}
148 + (void)renameClassMethod:(int)param1 replace_new_ment:(int)param2 {}
150 - (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 {}
151 - (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3 {}
153 - (void)usage {
154   [Interface classMethod:0 replacement:1]; // expected-warning {{is deprecated}}
155   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:25}:"renameClassMethod"
156   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:28-[[@LINE-2]]:39}:"replace_new_ment"
158   [self multi:0 parameter:1 replacement:2]; // expected-warning {{is deprecated}}
159   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:14}:"multi_new"
160   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:17-[[@LINE-2]]:26}:"parameter_new"
161   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:29-[[@LINE-3]]:40}:"replace_new_ment"
163 @end
165 // Make sure availability attribute is handled the same way as deprecation attribute.
166 @protocol AvailabilityAttributeRenames
167 // expected-note@+1 {{has been explicitly marked deprecated here}}
168 - (void)multi:(int)param1 parameter:(int)param2 replacement:(int)param3 __attribute__((availability(macosx,deprecated=9.0,replacement="multi_new:parameter_new:replace_new_ment:")));
169 - (void)multi_new:(int)param1 parameter_new:(int)param2 replace_new_ment:(int)param3;
170 @end
172 void availabilityAttributeRenames(id<AvailabilityAttributeRenames> object) {
173   [object multi:0 parameter:1 replacement:2]; // expected-warning {{is deprecated}}
174   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:16}:"multi_new"
175   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:19-[[@LINE-2]]:28}:"parameter_new"
176   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:31-[[@LINE-3]]:42}:"replace_new_ment"