1 | // RUN: %check_clang_tidy %s bugprone-stringview-nullptr -std=c++17 %t |
2 | |
3 | namespace std { |
4 | |
5 | using size_t = long long; |
6 | using nullptr_t = decltype(nullptr); |
7 | |
8 | template <typename T> |
9 | T &&declval(); |
10 | |
11 | template <typename T> |
12 | struct type_identity { using type = T; }; |
13 | template <typename T> |
14 | using type_identity_t = typename type_identity<T>::type; |
15 | |
16 | template <typename CharT> |
17 | class basic_string_view { |
18 | public: |
19 | constexpr basic_string_view() {} |
20 | |
21 | constexpr basic_string_view(const CharT *) {} |
22 | |
23 | // Not present in C++17 and C++20: |
24 | // constexpr basic_string_view(std::nullptr_t) {} |
25 | |
26 | constexpr basic_string_view(const CharT *, size_t) {} |
27 | |
28 | constexpr basic_string_view(const basic_string_view &) {} |
29 | |
30 | constexpr basic_string_view &operator=(const basic_string_view &) {} |
31 | }; |
32 | |
33 | template <typename CharT> |
34 | constexpr bool operator<(basic_string_view<CharT>, basic_string_view<CharT>) { |
35 | return {}; |
36 | } |
37 | template <typename CharT> |
38 | constexpr bool operator<(type_identity_t<basic_string_view<CharT>>, |
39 | basic_string_view<CharT>) { |
40 | return {}; |
41 | } |
42 | template <typename CharT> |
43 | constexpr bool operator<(basic_string_view<CharT>, |
44 | type_identity_t<basic_string_view<CharT>>) { |
45 | return {}; |
46 | } |
47 | |
48 | template <typename CharT> |
49 | constexpr bool operator<=(basic_string_view<CharT>, basic_string_view<CharT>) { |
50 | return {}; |
51 | } |
52 | template <typename CharT> |
53 | constexpr bool operator<=(type_identity_t<basic_string_view<CharT>>, |
54 | basic_string_view<CharT>) { |
55 | return {}; |
56 | } |
57 | template <typename CharT> |
58 | constexpr bool operator<=(basic_string_view<CharT>, |
59 | type_identity_t<basic_string_view<CharT>>) { |
60 | return {}; |
61 | } |
62 | |
63 | template <typename CharT> |
64 | constexpr bool operator>(basic_string_view<CharT>, basic_string_view<CharT>) { |
65 | return {}; |
66 | } |
67 | template <typename CharT> |
68 | constexpr bool operator>(type_identity_t<basic_string_view<CharT>>, |
69 | basic_string_view<CharT>) { |
70 | return {}; |
71 | } |
72 | template <typename CharT> |
73 | constexpr bool operator>(basic_string_view<CharT>, |
74 | type_identity_t<basic_string_view<CharT>>) { |
75 | return {}; |
76 | } |
77 | |
78 | template <typename CharT> |
79 | constexpr bool operator>=(basic_string_view<CharT>, basic_string_view<CharT>) { |
80 | return {}; |
81 | } |
82 | template <typename CharT> |
83 | constexpr bool operator>=(type_identity_t<basic_string_view<CharT>>, |
84 | basic_string_view<CharT>) { |
85 | return {}; |
86 | } |
87 | template <typename CharT> |
88 | constexpr bool operator>=(basic_string_view<CharT>, |
89 | type_identity_t<basic_string_view<CharT>>) { |
90 | return {}; |
91 | } |
92 | |
93 | template <typename CharT> |
94 | constexpr bool operator==(basic_string_view<CharT>, basic_string_view<CharT>) { |
95 | return {}; |
96 | } |
97 | template <typename CharT> |
98 | constexpr bool operator==(type_identity_t<basic_string_view<CharT>>, |
99 | basic_string_view<CharT>) { |
100 | return {}; |
101 | } |
102 | template <typename CharT> |
103 | constexpr bool operator==(basic_string_view<CharT>, |
104 | type_identity_t<basic_string_view<CharT>>) { |
105 | return {}; |
106 | } |
107 | |
108 | template <typename CharT> |
109 | constexpr bool operator!=(basic_string_view<CharT>, basic_string_view<CharT>) { |
110 | return {}; |
111 | } |
112 | template <typename CharT> |
113 | constexpr bool operator!=(type_identity_t<basic_string_view<CharT>>, |
114 | basic_string_view<CharT>) { |
115 | return {}; |
116 | } |
117 | template <typename CharT> |
118 | constexpr bool operator!=(basic_string_view<CharT>, |
119 | type_identity_t<basic_string_view<CharT>>) { |
120 | return {}; |
121 | } |
122 | |
123 | using string_view = basic_string_view<char>; |
124 | |
125 | } // namespace std |
126 | |
127 | using SV = std::string_view; // Used in some places for shorter line length |
128 | |
129 | void function(std::string_view); |
130 | void function(std::string_view, std::string_view); |
131 | |
132 | void temporary_construction() /* a */ { |
133 | // Functional Cast |
134 | { |
135 | (void)(std::string_view(nullptr)) /* a1 */; |
136 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing basic_string_view from null is undefined; replace with the default constructor |
137 | // CHECK-FIXES: {{^}} (void)(std::string_view()) /* a1 */; |
138 | |
139 | (void)(std::string_view((nullptr))) /* a2 */; |
140 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
141 | // CHECK-FIXES: {{^}} (void)(std::string_view()) /* a2 */; |
142 | |
143 | (void)(std::string_view({nullptr})) /* a3 */; |
144 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
145 | // CHECK-FIXES: {{^}} (void)(std::string_view()) /* a3 */; |
146 | |
147 | (void)(std::string_view({(nullptr)})) /* a4 */; |
148 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
149 | // CHECK-FIXES: {{^}} (void)(std::string_view()) /* a4 */; |
150 | |
151 | (void)(std::string_view({})) /* a5 */; // Default `const CharT*` |
152 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
153 | // CHECK-FIXES: {{^}} (void)(std::string_view()) /* a5 */; |
154 | } |
155 | |
156 | // Temporary Object |
157 | { |
158 | (void)(std::string_view{nullptr}) /* a6 */; |
159 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
160 | // CHECK-FIXES: {{^}} (void)(std::string_view{}) /* a6 */; |
161 | |
162 | (void)(std::string_view{(nullptr)}) /* a7 */; |
163 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
164 | // CHECK-FIXES: {{^}} (void)(std::string_view{}) /* a7 */; |
165 | |
166 | (void)(std::string_view{{nullptr}}) /* a8 */; |
167 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
168 | // CHECK-FIXES: {{^}} (void)(std::string_view{}) /* a8 */; |
169 | |
170 | (void)(std::string_view{{(nullptr)}}) /* a9 */; |
171 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
172 | // CHECK-FIXES: {{^}} (void)(std::string_view{}) /* a9 */; |
173 | |
174 | (void)(std::string_view{{}}) /* a10 */; // Default `const CharT*` |
175 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
176 | // CHECK-FIXES: {{^}} (void)(std::string_view{}) /* a10 */; |
177 | } |
178 | |
179 | // C-Style Cast && Compound Literal |
180 | { |
181 | (void)((std::string_view) nullptr) /* a11 */; |
182 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default |
183 | // CHECK-FIXES: {{^}} (void)((std::string_view) {}) /* a11 */; |
184 | |
185 | (void)((std::string_view)(nullptr)) /* a12 */; |
186 | // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: constructing{{.*}}default |
187 | // CHECK-FIXES: {{^}} (void)((std::string_view){}) /* a12 */; |
188 | |
189 | (void)((std::string_view){nullptr}) /* a13 */; |
190 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default |
191 | // CHECK-FIXES: {{^}} (void)((std::string_view){}) /* a13 */; |
192 | |
193 | (void)((std::string_view){(nullptr)}) /* a14 */; |
194 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default |
195 | // CHECK-FIXES: {{^}} (void)((std::string_view){}) /* a14 */; |
196 | |
197 | (void)((std::string_view){{nullptr}}) /* a15 */; |
198 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default |
199 | // CHECK-FIXES: {{^}} (void)((std::string_view){}) /* a15 */; |
200 | |
201 | (void)((std::string_view){{(nullptr)}}) /* a16 */; |
202 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default |
203 | // CHECK-FIXES: {{^}} (void)((std::string_view){}) /* a16 */; |
204 | |
205 | (void)((std::string_view){{}}) /* a17 */; // Default `const CharT*` |
206 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default |
207 | // CHECK-FIXES: {{^}} (void)((std::string_view){}) /* a17 */; |
208 | |
209 | (void)((const std::string_view) nullptr) /* a18 */; |
210 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
211 | // CHECK-FIXES: {{^}} (void)((const std::string_view) {}) /* a18 */; |
212 | |
213 | (void)((const std::string_view)(nullptr)) /* a19 */; |
214 | // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: constructing{{.*}}default |
215 | // CHECK-FIXES: {{^}} (void)((const std::string_view){}) /* a19 */; |
216 | |
217 | (void)((const std::string_view){nullptr}) /* a20 */; |
218 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
219 | // CHECK-FIXES: {{^}} (void)((const std::string_view){}) /* a20 */; |
220 | |
221 | (void)((const std::string_view){(nullptr)}) /* a21 */; |
222 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
223 | // CHECK-FIXES: {{^}} (void)((const std::string_view){}) /* a21 */; |
224 | |
225 | (void)((const std::string_view){{nullptr}}) /* a22 */; |
226 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
227 | // CHECK-FIXES: {{^}} (void)((const std::string_view){}) /* a22 */; |
228 | |
229 | (void)((const std::string_view){{(nullptr)}}) /* a23 */; |
230 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
231 | // CHECK-FIXES: {{^}} (void)((const std::string_view){}) /* a23 */; |
232 | |
233 | (void)((const std::string_view){{}}) /* a24 */; // Default `const CharT*` |
234 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
235 | // CHECK-FIXES: {{^}} (void)((const std::string_view){}) /* a24 */; |
236 | } |
237 | |
238 | // Static Cast |
239 | { |
240 | (void)(static_cast<std::string_view>(nullptr)) /* a25 */; |
241 | // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting to basic_string_view from null is undefined; replace with the empty string |
242 | // CHECK-FIXES: {{^}} (void)(static_cast<std::string_view>("")) /* a25 */; |
243 | |
244 | (void)(static_cast<std::string_view>((nullptr))) /* a26 */; |
245 | // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting{{.*}}empty string |
246 | // CHECK-FIXES: {{^}} (void)(static_cast<std::string_view>("")) /* a26 */; |
247 | |
248 | (void)(static_cast<const std::string_view>(nullptr)) /* a27 */; |
249 | // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: casting{{.*}}empty string |
250 | // CHECK-FIXES: {{^}} (void)(static_cast<const std::string_view>("")) /* a27 */; |
251 | |
252 | (void)(static_cast<const std::string_view>((nullptr))) /* a28 */; |
253 | // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: casting{{.*}}empty string |
254 | // CHECK-FIXES: {{^}} (void)(static_cast<const std::string_view>("")) /* a28 */; |
255 | } |
256 | } |
257 | |
258 | void stack_construction() /* b */ { |
259 | // Copy Initialization |
260 | { |
261 | std::string_view b1 = nullptr; |
262 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default |
263 | // CHECK-FIXES: {{^}} std::string_view b1 = {}; |
264 | |
265 | std::string_view b2 = (nullptr); |
266 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default |
267 | // CHECK-FIXES: {{^}} std::string_view b2 = {}; |
268 | |
269 | const std::string_view b3 = nullptr; |
270 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
271 | // CHECK-FIXES: {{^}} const std::string_view b3 = {}; |
272 | |
273 | const std::string_view b4 = (nullptr); |
274 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
275 | // CHECK-FIXES: {{^}} const std::string_view b4 = {}; |
276 | } |
277 | |
278 | // Copy Initialization With Temporary |
279 | { |
280 | std::string_view b5 = std::string_view(nullptr); |
281 | // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default |
282 | // CHECK-FIXES: {{^}} std::string_view b5 = std::string_view(); |
283 | |
284 | std::string_view b6 = std::string_view{nullptr}; |
285 | // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default |
286 | // CHECK-FIXES: {{^}} std::string_view b6 = std::string_view{}; |
287 | |
288 | std::string_view b7 = (std::string_view) nullptr; |
289 | // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default |
290 | // CHECK-FIXES: {{^}} std::string_view b7 = (std::string_view) {}; |
291 | |
292 | std::string_view b8 = (std::string_view){nullptr}; |
293 | // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default |
294 | // CHECK-FIXES: {{^}} std::string_view b8 = (std::string_view){}; |
295 | |
296 | std::string_view b9 = static_cast<SV>(nullptr); |
297 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: casting{{.*}}empty string |
298 | // CHECK-FIXES: {{^}} std::string_view b9 = static_cast<SV>(""); |
299 | } |
300 | |
301 | // Copy List Initialization |
302 | { |
303 | std::string_view b10 = {nullptr}; |
304 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
305 | // CHECK-FIXES: {{^}} std::string_view b10 = {}; |
306 | |
307 | std::string_view b11 = {(nullptr)}; |
308 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
309 | // CHECK-FIXES: {{^}} std::string_view b11 = {}; |
310 | |
311 | std::string_view b12 = {{nullptr}}; |
312 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
313 | // CHECK-FIXES: {{^}} std::string_view b12 = {}; |
314 | |
315 | std::string_view b13 = {{(nullptr)}}; |
316 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
317 | // CHECK-FIXES: {{^}} std::string_view b13 = {}; |
318 | |
319 | std::string_view b14 = {{}}; // Default `const CharT*` |
320 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
321 | // CHECK-FIXES: {{^}} std::string_view b14 = {}; |
322 | |
323 | const std::string_view b15 = {nullptr}; |
324 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
325 | // CHECK-FIXES: {{^}} const std::string_view b15 = {}; |
326 | |
327 | const std::string_view b16 = {(nullptr)}; |
328 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
329 | // CHECK-FIXES: {{^}} const std::string_view b16 = {}; |
330 | |
331 | const std::string_view b17 = {{nullptr}}; |
332 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
333 | // CHECK-FIXES: {{^}} const std::string_view b17 = {}; |
334 | |
335 | const std::string_view b18 = {{(nullptr)}}; |
336 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
337 | // CHECK-FIXES: {{^}} const std::string_view b18 = {}; |
338 | |
339 | const std::string_view b19 = {{}}; // Default `const CharT*` |
340 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
341 | // CHECK-FIXES: {{^}} const std::string_view b19 = {}; |
342 | } |
343 | |
344 | // Copy List Initialization With Temporary |
345 | { |
346 | std::string_view b20 = {std::string_view(nullptr)}; |
347 | // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default |
348 | // CHECK-FIXES: {{^}} std::string_view b20 = {std::string_view()}; |
349 | |
350 | std::string_view b21 = {std::string_view{nullptr}}; |
351 | // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default |
352 | // CHECK-FIXES: {{^}} std::string_view b21 = {std::string_view{}}; |
353 | |
354 | std::string_view b22 = {(std::string_view) nullptr}; |
355 | // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default |
356 | // CHECK-FIXES: {{^}} std::string_view b22 = {(std::string_view) {}}; |
357 | |
358 | std::string_view b23 = {(std::string_view){nullptr}}; |
359 | // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default |
360 | // CHECK-FIXES: {{^}} std::string_view b23 = {(std::string_view){}}; |
361 | |
362 | std::string_view b24 = {static_cast<SV>(nullptr)}; |
363 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: casting{{.*}}empty string |
364 | // CHECK-FIXES: {{^}} std::string_view b24 = {static_cast<SV>("")}; |
365 | } |
366 | |
367 | // Direct Initialization |
368 | { |
369 | std::string_view b25(nullptr); |
370 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default |
371 | // CHECK-FIXES: {{^}} std::string_view b25; |
372 | |
373 | std::string_view b26((nullptr)); |
374 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default |
375 | // CHECK-FIXES: {{^}} std::string_view b26; |
376 | |
377 | std::string_view b27({nullptr}); |
378 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default |
379 | // CHECK-FIXES: {{^}} std::string_view b27; |
380 | |
381 | std::string_view b28({(nullptr)}); |
382 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default |
383 | // CHECK-FIXES: {{^}} std::string_view b28; |
384 | |
385 | std::string_view b29({}); // Default `const CharT*` |
386 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default |
387 | // CHECK-FIXES: {{^}} std::string_view b29; |
388 | |
389 | const std::string_view b30(nullptr); |
390 | // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default |
391 | // CHECK-FIXES: {{^}} const std::string_view b30; |
392 | |
393 | const std::string_view b31((nullptr)); |
394 | // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default |
395 | // CHECK-FIXES: {{^}} const std::string_view b31; |
396 | |
397 | const std::string_view b32({nullptr}); |
398 | // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default |
399 | // CHECK-FIXES: {{^}} const std::string_view b32; |
400 | |
401 | const std::string_view b33({(nullptr)}); |
402 | // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default |
403 | // CHECK-FIXES: {{^}} const std::string_view b33; |
404 | |
405 | const std::string_view b34({}); // Default `const CharT*` |
406 | // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default |
407 | // CHECK-FIXES: {{^}} const std::string_view b34; |
408 | } |
409 | |
410 | // Direct Initialization With Temporary |
411 | { |
412 | std::string_view b35(std::string_view(nullptr)); |
413 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
414 | // CHECK-FIXES: {{^}} std::string_view b35(std::string_view()); |
415 | |
416 | std::string_view b36(std::string_view{nullptr}); |
417 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
418 | // CHECK-FIXES: {{^}} std::string_view b36(std::string_view{}); |
419 | |
420 | std::string_view b37((std::string_view) nullptr); |
421 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default |
422 | // CHECK-FIXES: {{^}} std::string_view b37((std::string_view) {}); |
423 | |
424 | std::string_view b38((std::string_view){nullptr}); |
425 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default |
426 | // CHECK-FIXES: {{^}} std::string_view b38((std::string_view){}); |
427 | |
428 | std::string_view b39(static_cast<SV>(nullptr)); |
429 | // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting{{.*}}empty string |
430 | // CHECK-FIXES: {{^}} std::string_view b39(static_cast<SV>("")); |
431 | } |
432 | |
433 | // Direct List Initialization |
434 | { |
435 | std::string_view b40{nullptr}; |
436 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
437 | // CHECK-FIXES: {{^}} std::string_view b40{}; |
438 | |
439 | std::string_view b41{(nullptr)}; |
440 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
441 | // CHECK-FIXES: {{^}} std::string_view b41{}; |
442 | |
443 | std::string_view b42{{nullptr}}; |
444 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
445 | // CHECK-FIXES: {{^}} std::string_view b42{}; |
446 | |
447 | std::string_view b43{{(nullptr)}}; |
448 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
449 | // CHECK-FIXES: {{^}} std::string_view b43{}; |
450 | |
451 | std::string_view b44{{}}; // Default `const CharT*` |
452 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
453 | // CHECK-FIXES: {{^}} std::string_view b44{}; |
454 | |
455 | const std::string_view b45{nullptr}; |
456 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
457 | // CHECK-FIXES: {{^}} const std::string_view b45{}; |
458 | |
459 | const std::string_view b46{(nullptr)}; |
460 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
461 | // CHECK-FIXES: {{^}} const std::string_view b46{}; |
462 | |
463 | const std::string_view b47{{nullptr}}; |
464 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
465 | // CHECK-FIXES: {{^}} const std::string_view b47{}; |
466 | |
467 | const std::string_view b48{{(nullptr)}}; |
468 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
469 | // CHECK-FIXES: {{^}} const std::string_view b48{}; |
470 | |
471 | const std::string_view b49{{}}; // Default `const CharT*` |
472 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
473 | // CHECK-FIXES: {{^}} const std::string_view b49{}; |
474 | } |
475 | |
476 | // Direct List Initialization With Temporary |
477 | { |
478 | std::string_view b50{std::string_view(nullptr)}; |
479 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
480 | // CHECK-FIXES: {{^}} std::string_view b50{std::string_view()}; |
481 | |
482 | std::string_view b51{std::string_view{nullptr}}; |
483 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
484 | // CHECK-FIXES: {{^}} std::string_view b51{std::string_view{}}; |
485 | |
486 | std::string_view b52{(std::string_view) nullptr}; |
487 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default |
488 | // CHECK-FIXES: {{^}} std::string_view b52{(std::string_view) {}}; |
489 | |
490 | std::string_view b53{(std::string_view){nullptr}}; |
491 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default |
492 | // CHECK-FIXES: {{^}} std::string_view b53{(std::string_view){}}; |
493 | |
494 | std::string_view b54{static_cast<SV>(nullptr)}; |
495 | // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting{{.*}}empty string |
496 | // CHECK-FIXES: {{^}} std::string_view b54{static_cast<SV>("")}; |
497 | } |
498 | } |
499 | |
500 | void field_construction() /* c */ { |
501 | // Default Member Initializaers |
502 | |
503 | struct DMICopyInitialization { |
504 | std::string_view c1 = nullptr; |
505 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default |
506 | // CHECK-FIXES: {{^}} std::string_view c1 = {}; |
507 | |
508 | std::string_view c2 = (nullptr); |
509 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default |
510 | // CHECK-FIXES: {{^}} std::string_view c2 = {}; |
511 | |
512 | const std::string_view c3 = nullptr; |
513 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
514 | // CHECK-FIXES: {{^}} const std::string_view c3 = {}; |
515 | |
516 | const std::string_view c4 = (nullptr); |
517 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
518 | // CHECK-FIXES: {{^}} const std::string_view c4 = {}; |
519 | }; |
520 | |
521 | struct DMICopyInitializationWithTemporary { |
522 | std::string_view c5 = std::string_view(nullptr); |
523 | // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default |
524 | // CHECK-FIXES: {{^}} std::string_view c5 = std::string_view(); |
525 | |
526 | std::string_view c6 = std::string_view{nullptr}; |
527 | // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default |
528 | // CHECK-FIXES: {{^}} std::string_view c6 = std::string_view{}; |
529 | |
530 | std::string_view c7 = (std::string_view) nullptr; |
531 | // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default |
532 | // CHECK-FIXES: {{^}} std::string_view c7 = (std::string_view) {}; |
533 | |
534 | std::string_view c8 = (std::string_view){nullptr}; |
535 | // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default |
536 | // CHECK-FIXES: {{^}} std::string_view c8 = (std::string_view){}; |
537 | |
538 | std::string_view c9 = static_cast<SV>(nullptr); |
539 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: casting{{.*}}empty string |
540 | // CHECK-FIXES: {{^}} std::string_view c9 = static_cast<SV>(""); |
541 | }; |
542 | |
543 | struct DMICopyListInitialization { |
544 | std::string_view c10 = {nullptr}; |
545 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
546 | // CHECK-FIXES: {{^}} std::string_view c10 = {}; |
547 | |
548 | std::string_view c11 = {(nullptr)}; |
549 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
550 | // CHECK-FIXES: {{^}} std::string_view c11 = {}; |
551 | |
552 | std::string_view c12 = {{nullptr}}; |
553 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
554 | // CHECK-FIXES: {{^}} std::string_view c12 = {}; |
555 | |
556 | std::string_view c13 = {{(nullptr)}}; |
557 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
558 | // CHECK-FIXES: {{^}} std::string_view c13 = {}; |
559 | |
560 | std::string_view c14 = {{}}; // Default `const CharT*` |
561 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
562 | // CHECK-FIXES: {{^}} std::string_view c14 = {}; |
563 | |
564 | const std::string_view c15 = {nullptr}; |
565 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
566 | // CHECK-FIXES: {{^}} const std::string_view c15 = {}; |
567 | |
568 | const std::string_view c16 = {(nullptr)}; |
569 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
570 | // CHECK-FIXES: {{^}} const std::string_view c16 = {}; |
571 | |
572 | const std::string_view c17 = {{nullptr}}; |
573 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
574 | // CHECK-FIXES: {{^}} const std::string_view c17 = {}; |
575 | |
576 | const std::string_view c18 = {{(nullptr)}}; |
577 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
578 | // CHECK-FIXES: {{^}} const std::string_view c18 = {}; |
579 | |
580 | const std::string_view c19 = {{}}; // Default `const CharT*` |
581 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
582 | // CHECK-FIXES: {{^}} const std::string_view c19 = {}; |
583 | }; |
584 | |
585 | struct DMICopyListInitializationWithTemporary { |
586 | std::string_view c20 = {std::string_view(nullptr)}; |
587 | // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default |
588 | // CHECK-FIXES: {{^}} std::string_view c20 = {std::string_view()}; |
589 | |
590 | std::string_view c21 = {std::string_view{nullptr}}; |
591 | // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default |
592 | // CHECK-FIXES: {{^}} std::string_view c21 = {std::string_view{}}; |
593 | |
594 | std::string_view c22 = {(std::string_view) nullptr}; |
595 | // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default |
596 | // CHECK-FIXES: {{^}} std::string_view c22 = {(std::string_view) {}}; |
597 | |
598 | std::string_view c23 = {(std::string_view){nullptr}}; |
599 | // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default |
600 | // CHECK-FIXES: {{^}} std::string_view c23 = {(std::string_view){}}; |
601 | |
602 | std::string_view c24 = {static_cast<SV>(nullptr)}; |
603 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: casting{{.*}}empty string |
604 | // CHECK-FIXES: {{^}} std::string_view c24 = {static_cast<SV>("")}; |
605 | }; |
606 | |
607 | struct DMIDirectListInitialization { |
608 | std::string_view c25{nullptr}; |
609 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
610 | // CHECK-FIXES: {{^}} std::string_view c25{}; |
611 | |
612 | std::string_view c26{(nullptr)}; |
613 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
614 | // CHECK-FIXES: {{^}} std::string_view c26{}; |
615 | |
616 | std::string_view c27{{nullptr}}; |
617 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
618 | // CHECK-FIXES: {{^}} std::string_view c27{}; |
619 | |
620 | std::string_view c28{{(nullptr)}}; |
621 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
622 | // CHECK-FIXES: {{^}} std::string_view c28{}; |
623 | |
624 | std::string_view c29{{}}; // Default `const CharT*` |
625 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default |
626 | // CHECK-FIXES: {{^}} std::string_view c29{}; |
627 | |
628 | const std::string_view c30{nullptr}; |
629 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
630 | // CHECK-FIXES: {{^}} const std::string_view c30{}; |
631 | |
632 | const std::string_view c31{(nullptr)}; |
633 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
634 | // CHECK-FIXES: {{^}} const std::string_view c31{}; |
635 | |
636 | const std::string_view c32{{nullptr}}; |
637 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
638 | // CHECK-FIXES: {{^}} const std::string_view c32{}; |
639 | |
640 | const std::string_view c33{{(nullptr)}}; |
641 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
642 | // CHECK-FIXES: {{^}} const std::string_view c33{}; |
643 | |
644 | const std::string_view c34{{}}; // Default `const CharT*` |
645 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
646 | // CHECK-FIXES: {{^}} const std::string_view c34{}; |
647 | }; |
648 | |
649 | struct DMIDirectListInitializationWithTemporary { |
650 | std::string_view c35{std::string_view(nullptr)}; |
651 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
652 | // CHECK-FIXES: {{^}} std::string_view c35{std::string_view()}; |
653 | |
654 | std::string_view c36{std::string_view{nullptr}}; |
655 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
656 | // CHECK-FIXES: {{^}} std::string_view c36{std::string_view{}}; |
657 | |
658 | std::string_view c37{(std::string_view) nullptr}; |
659 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default |
660 | // CHECK-FIXES: {{^}} std::string_view c37{(std::string_view) {}}; |
661 | |
662 | std::string_view c38{(std::string_view){nullptr}}; |
663 | // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default |
664 | // CHECK-FIXES: {{^}} std::string_view c38{(std::string_view){}}; |
665 | |
666 | std::string_view c39{static_cast<SV>(nullptr)}; |
667 | // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting{{.*}}empty string |
668 | // CHECK-FIXES: {{^}} std::string_view c39{static_cast<SV>("")}; |
669 | }; |
670 | |
671 | // Constructor Initializers |
672 | |
673 | class CIDirectInitialization { |
674 | std::string_view c40; |
675 | std::string_view c41; |
676 | std::string_view c42; |
677 | std::string_view c43; |
678 | std::string_view c44; |
679 | |
680 | CIDirectInitialization() |
681 | : c40(nullptr), |
682 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
683 | // CHECK-FIXES: {{^}} : c40(), |
684 | |
685 | c41((nullptr)), |
686 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
687 | // CHECK-FIXES: {{^}} c41(), |
688 | |
689 | c42({nullptr}), |
690 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
691 | // CHECK-FIXES: {{^}} c42(), |
692 | |
693 | c43({(nullptr)}), |
694 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
695 | // CHECK-FIXES: {{^}} c43(), |
696 | |
697 | c44({}) { // Default `const CharT*` |
698 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
699 | // CHECK-FIXES: {{^}} c44() { |
700 | } |
701 | }; |
702 | |
703 | class CIDirectInitializationWithTemporary { |
704 | std::string_view c45; |
705 | std::string_view c46; |
706 | std::string_view c47; |
707 | std::string_view c48; |
708 | std::string_view c49; |
709 | |
710 | CIDirectInitializationWithTemporary() |
711 | : c45(std::string_view(nullptr)), |
712 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
713 | // CHECK-FIXES: {{^}} : c45(std::string_view()), |
714 | |
715 | c46(std::string_view{nullptr}), |
716 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
717 | // CHECK-FIXES: {{^}} c46(std::string_view{}), |
718 | |
719 | c47((std::string_view) nullptr), |
720 | // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default |
721 | // CHECK-FIXES: {{^}} c47((std::string_view) {}), |
722 | |
723 | c48((std::string_view){nullptr}), |
724 | // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default |
725 | // CHECK-FIXES: {{^}} c48((std::string_view){}), |
726 | |
727 | c49(static_cast<SV>(nullptr)) { |
728 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: casting{{.*}}empty string |
729 | // CHECK-FIXES: {{^}} c49(static_cast<SV>("")) { |
730 | } |
731 | }; |
732 | |
733 | class CIDirectListInitialization { |
734 | std::string_view c50; |
735 | std::string_view c51; |
736 | std::string_view c52; |
737 | std::string_view c53; |
738 | std::string_view c54; |
739 | |
740 | CIDirectListInitialization() |
741 | : c50{nullptr}, |
742 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
743 | // CHECK-FIXES: {{^}} : c50{}, |
744 | |
745 | c51{(nullptr)}, |
746 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
747 | // CHECK-FIXES: {{^}} c51{}, |
748 | |
749 | c52{{nullptr}}, |
750 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
751 | // CHECK-FIXES: {{^}} c52{}, |
752 | |
753 | c53{{(nullptr)}}, |
754 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
755 | // CHECK-FIXES: {{^}} c53{}, |
756 | |
757 | c54{{}} { // Default `const CharT*` |
758 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default |
759 | // CHECK-FIXES: {{^}} c54{} { |
760 | } |
761 | }; |
762 | |
763 | class CIDirectListInitializationWithTemporary { |
764 | std::string_view c55; |
765 | std::string_view c56; |
766 | std::string_view c57; |
767 | std::string_view c58; |
768 | std::string_view c59; |
769 | |
770 | CIDirectListInitializationWithTemporary() |
771 | : c55{std::string_view(nullptr)}, |
772 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
773 | // CHECK-FIXES: {{^}} : c55{std::string_view()}, |
774 | |
775 | c56{std::string_view{nullptr}}, |
776 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
777 | // CHECK-FIXES: {{^}} c56{std::string_view{}}, |
778 | |
779 | c57{(std::string_view) nullptr}, |
780 | // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default |
781 | // CHECK-FIXES: {{^}} c57{(std::string_view) {}}, |
782 | |
783 | c58{(std::string_view){nullptr}}, |
784 | // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default |
785 | // CHECK-FIXES: {{^}} c58{(std::string_view){}}, |
786 | |
787 | c59{static_cast<SV>(nullptr)} { |
788 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: casting{{.*}}empty string |
789 | // CHECK-FIXES: {{^}} c59{static_cast<SV>("")} { |
790 | } |
791 | }; |
792 | } |
793 | |
794 | void default_argument_construction() /* d */ { |
795 | // Copy Initialization |
796 | { |
797 | void d1(std::string_view sv = nullptr); |
798 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
799 | // CHECK-FIXES: {{^}} void d1(std::string_view sv = {}); |
800 | |
801 | void d2(std::string_view sv = (nullptr)); |
802 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
803 | // CHECK-FIXES: {{^}} void d2(std::string_view sv = {}); |
804 | |
805 | void d3(const std::string_view sv = nullptr); |
806 | // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: constructing{{.*}}default |
807 | // CHECK-FIXES: {{^}} void d3(const std::string_view sv = {}); |
808 | |
809 | void d4(const std::string_view sv = (nullptr)); |
810 | // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: constructing{{.*}}default |
811 | // CHECK-FIXES: {{^}} void d4(const std::string_view sv = {}); |
812 | } |
813 | |
814 | // Copy Initialization With Temporary |
815 | { |
816 | void d5(std::string_view sv = std::string_view(nullptr)); |
817 | // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default |
818 | // CHECK-FIXES: {{^}} void d5(std::string_view sv = std::string_view()); |
819 | |
820 | void d6(std::string_view sv = std::string_view{nullptr}); |
821 | // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default |
822 | // CHECK-FIXES: {{^}} void d6(std::string_view sv = std::string_view{}); |
823 | |
824 | void d7(std::string_view sv = (std::string_view) nullptr); |
825 | // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: constructing{{.*}}default |
826 | // CHECK-FIXES: {{^}} void d7(std::string_view sv = (std::string_view) {}); |
827 | |
828 | void d8(std::string_view sv = (std::string_view){nullptr}); |
829 | // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: constructing{{.*}}default |
830 | // CHECK-FIXES: {{^}} void d8(std::string_view sv = (std::string_view){}); |
831 | |
832 | void d9(std::string_view sv = static_cast<SV>(nullptr)); |
833 | // CHECK-MESSAGES: :[[@LINE-1]]:51: warning: casting{{.*}}empty string |
834 | // CHECK-FIXES: {{^}} void d9(std::string_view sv = static_cast<SV>("")); |
835 | } |
836 | |
837 | // Copy List Initialization |
838 | { |
839 | void d10(std::string_view sv = {nullptr}); |
840 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
841 | // CHECK-FIXES: {{^}} void d10(std::string_view sv = {}); |
842 | |
843 | void d11(std::string_view sv = {(nullptr)}); |
844 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
845 | // CHECK-FIXES: {{^}} void d11(std::string_view sv = {}); |
846 | |
847 | void d12(std::string_view sv = {{nullptr}}); |
848 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
849 | // CHECK-FIXES: {{^}} void d12(std::string_view sv = {}); |
850 | |
851 | void d13(std::string_view sv = {{(nullptr)}}); |
852 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
853 | // CHECK-FIXES: {{^}} void d13(std::string_view sv = {}); |
854 | |
855 | void d14(std::string_view sv = {{}}); // Default `const CharT*` |
856 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default |
857 | // CHECK-FIXES: {{^}} void d14(std::string_view sv = {}); |
858 | |
859 | void d15(const std::string_view sv = {nullptr}); |
860 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
861 | // CHECK-FIXES: {{^}} void d15(const std::string_view sv = {}); |
862 | |
863 | void d16(const std::string_view sv = {(nullptr)}); |
864 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
865 | // CHECK-FIXES: {{^}} void d16(const std::string_view sv = {}); |
866 | |
867 | void d17(const std::string_view sv = {{nullptr}}); |
868 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
869 | // CHECK-FIXES: {{^}} void d17(const std::string_view sv = {}); |
870 | |
871 | void d18(const std::string_view sv = {{(nullptr)}}); |
872 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
873 | // CHECK-FIXES: {{^}} void d18(const std::string_view sv = {}); |
874 | |
875 | void d19(const std::string_view sv = {{}}); // Default `const CharT*` |
876 | // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default |
877 | // CHECK-FIXES: {{^}} void d19(const std::string_view sv = {}); |
878 | } |
879 | |
880 | // Copy List Initialization With Temporary |
881 | { |
882 | void d20(std::string_view sv = {std::string_view(nullptr)}); |
883 | // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: constructing{{.*}}default |
884 | // CHECK-FIXES: {{^}} void d20(std::string_view sv = {std::string_view()}); |
885 | |
886 | void d21(std::string_view sv = {std::string_view{nullptr}}); |
887 | // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: constructing{{.*}}default |
888 | // CHECK-FIXES: {{^}} void d21(std::string_view sv = {std::string_view{}}); |
889 | |
890 | void d22(std::string_view sv = {(std::string_view) nullptr}); |
891 | // CHECK-MESSAGES: :[[@LINE-1]]:56: warning: constructing{{.*}}default |
892 | // CHECK-FIXES: {{^}} void d22(std::string_view sv = {(std::string_view) {}}); |
893 | |
894 | void d23(std::string_view sv = {(std::string_view){nullptr}}); |
895 | // CHECK-MESSAGES: :[[@LINE-1]]:56: warning: constructing{{.*}}default |
896 | // CHECK-FIXES: {{^}} void d23(std::string_view sv = {(std::string_view){}}); |
897 | |
898 | void d24(std::string_view sv = {static_cast<SV>(nullptr)}); |
899 | // CHECK-MESSAGES: :[[@LINE-1]]:53: warning: casting{{.*}}empty string |
900 | // CHECK-FIXES: {{^}} void d24(std::string_view sv = {static_cast<SV>("")}); |
901 | } |
902 | } |
903 | |
904 | void heap_construction() /* e */ { |
905 | // Direct Initialization |
906 | { |
907 | (void)(new std::string_view(nullptr)) /* e1 */; |
908 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
909 | // CHECK-FIXES: {{^}} (void)(new std::string_view()) /* e1 */; |
910 | |
911 | (void)(new std::string_view((nullptr))) /* e2 */; |
912 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
913 | // CHECK-FIXES: {{^}} (void)(new std::string_view()) /* e2 */; |
914 | |
915 | (void)(new std::string_view({nullptr})) /* e3 */; |
916 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
917 | // CHECK-FIXES: {{^}} (void)(new std::string_view()) /* e3 */; |
918 | |
919 | (void)(new std::string_view({(nullptr)})) /* e4 */; |
920 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
921 | // CHECK-FIXES: {{^}} (void)(new std::string_view()) /* e4 */; |
922 | |
923 | (void)(new std::string_view({})) /* e5 */; // Default `const CharT*` |
924 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
925 | // CHECK-FIXES: {{^}} (void)(new std::string_view()) /* e5 */; |
926 | |
927 | (void)(new const std::string_view(nullptr)) /* e6 */; |
928 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
929 | // CHECK-FIXES: {{^}} (void)(new const std::string_view()) /* e6 */; |
930 | |
931 | (void)(new const std::string_view((nullptr))) /* e7 */; |
932 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
933 | // CHECK-FIXES: {{^}} (void)(new const std::string_view()) /* e7 */; |
934 | |
935 | (void)(new const std::string_view({nullptr})) /* e8 */; |
936 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
937 | // CHECK-FIXES: {{^}} (void)(new const std::string_view()) /* e8 */; |
938 | |
939 | (void)(new const std::string_view({(nullptr)})) /* e9 */; |
940 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
941 | // CHECK-FIXES: {{^}} (void)(new const std::string_view()) /* e9 */; |
942 | |
943 | (void)(new const std::string_view({})) /* e10 */; // Default `const CharT*` |
944 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
945 | // CHECK-FIXES: {{^}} (void)(new const std::string_view()) /* e10 */; |
946 | } |
947 | |
948 | // Direct Initialization With Temporary |
949 | { |
950 | (void)(new std::string_view(std::string_view(nullptr))) /* e11 */; |
951 | // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: constructing{{.*}}default |
952 | // CHECK-FIXES: {{^}} (void)(new std::string_view(std::string_view())) /* e11 */; |
953 | |
954 | (void)(new std::string_view(std::string_view{nullptr})) /* e12 */; |
955 | // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: constructing{{.*}}default |
956 | // CHECK-FIXES: {{^}} (void)(new std::string_view(std::string_view{})) /* e12 */; |
957 | |
958 | (void)(new std::string_view((std::string_view) nullptr)) /* e13 */; |
959 | // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default |
960 | // CHECK-FIXES: {{^}} (void)(new std::string_view((std::string_view) {})) /* e13 */; |
961 | |
962 | (void)(new std::string_view((std::string_view){nullptr})) /* e14 */; |
963 | // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default |
964 | // CHECK-FIXES: {{^}} (void)(new std::string_view((std::string_view){})) /* e14 */; |
965 | |
966 | (void)(new std::string_view(static_cast<SV>(nullptr))) /* e15 */; |
967 | // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: casting{{.*}}empty string |
968 | // CHECK-FIXES: {{^}} (void)(new std::string_view(static_cast<SV>(""))) /* e15 */; |
969 | } |
970 | |
971 | // Direct List Initialization |
972 | { |
973 | (void)(new std::string_view{nullptr}) /* e16 */; |
974 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
975 | // CHECK-FIXES: {{^}} (void)(new std::string_view{}) /* e16 */; |
976 | |
977 | (void)(new std::string_view{(nullptr)}) /* e17 */; |
978 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
979 | // CHECK-FIXES: {{^}} (void)(new std::string_view{}) /* e17 */; |
980 | |
981 | (void)(new std::string_view{{nullptr}}) /* e18 */; |
982 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
983 | // CHECK-FIXES: {{^}} (void)(new std::string_view{}) /* e18 */; |
984 | |
985 | (void)(new std::string_view{{(nullptr)}}) /* e19 */; |
986 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
987 | // CHECK-FIXES: {{^}} (void)(new std::string_view{}) /* e19 */; |
988 | |
989 | (void)(new std::string_view{{}}) /* e20 */; // Default `const CharT*` |
990 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
991 | // CHECK-FIXES: {{^}} (void)(new std::string_view{}) /* e20 */; |
992 | |
993 | (void)(new const std::string_view{nullptr}) /* e21 */; |
994 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
995 | // CHECK-FIXES: {{^}} (void)(new const std::string_view{}) /* e21 */; |
996 | |
997 | (void)(new const std::string_view{(nullptr)}) /* e22 */; |
998 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
999 | // CHECK-FIXES: {{^}} (void)(new const std::string_view{}) /* e22 */; |
1000 | |
1001 | (void)(new const std::string_view{{nullptr}}) /* e23 */; |
1002 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
1003 | // CHECK-FIXES: {{^}} (void)(new const std::string_view{}) /* e23 */; |
1004 | |
1005 | (void)(new const std::string_view{{(nullptr)}}) /* e24 */; |
1006 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
1007 | // CHECK-FIXES: {{^}} (void)(new const std::string_view{}) /* e24 */; |
1008 | |
1009 | (void)(new const std::string_view{{}}) /* e25 */; // Default `const CharT*` |
1010 | // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default |
1011 | // CHECK-FIXES: {{^}} (void)(new const std::string_view{}) /* e25 */; |
1012 | } |
1013 | |
1014 | // Direct List Initialization With Temporary |
1015 | { |
1016 | (void)(new std::string_view{std::string_view(nullptr)}) /* e26 */; |
1017 | // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: constructing{{.*}}default |
1018 | // CHECK-FIXES: {{^}} (void)(new std::string_view{std::string_view()}) /* e26 */; |
1019 | |
1020 | (void)(new std::string_view{std::string_view{nullptr}}) /* e27 */; |
1021 | // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: constructing{{.*}}default |
1022 | // CHECK-FIXES: {{^}} (void)(new std::string_view{std::string_view{}}) /* e27 */; |
1023 | |
1024 | (void)(new std::string_view{(std::string_view) nullptr}) /* e28 */; |
1025 | // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default |
1026 | // CHECK-FIXES: {{^}} (void)(new std::string_view{(std::string_view) {}}) /* e28 */; |
1027 | |
1028 | (void)(new std::string_view{(std::string_view){nullptr}}) /* e29 */; |
1029 | // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default |
1030 | // CHECK-FIXES: {{^}} (void)(new std::string_view{(std::string_view){}}) /* e29 */; |
1031 | |
1032 | (void)(new std::string_view{static_cast<SV>(nullptr)}) /* e30 */; |
1033 | // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: casting{{.*}}empty string |
1034 | // CHECK-FIXES: {{^}} (void)(new std::string_view{static_cast<SV>("")}) /* e30 */; |
1035 | } |
1036 | } |
1037 | |
1038 | void function_argument_initialization() /* f */ { |
1039 | // Function Argument Initialization |
1040 | { |
1041 | function(nullptr) /* f1 */; |
1042 | // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing null as basic_string_view is undefined; replace with the empty string |
1043 | // CHECK-FIXES: {{^}} function("") /* f1 */; |
1044 | |
1045 | function((nullptr)) /* f2 */; |
1046 | // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string |
1047 | // CHECK-FIXES: {{^}} function("") /* f2 */; |
1048 | |
1049 | function({nullptr}) /* f3 */; |
1050 | // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string |
1051 | // CHECK-FIXES: {{^}} function("") /* f3 */; |
1052 | |
1053 | function({(nullptr)}) /* f4 */; |
1054 | // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string |
1055 | // CHECK-FIXES: {{^}} function("") /* f4 */; |
1056 | |
1057 | function({{}}) /* f5 */; // Default `const CharT*` |
1058 | // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string |
1059 | // CHECK-FIXES: {{^}} function("") /* f5 */; |
1060 | } |
1061 | |
1062 | // Function Argument Initialization With Temporary |
1063 | { |
1064 | function(std::string_view(nullptr)) /* f6 */; |
1065 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default |
1066 | // CHECK-FIXES: {{^}} function(std::string_view()) /* f6 */; |
1067 | |
1068 | function(std::string_view{nullptr}) /* f7 */; |
1069 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default |
1070 | // CHECK-FIXES: {{^}} function(std::string_view{}) /* f7 */; |
1071 | |
1072 | function((std::string_view) nullptr) /* f8 */; |
1073 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
1074 | // CHECK-FIXES: {{^}} function((std::string_view) {}) /* f8 */; |
1075 | |
1076 | function((std::string_view){nullptr}) /* f9 */; |
1077 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
1078 | // CHECK-FIXES: {{^}} function((std::string_view){}) /* f9 */; |
1079 | |
1080 | function(static_cast<SV>(nullptr)) /* f10 */; |
1081 | // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: casting{{.*}}empty string |
1082 | // CHECK-FIXES: {{^}} function(static_cast<SV>("")) /* f10 */; |
1083 | } |
1084 | } |
1085 | |
1086 | void assignment(std::string_view sv) /* g */ { |
1087 | // Assignment |
1088 | { |
1089 | sv = nullptr /* g1 */; |
1090 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment to basic_string_view from null is undefined; replace with the default constructor |
1091 | // CHECK-FIXES: {{^}} sv = {} /* g1 */; |
1092 | |
1093 | sv = (nullptr) /* g2 */; |
1094 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default |
1095 | // CHECK-FIXES: {{^}} sv = {} /* g2 */; |
1096 | |
1097 | sv = {nullptr} /* g3 */; |
1098 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default |
1099 | // CHECK-FIXES: {{^}} sv = {} /* g3 */; |
1100 | |
1101 | sv = {(nullptr)} /* g4 */; |
1102 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default |
1103 | // CHECK-FIXES: {{^}} sv = {} /* g4 */; |
1104 | |
1105 | sv = {{}} /* g5 */; // Default `const CharT*` |
1106 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default |
1107 | // CHECK-FIXES: {{^}} sv = {} /* g5 */; |
1108 | } |
1109 | |
1110 | // Assignment With Temporary |
1111 | { |
1112 | sv = std::string_view(nullptr) /* g6 */; |
1113 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default |
1114 | // CHECK-FIXES: {{^}} sv = std::string_view() /* g6 */; |
1115 | |
1116 | sv = std::string_view{nullptr} /* g7 */; |
1117 | // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default |
1118 | // CHECK-FIXES: {{^}} sv = std::string_view{} /* g7 */; |
1119 | |
1120 | sv = (std::string_view) nullptr /* g8 */; |
1121 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
1122 | // CHECK-FIXES: {{^}} sv = (std::string_view) {} /* g8 */; |
1123 | |
1124 | sv = (std::string_view){nullptr} /* g9 */; |
1125 | // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default |
1126 | // CHECK-FIXES: {{^}} sv = (std::string_view){} /* g9 */; |
1127 | |
1128 | sv = static_cast<SV>(nullptr) /* g10 */; |
1129 | // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: casting{{.*}}empty string |
1130 | // CHECK-FIXES: {{^}} sv = static_cast<SV>("") /* g10 */; |
1131 | } |
1132 | } |
1133 | |
1134 | void pointer_assignment(std::string_view *sv_ptr) /* h */ { |
1135 | // Assignment |
1136 | { |
1137 | *sv_ptr = nullptr /* h1 */; |
1138 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default |
1139 | // CHECK-FIXES: {{^}} *sv_ptr = {} /* h1 */; |
1140 | |
1141 | *sv_ptr = (nullptr) /* h2 */; |
1142 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default |
1143 | // CHECK-FIXES: {{^}} *sv_ptr = {} /* h2 */; |
1144 | |
1145 | *sv_ptr = {nullptr} /* h3 */; |
1146 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default |
1147 | // CHECK-FIXES: {{^}} *sv_ptr = {} /* h3 */; |
1148 | |
1149 | *sv_ptr = {(nullptr)} /* h4 */; |
1150 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default |
1151 | // CHECK-FIXES: {{^}} *sv_ptr = {} /* h4 */; |
1152 | |
1153 | *sv_ptr = {{}} /* h5 */; // Default `const CharT*` |
1154 | // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default |
1155 | // CHECK-FIXES: {{^}} *sv_ptr = {} /* h5 */; |
1156 | } |
1157 | |
1158 | // Assignment With Temporary |
1159 | { |
1160 | *sv_ptr = std::string_view(nullptr) /* h6 */; |
1161 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
1162 | // CHECK-FIXES: {{^}} *sv_ptr = std::string_view() /* h6 */; |
1163 | |
1164 | *sv_ptr = std::string_view{nullptr} /* h7 */; |
1165 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
1166 | // CHECK-FIXES: {{^}} *sv_ptr = std::string_view{} /* h7 */; |
1167 | |
1168 | *sv_ptr = (std::string_view) nullptr /* h8 */; |
1169 | // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default |
1170 | // CHECK-FIXES: {{^}} *sv_ptr = (std::string_view) {} /* h8 */; |
1171 | |
1172 | *sv_ptr = (std::string_view){nullptr} /* h9 */; |
1173 | // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default |
1174 | // CHECK-FIXES: {{^}} *sv_ptr = (std::string_view){} /* h9 */; |
1175 | |
1176 | *sv_ptr = static_cast<SV>(nullptr) /* h10 */; |
1177 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: casting{{.*}}empty string |
1178 | // CHECK-FIXES: {{^}} *sv_ptr = static_cast<SV>("") /* h10 */; |
1179 | } |
1180 | } |
1181 | |
1182 | void lesser_comparison(std::string_view sv) /* i */ { |
1183 | // Without Equality |
1184 | { |
1185 | (void)(sv < nullptr) /* i1 */; |
1186 | // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: comparing basic_string_view to null is undefined; replace with the empty string |
1187 | // CHECK-FIXES: {{^}} (void)(sv < "") /* i1 */; |
1188 | |
1189 | (void)(sv < (nullptr)) /* i2 */; |
1190 | // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: comparing{{.*}}empty string |
1191 | // CHECK-FIXES: {{^}} (void)(sv < "") /* i2 */; |
1192 | |
1193 | (void)(nullptr < sv) /* i3 */; |
1194 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1195 | // CHECK-FIXES: {{^}} (void)("" < sv) /* i3 */; |
1196 | |
1197 | (void)((nullptr) < sv) /* i4 */; |
1198 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1199 | // CHECK-FIXES: {{^}} (void)("" < sv) /* i4 */; |
1200 | } |
1201 | |
1202 | // With Equality |
1203 | { |
1204 | (void)(sv <= nullptr) /* i5 */; |
1205 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: comparing{{.*}}empty string |
1206 | // CHECK-FIXES: {{^}} (void)(sv <= "") /* i5 */; |
1207 | |
1208 | (void)(sv <= (nullptr)) /* i6 */; |
1209 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: comparing{{.*}}empty string |
1210 | // CHECK-FIXES: {{^}} (void)(sv <= "") /* i6 */; |
1211 | |
1212 | (void)(nullptr <= sv) /* i7 */; |
1213 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1214 | // CHECK-FIXES: {{^}} (void)("" <= sv) /* i7 */; |
1215 | |
1216 | (void)((nullptr) <= sv) /* i8 */; |
1217 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1218 | // CHECK-FIXES: {{^}} (void)("" <= sv) /* i8 */; |
1219 | } |
1220 | } |
1221 | |
1222 | void pointer_lesser_comparison(std::string_view *sv_ptr) /* j */ { |
1223 | // Without Equality |
1224 | { |
1225 | (void)(*sv_ptr < nullptr) /* j1 */; |
1226 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: comparing{{.*}}empty string |
1227 | // CHECK-FIXES: {{^}} (void)(*sv_ptr < "") /* j1 */; |
1228 | |
1229 | (void)(*sv_ptr < (nullptr)) /* j2 */; |
1230 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: comparing{{.*}}empty string |
1231 | // CHECK-FIXES: {{^}} (void)(*sv_ptr < "") /* j2 */; |
1232 | |
1233 | (void)(nullptr < *sv_ptr) /* j3 */; |
1234 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1235 | // CHECK-FIXES: {{^}} (void)("" < *sv_ptr) /* j3 */; |
1236 | |
1237 | (void)((nullptr) < *sv_ptr) /* j4 */; |
1238 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1239 | // CHECK-FIXES: {{^}} (void)("" < *sv_ptr) /* j4 */; |
1240 | } |
1241 | |
1242 | // With Equality |
1243 | { |
1244 | (void)(*sv_ptr <= nullptr) /* j5 */; |
1245 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: comparing{{.*}}empty string |
1246 | // CHECK-FIXES: {{^}} (void)(*sv_ptr <= "") /* j5 */; |
1247 | |
1248 | (void)(*sv_ptr <= (nullptr)) /* j6 */; |
1249 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: comparing{{.*}}empty string |
1250 | // CHECK-FIXES: {{^}} (void)(*sv_ptr <= "") /* j6 */; |
1251 | |
1252 | (void)(nullptr <= *sv_ptr) /* j7 */; |
1253 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1254 | // CHECK-FIXES: {{^}} (void)("" <= *sv_ptr) /* j7 */; |
1255 | |
1256 | (void)((nullptr) <= *sv_ptr) /* j8 */; |
1257 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1258 | // CHECK-FIXES: {{^}} (void)("" <= *sv_ptr) /* j8 */; |
1259 | } |
1260 | } |
1261 | |
1262 | void greater_comparison(std::string_view sv) /* k */ { |
1263 | // Without Equality |
1264 | { |
1265 | (void)(sv > nullptr) /* k1 */; |
1266 | // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: comparing{{.*}}empty string |
1267 | // CHECK-FIXES: {{^}} (void)(sv > "") /* k1 */; |
1268 | |
1269 | (void)(sv > (nullptr)) /* k2 */; |
1270 | // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: comparing{{.*}}empty string |
1271 | // CHECK-FIXES: {{^}} (void)(sv > "") /* k2 */; |
1272 | |
1273 | (void)(nullptr > sv) /* k3 */; |
1274 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1275 | // CHECK-FIXES: {{^}} (void)("" > sv) /* k3 */; |
1276 | |
1277 | (void)((nullptr) > sv) /* k4 */; |
1278 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1279 | // CHECK-FIXES: {{^}} (void)("" > sv) /* k4 */; |
1280 | } |
1281 | |
1282 | // With Equality |
1283 | { |
1284 | (void)(sv >= nullptr) /* k5 */; |
1285 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: comparing{{.*}}empty string |
1286 | // CHECK-FIXES: {{^}} (void)(sv >= "") /* k5 */; |
1287 | |
1288 | (void)(sv >= (nullptr)) /* k6 */; |
1289 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: comparing{{.*}}empty string |
1290 | // CHECK-FIXES: {{^}} (void)(sv >= "") /* k6 */; |
1291 | |
1292 | (void)(nullptr >= sv) /* k7 */; |
1293 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1294 | // CHECK-FIXES: {{^}} (void)("" >= sv) /* k7 */; |
1295 | |
1296 | (void)((nullptr) >= sv) /* k8 */; |
1297 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1298 | // CHECK-FIXES: {{^}} (void)("" >= sv) /* k8 */; |
1299 | } |
1300 | } |
1301 | |
1302 | void pointer_greater_comparison(std::string_view *sv_ptr) /* l */ { |
1303 | // Without Equality |
1304 | { |
1305 | (void)(*sv_ptr > nullptr) /* l1 */; |
1306 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: comparing{{.*}}empty string |
1307 | // CHECK-FIXES: {{^}} (void)(*sv_ptr > "") /* l1 */; |
1308 | |
1309 | (void)(*sv_ptr > (nullptr)) /* l2 */; |
1310 | // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: comparing{{.*}}empty string |
1311 | // CHECK-FIXES: {{^}} (void)(*sv_ptr > "") /* l2 */; |
1312 | |
1313 | (void)(nullptr > *sv_ptr) /* l3 */; |
1314 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1315 | // CHECK-FIXES: {{^}} (void)("" > *sv_ptr) /* l3 */; |
1316 | |
1317 | (void)((nullptr) > *sv_ptr) /* l4 */; |
1318 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1319 | // CHECK-FIXES: {{^}} (void)("" > *sv_ptr) /* l4 */; |
1320 | } |
1321 | |
1322 | // With Equality |
1323 | { |
1324 | (void)(*sv_ptr >= nullptr) /* l5 */; |
1325 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: comparing{{.*}}empty string |
1326 | // CHECK-FIXES: {{^}} (void)(*sv_ptr >= "") /* l5 */; |
1327 | |
1328 | (void)(*sv_ptr >= (nullptr)) /* l6 */; |
1329 | // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: comparing{{.*}}empty string |
1330 | // CHECK-FIXES: {{^}} (void)(*sv_ptr >= "") /* l6 */; |
1331 | |
1332 | (void)(nullptr >= *sv_ptr) /* l7 */; |
1333 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1334 | // CHECK-FIXES: {{^}} (void)("" >= *sv_ptr) /* l7 */; |
1335 | |
1336 | (void)((nullptr) >= *sv_ptr) /* l8 */; |
1337 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string |
1338 | // CHECK-FIXES: {{^}} (void)("" >= *sv_ptr) /* l8 */; |
1339 | } |
1340 | } |
1341 | |
1342 | void relative_comparison_with_temporary(std::string_view sv) /* m */ { |
1343 | (void)(sv < std::string_view(nullptr)) /* m1 */; |
1344 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
1345 | // CHECK-FIXES: {{^}} (void)(sv < std::string_view()) /* m1 */; |
1346 | |
1347 | (void)(sv < std::string_view{nullptr}) /* m2 */; |
1348 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default |
1349 | // CHECK-FIXES: {{^}} (void)(sv < std::string_view{}) /* m2 */; |
1350 | |
1351 | (void)(sv < (std::string_view) nullptr) /* m3 */; |
1352 | // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default |
1353 | // CHECK-FIXES: {{^}} (void)(sv < (std::string_view) {}) /* m3 */; |
1354 | |
1355 | (void)(sv < (std::string_view){nullptr}) /* m4 */; |
1356 | // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default |
1357 | // CHECK-FIXES: {{^}} (void)(sv < (std::string_view){}) /* m4 */; |
1358 | |
1359 | (void)(sv < static_cast<SV>(nullptr)) /* m5 */; |
1360 | // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: casting{{.*}}empty string |
1361 | // CHECK-FIXES: {{^}} (void)(sv < static_cast<SV>("")) /* m5 */; |
1362 | } |
1363 | |
1364 | void equality_comparison(std::string_view sv) /* n */ { |
1365 | // Empty Without Parens |
1366 | { |
1367 | (void)(sv == nullptr) /* n1 */; |
1368 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing basic_string_view to null is undefined; replace with the emptiness query |
1369 | // CHECK-FIXES: {{^}} (void)(sv.empty()) /* n1 */; |
1370 | |
1371 | (void)(sv == (nullptr)) /* n2 */; |
1372 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1373 | // CHECK-FIXES: {{^}} (void)(sv.empty()) /* n2 */; |
1374 | |
1375 | (void)(nullptr == sv) /* n3 */; |
1376 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1377 | // CHECK-FIXES: {{^}} (void)(sv.empty()) /* n3 */; |
1378 | |
1379 | (void)((nullptr) == sv) /* n4 */; |
1380 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1381 | // CHECK-FIXES: {{^}} (void)(sv.empty()) /* n4 */; |
1382 | } |
1383 | |
1384 | // Empty With Parens |
1385 | { |
1386 | (void)((sv) == nullptr) /* n5 */; |
1387 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing basic_string_view to null is undefined; replace with the emptiness query |
1388 | // CHECK-FIXES: {{^}} (void)(sv.empty()) /* n5 */; |
1389 | |
1390 | (void)((sv) == (nullptr)) /* n6 */; |
1391 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1392 | // CHECK-FIXES: {{^}} (void)(sv.empty()) /* n6 */; |
1393 | |
1394 | (void)(nullptr == (sv)) /* n7 */; |
1395 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1396 | // CHECK-FIXES: {{^}} (void)(sv.empty()) /* n7 */; |
1397 | |
1398 | (void)((nullptr) == (sv)) /* n8 */; |
1399 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1400 | // CHECK-FIXES: {{^}} (void)(sv.empty()) /* n8 */; |
1401 | } |
1402 | |
1403 | // Non-Empty Without Parens |
1404 | { |
1405 | (void)((sv) != nullptr) /* n9 */; |
1406 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1407 | // CHECK-FIXES: {{^}} (void)(!sv.empty()) /* n9 */; |
1408 | |
1409 | (void)((sv) != (nullptr)) /* n10 */; |
1410 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1411 | // CHECK-FIXES: {{^}} (void)(!sv.empty()) /* n10 */; |
1412 | |
1413 | (void)(nullptr != (sv)) /* n11 */; |
1414 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1415 | // CHECK-FIXES: {{^}} (void)(!sv.empty()) /* n11 */; |
1416 | |
1417 | (void)((nullptr) != (sv)) /* n12 */; |
1418 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1419 | // CHECK-FIXES: {{^}} (void)(!sv.empty()) /* n12 */; |
1420 | } |
1421 | |
1422 | // Non-Empty With Parens |
1423 | { |
1424 | (void)((sv) != nullptr) /* n13 */; |
1425 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1426 | // CHECK-FIXES: {{^}} (void)(!sv.empty()) /* n13 */; |
1427 | |
1428 | (void)((sv) != (nullptr)) /* n14 */; |
1429 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1430 | // CHECK-FIXES: {{^}} (void)(!sv.empty()) /* n14 */; |
1431 | |
1432 | (void)(nullptr != (sv)) /* n15 */; |
1433 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1434 | // CHECK-FIXES: {{^}} (void)(!sv.empty()) /* n15 */; |
1435 | |
1436 | (void)((nullptr) != (sv)) /* n16 */; |
1437 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1438 | // CHECK-FIXES: {{^}} (void)(!sv.empty()) /* n16 */; |
1439 | } |
1440 | } |
1441 | |
1442 | void pointer_equality_comparison(std::string_view *sv_ptr) /* o */ { |
1443 | // Empty Without Parens |
1444 | { |
1445 | (void)(*sv_ptr == nullptr) /* o1 */; |
1446 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1447 | // CHECK-FIXES: {{^}} (void)(sv_ptr->empty()) /* o1 */; |
1448 | |
1449 | (void)(*sv_ptr == (nullptr)) /* o2 */; |
1450 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1451 | // CHECK-FIXES: {{^}} (void)(sv_ptr->empty()) /* o2 */; |
1452 | |
1453 | (void)(nullptr == *sv_ptr) /* o3 */; |
1454 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1455 | // CHECK-FIXES: {{^}} (void)(sv_ptr->empty()) /* o3 */; |
1456 | |
1457 | (void)((nullptr) == *sv_ptr) /* o4 */; |
1458 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1459 | // CHECK-FIXES: {{^}} (void)(sv_ptr->empty()) /* o4 */; |
1460 | } |
1461 | |
1462 | // Empty With Parens |
1463 | { |
1464 | (void)((*sv_ptr) == nullptr) /* o5 */; |
1465 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1466 | // CHECK-FIXES: {{^}} (void)(sv_ptr->empty()) /* o5 */; |
1467 | |
1468 | (void)((*sv_ptr) == (nullptr)) /* o6 */; |
1469 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1470 | // CHECK-FIXES: {{^}} (void)(sv_ptr->empty()) /* o6 */; |
1471 | |
1472 | (void)(nullptr == (*sv_ptr)) /* o7 */; |
1473 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1474 | // CHECK-FIXES: {{^}} (void)(sv_ptr->empty()) /* o7 */; |
1475 | |
1476 | (void)((nullptr) == (*sv_ptr)) /* o8 */; |
1477 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1478 | // CHECK-FIXES: {{^}} (void)(sv_ptr->empty()) /* o8 */; |
1479 | } |
1480 | |
1481 | // Non-Empty With Parens |
1482 | { |
1483 | (void)((*sv_ptr) != nullptr) /* o9 */; |
1484 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1485 | // CHECK-FIXES: {{^}} (void)(!sv_ptr->empty()) /* o9 */; |
1486 | |
1487 | (void)((*sv_ptr) != (nullptr)) /* o10 */; |
1488 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1489 | // CHECK-FIXES: {{^}} (void)(!sv_ptr->empty()) /* o10 */; |
1490 | |
1491 | (void)(nullptr != (*sv_ptr)) /* o11 */; |
1492 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1493 | // CHECK-FIXES: {{^}} (void)(!sv_ptr->empty()) /* o11 */; |
1494 | |
1495 | (void)((nullptr) != (*sv_ptr)) /* o12 */; |
1496 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1497 | // CHECK-FIXES: {{^}} (void)(!sv_ptr->empty()) /* o12 */; |
1498 | } |
1499 | |
1500 | // Non-Empty Without Parens |
1501 | { |
1502 | (void)((*sv_ptr) != nullptr) /* o13 */; |
1503 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1504 | // CHECK-FIXES: {{^}} (void)(!sv_ptr->empty()) /* o13 */; |
1505 | |
1506 | (void)((*sv_ptr) != (nullptr)) /* o14 */; |
1507 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1508 | // CHECK-FIXES: {{^}} (void)(!sv_ptr->empty()) /* o14 */; |
1509 | |
1510 | (void)(nullptr != (*sv_ptr)) /* o15 */; |
1511 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1512 | // CHECK-FIXES: {{^}} (void)(!sv_ptr->empty()) /* o15 */; |
1513 | |
1514 | (void)((nullptr) != (*sv_ptr)) /* o16 */; |
1515 | // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query |
1516 | // CHECK-FIXES: {{^}} (void)(!sv_ptr->empty()) /* o16 */; |
1517 | } |
1518 | } |
1519 | |
1520 | void equality_comparison_with_temporary(std::string_view sv) /* p */ { |
1521 | (void)(sv == std::string_view(nullptr)) /* p1 */; |
1522 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
1523 | // CHECK-FIXES: {{^}} (void)(sv == std::string_view()) /* p1 */; |
1524 | |
1525 | (void)(sv == std::string_view{nullptr}) /* p2 */; |
1526 | // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default |
1527 | // CHECK-FIXES: {{^}} (void)(sv == std::string_view{}) /* p2 */; |
1528 | |
1529 | (void)(sv == (std::string_view) nullptr) /* p3 */; |
1530 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
1531 | // CHECK-FIXES: {{^}} (void)(sv == (std::string_view) {}) /* p3 */; |
1532 | |
1533 | (void)(sv == (std::string_view){nullptr}) /* p4 */; |
1534 | // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default |
1535 | // CHECK-FIXES: {{^}} (void)(sv == (std::string_view){}) /* p4 */; |
1536 | |
1537 | (void)(sv == static_cast<SV>(nullptr)) /* p5 */; |
1538 | // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: casting{{.*}}empty string |
1539 | // CHECK-FIXES: {{^}} (void)(sv == static_cast<SV>("")) /* p5 */; |
1540 | } |
1541 | |
1542 | void return_statement() /* q */ { |
1543 | // Return Statement |
1544 | { |
1545 | []() -> SV { return nullptr; } /* q1 */; |
1546 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default |
1547 | // CHECK-FIXES: {{^}} []() -> SV { return {}; } /* q1 */; |
1548 | |
1549 | []() -> SV { return (nullptr); } /* q2 */; |
1550 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default |
1551 | // CHECK-FIXES: {{^}} []() -> SV { return {}; } /* q2 */; |
1552 | |
1553 | []() -> SV { return {nullptr}; } /* q3 */; |
1554 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default |
1555 | // CHECK-FIXES: {{^}} []() -> SV { return {}; } /* q3 */; |
1556 | |
1557 | []() -> SV { return {(nullptr)}; } /* q4 */; |
1558 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default |
1559 | // CHECK-FIXES: {{^}} []() -> SV { return {}; } /* q4 */; |
1560 | |
1561 | []() -> SV { return {{nullptr}}; } /* q5 */; |
1562 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default |
1563 | // CHECK-FIXES: {{^}} []() -> SV { return {}; } /* q5 */; |
1564 | |
1565 | []() -> SV { return {{(nullptr)}}; } /* q6 */; |
1566 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default |
1567 | // CHECK-FIXES: {{^}} []() -> SV { return {}; } /* q6 */; |
1568 | |
1569 | []() -> SV { return {{}}; } /* q7 */; // Default `const CharT*` |
1570 | // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default |
1571 | // CHECK-FIXES: {{^}} []() -> SV { return {}; } /* q7 */; |
1572 | } |
1573 | |
1574 | // Return Statement With Temporary |
1575 | { |
1576 | []() -> SV { return SV(nullptr); } /* q8 */; |
1577 | // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default |
1578 | // CHECK-FIXES: {{^}} []() -> SV { return SV(); } /* q8 */; |
1579 | |
1580 | []() -> SV { return SV{nullptr}; } /* q9 */; |
1581 | // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default |
1582 | // CHECK-FIXES: {{^}} []() -> SV { return SV{}; } /* q9 */; |
1583 | |
1584 | []() -> SV { return (SV) nullptr; } /* q10 */; |
1585 | // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: constructing{{.*}}default |
1586 | // CHECK-FIXES: {{^}} []() -> SV { return (SV) {}; } /* q10 */; |
1587 | |
1588 | []() -> SV { return (SV){nullptr}; } /* q11 */; |
1589 | // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: constructing{{.*}}default |
1590 | // CHECK-FIXES: {{^}} []() -> SV { return (SV){}; } /* q11 */; |
1591 | |
1592 | []() -> SV { return static_cast<SV>(nullptr); } /* q12 */; |
1593 | // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: casting{{.*}}empty string |
1594 | // CHECK-FIXES: {{^}} []() -> SV { return static_cast<SV>(""); } /* q12 */; |
1595 | } |
1596 | } |
1597 | |
1598 | void constructor_invocation() /* r */ { |
1599 | struct AcceptsSV { |
1600 | explicit AcceptsSV(std::string_view) {} |
1601 | } r1(nullptr); |
1602 | // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: passing{{.*}}empty string |
1603 | // CHECK-FIXES: {{^}} } r1(""); |
1604 | |
1605 | (void)(AcceptsSV{nullptr}) /* r2 */; |
1606 | // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: passing{{.*}}empty string |
1607 | // CHECK-FIXES: {{^}} (void)(AcceptsSV{""}) /* r2 */; |
1608 | |
1609 | AcceptsSV r3{nullptr}; |
1610 | // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: passing{{.*}}empty string |
1611 | // CHECK-FIXES: {{^}} AcceptsSV r3{""}; |
1612 | } |
1613 | |