1 | // RUN: mkdir -p %T/used-helper-decls |
2 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
3 | // RUN: cd %T/used-helper-decls |
4 | |
5 | // ---------------------------------------------------------------------------- |
6 | // Test moving used helper function and its transitively used functions. |
7 | // ---------------------------------------------------------------------------- |
8 | // RUN: clang-move -names="a::Class1" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
9 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS1-CPP %s |
10 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS1-CPP %s |
11 | |
12 | // CHECK-NEW-CLASS1-CPP: #include "{{.*}}new_helper_decls_test.h" |
13 | // CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}} |
14 | // CHECK-NEW-CLASS1-CPP-NEXT: namespace { |
15 | // CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun1() {} |
16 | // CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}} |
17 | // CHECK-NEW-CLASS1-CPP-NEXT: void HelperFun2() { HelperFun1(); } |
18 | // CHECK-NEW-CLASS1-CPP-NEXT: } // namespace |
19 | // CHECK-NEW-CLASS1-CPP-SAME: {{[[:space:]]}} |
20 | // CHECK-NEW-CLASS1-CPP-NEXT: namespace a { |
21 | // CHECK-NEW-CLASS1-CPP-NEXT: void Class1::f() { HelperFun2(); } |
22 | // CHECK-NEW-CLASS1-CPP-NEXT: } // namespace a |
23 | // |
24 | // CHECK-OLD-CLASS1-CPP: void HelperFun1() {} |
25 | // CHECK-OLD-CLASS1-CPP-NOT: void HelperFun2() { HelperFun1(); } |
26 | // CHECK-OLD-CLASS1-CPP-NOT: void Class1::f() { HelperFun2(); } |
27 | // CHECK-OLD-CLASS1-CPP: void Class2::f() { |
28 | // CHECK-OLD-CLASS1-CPP: HelperFun1(); |
29 | |
30 | |
31 | // ---------------------------------------------------------------------------- |
32 | // Test moving used helper function and its transitively used static variables. |
33 | // ---------------------------------------------------------------------------- |
34 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
35 | // RUN: clang-move -names="a::Class2" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
36 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS2-CPP %s |
37 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS2-CPP %s |
38 | |
39 | // CHECK-NEW-CLASS2-CPP: #include "{{.*}}new_helper_decls_test.h" |
40 | // CHECK-NEW-CLASS2-CPP-SAME: {{[[:space:]]}} |
41 | // CHECK-NEW-CLASS2-CPP-NEXT: namespace { |
42 | // CHECK-NEW-CLASS2-CPP-NEXT: void HelperFun1() {} |
43 | // CHECK-NEW-CLASS2-CPP-NEXT: } // namespace |
44 | // CHECK-NEW-CLASS2-CPP-SAME: {{[[:space:]]}} |
45 | // CHECK-NEW-CLASS2-CPP-NEXT: static const int K2 = 2; |
46 | // CHECK-NEW-CLASS2-CPP-SAME: {{[[:space:]]}} |
47 | // CHECK-NEW-CLASS2-CPP-NEXT: static void HelperFun3() { K2; } |
48 | // CHECK-NEW-CLASS2-CPP-NEXT: namespace a { |
49 | // CHECK-NEW-CLASS2-CPP-NEXT: void Class2::f() { |
50 | // CHECK-NEW-CLASS2-CPP-NEXT: HelperFun1(); |
51 | // CHECK-NEW-CLASS2-CPP-NEXT: HelperFun3(); |
52 | // CHECK-NEW-CLASS2-CPP-NEXT: } |
53 | // CHECK-NEW-CLASS2-CPP-NEXT: } // namespace a |
54 | |
55 | // CHECK-OLD-CLASS2-CPP: void HelperFun1() {} |
56 | // CHECK-OLD-CLASS2-CPP: void HelperFun2() { HelperFun1(); } |
57 | // CHECK-OLD-CLASS2-CPP: const int K1 = 1; |
58 | // CHECK-OLD-CLASS2-CPP: static const int K2 = 2; |
59 | // CHECK-OLD-CLASS2-CPP-NOT: static void HelperFun3() { K2; } |
60 | // CHECK-OLD-CLASS2-CPP-NOT: void Class2::f() { |
61 | // CHECK-OLD-CLASS2-CPP-NOT: HelperFun1(); |
62 | // CHECK-OLD-CLASS2-CPP-NOT: HelperFun3(); |
63 | // CHECK-OLD-CLASS2-CPP: void Class5::f() { |
64 | // CHECK-OLD-CLASS2-CPP-NEXT: int Result = K1 + K2 + K3; |
65 | |
66 | |
67 | // ---------------------------------------------------------------------------- |
68 | // Test using a static member variable of a helper class. |
69 | // ---------------------------------------------------------------------------- |
70 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
71 | // RUN: clang-move -names="a::Class3" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
72 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS3-CPP %s |
73 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS3-CPP %s |
74 | |
75 | // CHECK-NEW-CLASS3-CPP: #include "{{.*}}new_helper_decls_test.h" |
76 | // CHECK-NEW-CLASS3-CPP-SAME: {{[[:space:]]}} |
77 | // CHECK-NEW-CLASS3-CPP-NEXT: namespace { |
78 | // CHECK-NEW-CLASS3-CPP-NEXT: class HelperC1 { |
79 | // CHECK-NEW-CLASS3-CPP-NEXT: public: |
80 | // CHECK-NEW-CLASS3-CPP-NEXT: static int I; |
81 | // CHECK-NEW-CLASS3-CPP-NEXT: }; |
82 | // CHECK-NEW-CLASS3-CPP-SAME: {{[[:space:]]}} |
83 | // CHECK-NEW-CLASS3-CPP-NEXT: int HelperC1::I = 0; |
84 | // CHECK-NEW-CLASS3-CPP-NEXT: } // namespace |
85 | // CHECK-NEW-CLASS3-CPP-SAME: {{[[:space:]]}} |
86 | // CHECK-NEW-CLASS3-CPP-NEXT: namespace a { |
87 | // CHECK-NEW-CLASS3-CPP-NEXT: void Class3::f() { HelperC1::I; } |
88 | // CHECK-NEW-CLASS3-CPP-NEXT: } // namespace a |
89 | |
90 | // CHECK-OLD-CLASS3-CPP: namespace { |
91 | // CHECK-OLD-CLASS3-CPP-NOT: class HelperC1 { |
92 | // CHECK-OLD-CLASS3-CPP-NOT: public: |
93 | // CHECK-OLD-CLASS3-CPP-NOT: static int I; |
94 | // CHECK-OLD-CLASS3-CPP-NOT: }; |
95 | // CHECK-OLD-CLASS3-CPP-NOT: int HelperC1::I = 0; |
96 | // CHECK-OLD-CLASS3-CPP: class HelperC2 {}; |
97 | |
98 | |
99 | // ---------------------------------------------------------------------------- |
100 | // Test moving helper classes. |
101 | // ---------------------------------------------------------------------------- |
102 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
103 | // RUN: clang-move -names="a::Class4" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
104 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS4-CPP %s |
105 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS4-CPP %s |
106 | |
107 | // CHECK-NEW-CLASS4-CPP: #include "{{.*}}new_helper_decls_test.h" |
108 | // CHECK-NEW-CLASS4-CPP-SAME: {{[[:space:]]}} |
109 | // CHECK-NEW-CLASS4-CPP-NEXT: namespace { |
110 | // CHECK-NEW-CLASS4-CPP-NEXT: class HelperC2 {}; |
111 | // CHECK-NEW-CLASS4-CPP-NEXT: } // namespace |
112 | // CHECK-NEW-CLASS4-CPP-SAME: {{[[:space:]]}} |
113 | // CHECK-NEW-CLASS4-CPP-NEXT: namespace a { |
114 | // CHECK-NEW-CLASS4-CPP-NEXT: void Class4::f() { HelperC2 c2; } |
115 | // CHECK-NEW-CLASS4-CPP-NEXT: } // namespace a |
116 | |
117 | // CHECK-OLD-CLASS4-CPP-NOT: class HelperC2 {}; |
118 | |
119 | |
120 | // ---------------------------------------------------------------------------- |
121 | // Test moving helper variables and helper functions together. |
122 | // ---------------------------------------------------------------------------- |
123 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
124 | // RUN: clang-move -names="a::Class5" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
125 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS5-CPP %s |
126 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS5-CPP %s |
127 | |
128 | // CHECK-NEW-CLASS5-CPP: #include "{{.*}}new_helper_decls_test.h" |
129 | // CHECK-NEW-CLASS5-CPP-SAME: {{[[:space:]]}} |
130 | // CHECK-NEW-CLASS5-CPP-NEXT: namespace { |
131 | // CHECK-NEW-CLASS5-CPP-NEXT: const int K1 = 1; |
132 | // CHECK-NEW-CLASS5-CPP-NEXT: } // namespace |
133 | // CHECK-NEW-CLASS5-CPP-SAME: {{[[:space:]]}} |
134 | // CHECK-NEW-CLASS5-CPP-NEXT: static const int K2 = 2; |
135 | // CHECK-NEW-CLASS5-CPP-NEXT: namespace a { |
136 | // CHECK-NEW-CLASS5-CPP-NEXT: static const int K3 = 3; |
137 | // CHECK-NEW-CLASS5-CPP-SAME: {{[[:space:]]}} |
138 | // CHECK-NEW-CLASS5-CPP-NEXT: static void HelperFun4() {} |
139 | // CHECK-NEW-CLASS5-CPP-SAME: {{[[:space:]]}} |
140 | // CHECK-NEW-CLASS5-CPP-NEXT: void Class5::f() { |
141 | // CHECK-NEW-CLASS5-CPP-NEXT: int Result = K1 + K2 + K3; |
142 | // CHECK-NEW-CLASS5-CPP-NEXT: HelperFun4(); |
143 | // CHECK-NEW-CLASS5-CPP-NEXT: } |
144 | // CHECK-NEW-CLASS5-CPP-NEXT: } // namespace a |
145 | |
146 | // CHECK-OLD-CLASS5-CPP-NOT: const int K1 = 1; |
147 | // CHECK-OLD-CLASS5-CPP: static const int K2 = 2; |
148 | // CHECK-OLD-CLASS5-CPP: static void HelperFun3() { K2; } |
149 | // CHECK-OLD-CLASS5-CPP: static const int K4 = HelperC3::I; |
150 | // CHECK-OLD-CLASS5-CPP-NOT: void Class5::f() { |
151 | |
152 | |
153 | // ---------------------------------------------------------------------------- |
154 | // Test moving helper variables and their transitively used helper classes. |
155 | // ---------------------------------------------------------------------------- |
156 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
157 | // RUN: clang-move -names="a::Class6" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
158 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS6-CPP %s |
159 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS6-CPP %s |
160 | |
161 | // CHECK-NEW-CLASS6-CPP: #include "{{.*}}new_helper_decls_test.h" |
162 | // CHECK-NEW-CLASS6-CPP-SAME: {{[[:space:]]}} |
163 | // CHECK-NEW-CLASS6-CPP-NEXT: namespace { |
164 | // CHECK-NEW-CLASS6-CPP-NEXT: class HelperC3 { |
165 | // CHECK-NEW-CLASS6-CPP-NEXT: public: |
166 | // CHECK-NEW-CLASS6-CPP-NEXT: static int I; |
167 | // CHECK-NEW-CLASS6-CPP-NEXT: }; |
168 | // CHECK-NEW-CLASS6-CPP-SAME: {{[[:space:]]}} |
169 | // CHECK-NEW-CLASS6-CPP-NEXT: int HelperC3::I = 0; |
170 | // CHECK-NEW-CLASS6-CPP-NEXT: } // namespace |
171 | // CHECK-NEW-CLASS6-CPP-SAME: {{[[:space:]]}} |
172 | // CHECK-NEW-CLASS6-CPP-NEXT: namespace a { |
173 | // CHECK-NEW-CLASS6-CPP-NEXT: static const int K4 = HelperC3::I; |
174 | // CHECK-NEW-CLASS6-CPP-SAME: {{[[:space:]]}} |
175 | // CHECK-NEW-CLASS6-CPP-NEXT: int Class6::f() { |
176 | // CHECK-NEW-CLASS6-CPP-NEXT: int R = K4; |
177 | // CHECK-NEW-CLASS6-CPP-NEXT: return R; |
178 | // CHECK-NEW-CLASS6-CPP-NEXT: } |
179 | // CHECK-NEW-CLASS6-CPP-NEXT: } // namespace a |
180 | |
181 | // CHECK-OLD-CLASS6-CPP-NOT: class HelperC3 { |
182 | // CHECK-OLD-CLASS6-CPP-NOT: int HelperC3::I = 0; |
183 | // CHECK-OLD-CLASS6-CPP-NOT: static const int K4 = HelperC3::I; |
184 | |
185 | |
186 | // ---------------------------------------------------------------------------- |
187 | // Test moving classes where its methods use helpers. |
188 | // ---------------------------------------------------------------------------- |
189 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
190 | // RUN: clang-move -names="a::Class7" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
191 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CLASS7-CPP %s |
192 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-CLASS7-CPP %s |
193 | |
194 | // CHECK-NEW-CLASS7-CPP: #include "{{.*}}new_helper_decls_test.h" |
195 | // CHECK-NEW-CLASS7-CPP-SAME: {{[[:space:]]}} |
196 | // CHECK-NEW-CLASS7-CPP-NEXT: namespace a { |
197 | // CHECK-NEW-CLASS7-CPP-NEXT: static const int K6 = 6; |
198 | // CHECK-NEW-CLASS7-CPP-SAME: {{[[:space:]]}} |
199 | // CHECK-NEW-CLASS7-CPP-NEXT: static void HelperFun6() {} |
200 | // CHECK-NEW-CLASS7-CPP-SAME: {{[[:space:]]}} |
201 | // CHECK-NEW-CLASS7-CPP-NEXT: int Class7::f() { |
202 | // CHECK-NEW-CLASS7-CPP-NEXT: int R = K6; |
203 | // CHECK-NEW-CLASS7-CPP-NEXT: return R; |
204 | // CHECK-NEW-CLASS7-CPP-NEXT: } |
205 | // CHECK-NEW-CLASS7-CPP-SAME: {{[[:space:]]}} |
206 | // CHECK-NEW-CLASS7-CPP-NEXT: int Class7::g() { |
207 | // CHECK-NEW-CLASS7-CPP-NEXT: HelperFun6(); |
208 | // CHECK-NEW-CLASS7-CPP-NEXT: return 1; |
209 | // CHECK-NEW-CLASS7-CPP-NEXT: } |
210 | // CHECK-NEW-CLASS7-CPP-NEXT: } // namespace a |
211 | // |
212 | // CHECK-OLD-CLASS7-CPP-NOT: static const int K6 = 6; |
213 | // CHECK-OLD-CLASS7-CPP-NOT: static void HelperFun6() {} |
214 | // CHECK-OLD-CLASS7-CPP-NOT: int Class7::f() { |
215 | // CHECK-OLD-CLASS7-CPP-NOT: int Class7::g() { |
216 | |
217 | |
218 | // ---------------------------------------------------------------------------- |
219 | // Test moving helper function and its transitively used helper variables. |
220 | // ---------------------------------------------------------------------------- |
221 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
222 | // RUN: clang-move -names="a::Fun1" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
223 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-FUN1-CPP %s |
224 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-FUN1-CPP %s |
225 | |
226 | // CHECK-NEW-FUN1-CPP: #include "{{.*}}new_helper_decls_test.h" |
227 | // CHECK-NEW-FUN1-CPP-SAME: {{[[:space:]]}} |
228 | // CHECK-NEW-FUN1-CPP-NEXT: namespace a { |
229 | // CHECK-NEW-FUN1-CPP-NEXT: static const int K5 = 5; |
230 | // CHECK-NEW-FUN1-CPP-SAME: {{[[:space:]]}} |
231 | // CHECK-NEW-FUN1-CPP-NEXT: static int HelperFun5() { |
232 | // CHECK-NEW-FUN1-CPP-NEXT: int R = K5; |
233 | // CHECK-NEW-FUN1-CPP-NEXT: return R; |
234 | // CHECK-NEW-FUN1-CPP-NEXT: } |
235 | // CHECK-NEW-FUN1-CPP-SAME: {{[[:space:]]}} |
236 | // CHECK-NEW-FUN1-CPP-NEXT: void Fun1() { HelperFun5(); } |
237 | // CHECK-NEW-FUN1-CPP-NEXT: } // namespace a |
238 | |
239 | // CHECK-OLD-FUN1-CPP-NOT: static const int K5 = 5; |
240 | // CHECK-OLD-FUN1-CPP-NOT: static int HelperFun5() { |
241 | // CHECK-OLD-FUN1-CPP-NOT: void Fun1() { HelperFun5(); } |
242 | |
243 | |
244 | // ---------------------------------------------------------------------------- |
245 | // Test no moving helpers when moving inline functions in header. |
246 | // ---------------------------------------------------------------------------- |
247 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
248 | // RUN: clang-move -names="a::Fun2" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
249 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-FUN2-CPP %s |
250 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.h -check-prefix=CHECK-NEW-FUN2-H %s |
251 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.h -check-prefix=CHECK-OLD-FUN2-H %s |
252 | |
253 | // CHECK-NEW-FUN2-H: namespace a { |
254 | // CHECK-NEW-FUN2-H-NEXT: inline void Fun2() {} |
255 | // CHECK-NEW-FUN2-H-NEXT: } // namespace a |
256 | |
257 | // CHECK-NEW-FUN2-CPP: #include "{{.*}}new_helper_decls_test.h" |
258 | // CHECK-NEW-FUN2-CPP-SAME: {{[[:space:]]}} |
259 | |
260 | // CHECK-OLD-FUN2-H-NOT: inline void Fun2() {} |
261 | |
262 | // ---------------------------------------------------------------------------- |
263 | // Test moving used helper function and its transitively used functions. |
264 | // ---------------------------------------------------------------------------- |
265 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
266 | // RUN: clang-move -names="b::Fun3" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
267 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-FUN3-CPP %s |
268 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -check-prefix=CHECK-OLD-FUN3-CPP %s |
269 | |
270 | // CHECK-NEW-FUN3-CPP: #include "{{.*}}new_helper_decls_test.h" |
271 | // CHECK-NEW-FUN3-CPP-SAME: {{[[:space:]]}} |
272 | // CHECK-NEW-FUN3-CPP-NEXT: namespace b { |
273 | // CHECK-NEW-FUN3-CPP-NEXT: namespace { |
274 | // CHECK-NEW-FUN3-CPP-NEXT: void HelperFun7(); |
275 | // CHECK-NEW-FUN3-CPP-SAME: {{[[:space:]]}} |
276 | // CHECK-NEW-FUN3-CPP-NEXT: class HelperC4; |
277 | // CHECK-NEW-FUN3-CPP-NEXT: } // namespace |
278 | // CHECK-NEW-FUN3-CPP-SAME: {{[[:space:]]}} |
279 | // CHECK-NEW-FUN3-CPP-NEXT: void Fun3() { |
280 | // CHECK-NEW-FUN3-CPP-NEXT: HelperFun7(); |
281 | // CHECK-NEW-FUN3-CPP-NEXT: HelperC4 *t; |
282 | // CHECK-NEW-FUN3-CPP-NEXT: } |
283 | // CHECK-NEW-FUN3-CPP-NEXT: namespace { |
284 | // CHECK-NEW-FUN3-CPP-NEXT: void HelperFun7() {} |
285 | // CHECK-NEW-FUN3-CPP-SAME: {{[[:space:]]}} |
286 | // CHECK-NEW-FUN3-CPP-NEXT: class HelperC4 {}; |
287 | // CHECK-NEW-FUN3-CPP-NEXT: } // namespace |
288 | // CHECK-NEW-FUN3-CPP-NEXT: } // namespace b |
289 | // |
290 | // CHECK-OLD-FUN3-CPP-NOT: void HelperFun7(); |
291 | // CHECK-OLD-FUN3-CPP-NOT: void HelperFun7() {} |
292 | // CHECK-OLD-FUN3-CPP-NOT: void Fun3() { HelperFun7(); } |
293 | |
294 | // ---------------------------------------------------------------------------- |
295 | // Test moving all symbols in headers. |
296 | // ---------------------------------------------------------------------------- |
297 | // RUN: cp %S/Inputs/helper_decls_test* %T/used-helper-decls/ |
298 | // RUN: clang-move -names="a::Class1, a::Class2, a::Class3, a::Class4, a::Class5, a::Class5, a::Class6, a::Class7, a::Fun1, a::Fun2, b::Fun3" -new_cc=%T/used-helper-decls/new_helper_decls_test.cpp -new_header=%T/used-helper-decls/new_helper_decls_test.h -old_cc=%T/used-helper-decls/helper_decls_test.cpp -old_header=../used-helper-decls/helper_decls_test.h %T/used-helper-decls/helper_decls_test.cpp -- -std=c++11 |
299 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.h -check-prefix=CHECK-NEW-H %s |
300 | // RUN: FileCheck -input-file=%T/used-helper-decls/new_helper_decls_test.cpp -check-prefix=CHECK-NEW-CPP %s |
301 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.h -allow-empty -check-prefix=CHECK-EMPTY %s |
302 | // RUN: FileCheck -input-file=%T/used-helper-decls/helper_decls_test.cpp -allow-empty -check-prefix=CHECK-EMPTY %s |
303 | |
304 | |
305 | // CHECK-NEW-H: namespace a { |
306 | // CHECK-NEW-H-NEXT: class Class1 { |
307 | // CHECK-NEW-H-NEXT: void f(); |
308 | // CHECK-NEW-H-NEXT: }; |
309 | // CHECK-NEW-H-SAME: {{[[:space:]]}} |
310 | // CHECK-NEW-H-NEXT: class Class2 { |
311 | // CHECK-NEW-H-NEXT: void f(); |
312 | // CHECK-NEW-H-NEXT: }; |
313 | // CHECK-NEW-H-SAME: {{[[:space:]]}} |
314 | // CHECK-NEW-H-NEXT: class Class3 { |
315 | // CHECK-NEW-H-NEXT: void f(); |
316 | // CHECK-NEW-H-NEXT: }; |
317 | // CHECK-NEW-H-SAME: {{[[:space:]]}} |
318 | // CHECK-NEW-H-NEXT: class Class4 { |
319 | // CHECK-NEW-H-NEXT: void f(); |
320 | // CHECK-NEW-H-NEXT: }; |
321 | // CHECK-NEW-H-SAME: {{[[:space:]]}} |
322 | // CHECK-NEW-H-NEXT: class Class5 { |
323 | // CHECK-NEW-H-NEXT: void f(); |
324 | // CHECK-NEW-H-NEXT: }; |
325 | // CHECK-NEW-H-SAME: {{[[:space:]]}} |
326 | // CHECK-NEW-H-NEXT: class Class6 { |
327 | // CHECK-NEW-H-NEXT: int f(); |
328 | // CHECK-NEW-H-NEXT: }; |
329 | // CHECK-NEW-H-SAME: {{[[:space:]]}} |
330 | // CHECK-NEW-H-NEXT: class Class7 { |
331 | // CHECK-NEW-H-NEXT: int f(); |
332 | // CHECK-NEW-H-NEXT: int g(); |
333 | // CHECK-NEW-H-NEXT: }; |
334 | // CHECK-NEW-H-SAME: {{[[:space:]]}} |
335 | // CHECK-NEW-H-NEXT: void Fun1(); |
336 | // CHECK-NEW-H-SAME: {{[[:space:]]}} |
337 | // CHECK-NEW-H-NEXT: inline void Fun2() {} |
338 | // CHECK-NEW-H-SAME: {{[[:space:]]}} |
339 | // CHECK-NEW-H-NEXT: } // namespace a |
340 | |
341 | |
342 | // CHECK-NEW-CPP: namespace { |
343 | // CHECK-NEW-CPP-NEXT: class HelperC1 { |
344 | // CHECK-NEW-CPP-NEXT: public: |
345 | // CHECK-NEW-CPP-NEXT: static int I; |
346 | // CHECK-NEW-CPP-NEXT: }; |
347 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
348 | // CHECK-NEW-CPP-NEXT: int HelperC1::I = 0; |
349 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
350 | // CHECK-NEW-CPP-NEXT: class HelperC2 {}; |
351 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
352 | // CHECK-NEW-CPP-NEXT: class HelperC3 { |
353 | // CHECK-NEW-CPP-NEXT: public: |
354 | // CHECK-NEW-CPP-NEXT: static int I; |
355 | // CHECK-NEW-CPP-NEXT: }; |
356 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
357 | // CHECK-NEW-CPP-NEXT: int HelperC3::I = 0; |
358 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
359 | // CHECK-NEW-CPP-NEXT: void HelperFun1() {} |
360 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
361 | // CHECK-NEW-CPP-NEXT: void HelperFun2() { HelperFun1(); } |
362 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
363 | // CHECK-NEW-CPP-NEXT: const int K1 = 1; |
364 | // CHECK-NEW-CPP-NEXT: } // namespace |
365 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
366 | // CHECK-NEW-CPP-NEXT: static const int K2 = 2; |
367 | // CHECK-NEW-CPP-NEXT: static void HelperFun3() { K2; } |
368 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
369 | // CHECK-NEW-CPP-NEXT: namespace a { |
370 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
371 | // CHECK-NEW-CPP-NEXT: static const int K3 = 3; |
372 | // CHECK-NEW-CPP-NEXT: static const int K4 = HelperC3::I; |
373 | // CHECK-NEW-CPP-NEXT: static const int K5 = 5; |
374 | // CHECK-NEW-CPP-NEXT: static const int K6 = 6; |
375 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
376 | // CHECK-NEW-CPP-NEXT: static void HelperFun4() {} |
377 | // CHECK-NEW-CPP-NEXT: static void HelperFun6() {} |
378 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
379 | // CHECK-NEW-CPP-NEXT: void Class1::f() { HelperFun2(); } |
380 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
381 | // CHECK-NEW-CPP-NEXT: void Class2::f() { |
382 | // CHECK-NEW-CPP-NEXT: HelperFun1(); |
383 | // CHECK-NEW-CPP-NEXT: HelperFun3(); |
384 | // CHECK-NEW-CPP-NEXT: } |
385 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
386 | // CHECK-NEW-CPP-NEXT: void Class3::f() { HelperC1::I; } |
387 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
388 | // CHECK-NEW-CPP-NEXT: void Class4::f() { HelperC2 c2; } |
389 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
390 | // CHECK-NEW-CPP-NEXT: void Class5::f() { |
391 | // CHECK-NEW-CPP-NEXT: int Result = K1 + K2 + K3; |
392 | // CHECK-NEW-CPP-NEXT: HelperFun4(); |
393 | // CHECK-NEW-CPP-NEXT: } |
394 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
395 | // CHECK-NEW-CPP-NEXT: int Class6::f() { |
396 | // CHECK-NEW-CPP-NEXT: int R = K4; |
397 | // CHECK-NEW-CPP-NEXT: return R; |
398 | // CHECK-NEW-CPP-NEXT: } |
399 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
400 | // CHECK-NEW-CPP-NEXT: int Class7::f() { |
401 | // CHECK-NEW-CPP-NEXT: int R = K6; |
402 | // CHECK-NEW-CPP-NEXT: return R; |
403 | // CHECK-NEW-CPP-NEXT: } |
404 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
405 | // CHECK-NEW-CPP-NEXT: int Class7::g() { |
406 | // CHECK-NEW-CPP-NEXT: HelperFun6(); |
407 | // CHECK-NEW-CPP-NEXT: return 1; |
408 | // CHECK-NEW-CPP-NEXT: } |
409 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
410 | // CHECK-NEW-CPP-NEXT: static int HelperFun5() { |
411 | // CHECK-NEW-CPP-NEXT: int R = K5; |
412 | // CHECK-NEW-CPP-NEXT: return R; |
413 | // CHECK-NEW-CPP-NEXT: } |
414 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
415 | // CHECK-NEW-CPP-NEXT: void Fun1() { HelperFun5(); } |
416 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
417 | // CHECK-NEW-CPP-NEXT: } // namespace a |
418 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
419 | // CHECK-NEW-CPP-NEXT: namespace b { |
420 | // CHECK-NEW-CPP-NEXT: namespace { |
421 | // CHECK-NEW-CPP-NEXT: void HelperFun7(); |
422 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
423 | // CHECK-NEW-CPP-NEXT: class HelperC4; |
424 | // CHECK-NEW-CPP-NEXT: } // namespace |
425 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
426 | // CHECK-NEW-CPP-NEXT: void Fun3() { |
427 | // CHECK-NEW-CPP-NEXT: HelperFun7(); |
428 | // CHECK-NEW-CPP-NEXT: HelperC4 *t; |
429 | // CHECK-NEW-CPP-NEXT: } |
430 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
431 | // CHECK-NEW-CPP-NEXT: namespace { |
432 | // CHECK-NEW-CPP-NEXT: void HelperFun7() {} |
433 | // CHECK-NEW-CPP-SAME: {{[[:space:]]}} |
434 | // CHECK-NEW-CPP-NEXT: class HelperC4 {}; |
435 | // CHECK-NEW-CPP-NEXT: } // namespace |
436 | // CHECK-NEW-CPP-NEXT: } // namespace b |
437 | |
438 | // CHECK-EMPTY: {{^}}{{$}} |
439 | |