brintos

brintos / llvm-project-archived public Read only

0
0
Text · 63.4 KiB · b85ba02 Raw
1639 lines · cpp
1// RUN: %check_clang_tidy %s bugprone-stringview-nullptr -std=c++17 %t2 3namespace std {4 5using size_t = long long;6using nullptr_t = decltype(nullptr);7 8template <typename T>9T &&declval();10 11template <typename T>12struct type_identity { using type = T; };13template <typename T>14using type_identity_t = typename type_identity<T>::type;15 16template <typename CharT>17class basic_string_view {18public: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 &) { return *this; }31};32 33template <typename CharT>34constexpr bool operator<(basic_string_view<CharT>, basic_string_view<CharT>) {35  return {};36}37template <typename CharT>38constexpr bool operator<(type_identity_t<basic_string_view<CharT>>,39                         basic_string_view<CharT>) {40  return {};41}42template <typename CharT>43constexpr bool operator<(basic_string_view<CharT>,44                         type_identity_t<basic_string_view<CharT>>) {45  return {};46}47 48template <typename CharT>49constexpr bool operator<=(basic_string_view<CharT>, basic_string_view<CharT>) {50  return {};51}52template <typename CharT>53constexpr bool operator<=(type_identity_t<basic_string_view<CharT>>,54                          basic_string_view<CharT>) {55  return {};56}57template <typename CharT>58constexpr bool operator<=(basic_string_view<CharT>,59                          type_identity_t<basic_string_view<CharT>>) {60  return {};61}62 63template <typename CharT>64constexpr bool operator>(basic_string_view<CharT>, basic_string_view<CharT>) {65  return {};66}67template <typename CharT>68constexpr bool operator>(type_identity_t<basic_string_view<CharT>>,69                         basic_string_view<CharT>) {70  return {};71}72template <typename CharT>73constexpr bool operator>(basic_string_view<CharT>,74                         type_identity_t<basic_string_view<CharT>>) {75  return {};76}77 78template <typename CharT>79constexpr bool operator>=(basic_string_view<CharT>, basic_string_view<CharT>) {80  return {};81}82template <typename CharT>83constexpr bool operator>=(type_identity_t<basic_string_view<CharT>>,84                          basic_string_view<CharT>) {85  return {};86}87template <typename CharT>88constexpr bool operator>=(basic_string_view<CharT>,89                          type_identity_t<basic_string_view<CharT>>) {90  return {};91}92 93template <typename CharT>94constexpr bool operator==(basic_string_view<CharT>, basic_string_view<CharT>) {95  return {};96}97template <typename CharT>98constexpr bool operator==(type_identity_t<basic_string_view<CharT>>,99                          basic_string_view<CharT>) {100  return {};101}102template <typename CharT>103constexpr bool operator==(basic_string_view<CharT>,104                          type_identity_t<basic_string_view<CharT>>) {105  return {};106}107 108template <typename CharT>109constexpr bool operator!=(basic_string_view<CharT>, basic_string_view<CharT>) {110  return {};111}112template <typename CharT>113constexpr bool operator!=(type_identity_t<basic_string_view<CharT>>,114                          basic_string_view<CharT>) {115  return {};116}117template <typename CharT>118constexpr bool operator!=(basic_string_view<CharT>,119                          type_identity_t<basic_string_view<CharT>>) {120  return {};121}122 123using string_view = basic_string_view<char>;124 125} // namespace std126 127using SV = std::string_view; // Used in some places for shorter line length128 129void function(std::string_view);130void function(std::string_view, std::string_view);131 132void temporary_construction() /* a */ {133  // Functional Cast134  {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 constructor137    // CHECK-FIXES: (void)(std::string_view()) /* a1 */;138 139    (void)(std::string_view((nullptr))) /* a2 */;140    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default141    // CHECK-FIXES: (void)(std::string_view()) /* a2 */;142 143    (void)(std::string_view({nullptr})) /* a3 */;144    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default145    // CHECK-FIXES: (void)(std::string_view()) /* a3 */;146 147    (void)(std::string_view({(nullptr)})) /* a4 */;148    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default149    // CHECK-FIXES: (void)(std::string_view()) /* a4 */;150 151    // Default `const CharT*`152    (void)(std::string_view({})) /* a5 */; 153    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default154    // CHECK-FIXES: (void)(std::string_view()) /* a5 */;155  }156 157  // Temporary Object158  {159    (void)(std::string_view{nullptr}) /* a6 */;160    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default161    // CHECK-FIXES: (void)(std::string_view{}) /* a6 */;162 163    (void)(std::string_view{(nullptr)}) /* a7 */;164    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default165    // CHECK-FIXES: (void)(std::string_view{}) /* a7 */;166 167    (void)(std::string_view{{nullptr}}) /* a8 */;168    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default169    // CHECK-FIXES: (void)(std::string_view{}) /* a8 */;170 171    (void)(std::string_view{{(nullptr)}}) /* a9 */;172    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default173    // CHECK-FIXES: (void)(std::string_view{}) /* a9 */;174 175    // Default `const CharT*`176    (void)(std::string_view{{}}) /* a10 */;177    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default178    // CHECK-FIXES: (void)(std::string_view{}) /* a10 */;179  }180 181  // C-Style Cast && Compound Literal182  {183    (void)((std::string_view) nullptr) /* a11 */;184    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default185    // CHECK-FIXES: (void)((std::string_view) {}) /* a11 */;186 187    (void)((std::string_view)(nullptr)) /* a12 */;188    // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: constructing{{.*}}default189    // CHECK-FIXES: (void)((std::string_view){}) /* a12 */;190 191    (void)((std::string_view){nullptr}) /* a13 */;192    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default193    // CHECK-FIXES: (void)((std::string_view){}) /* a13 */;194 195    (void)((std::string_view){(nullptr)}) /* a14 */;196    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default197    // CHECK-FIXES: (void)((std::string_view){}) /* a14 */;198 199    (void)((std::string_view){{nullptr}}) /* a15 */;200    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default201    // CHECK-FIXES: (void)((std::string_view){}) /* a15 */;202 203    (void)((std::string_view){{(nullptr)}}) /* a16 */;204    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default205    // CHECK-FIXES: (void)((std::string_view){}) /* a16 */;206 207    // Default `const CharT*`208    (void)((std::string_view){{}}) /* a17 */;209    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default210    // CHECK-FIXES: (void)((std::string_view){}) /* a17 */;211 212    (void)((const std::string_view) nullptr) /* a18 */;213    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default214    // CHECK-FIXES: (void)((const std::string_view) {}) /* a18 */;215 216    (void)((const std::string_view)(nullptr)) /* a19 */;217    // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: constructing{{.*}}default218    // CHECK-FIXES: (void)((const std::string_view){}) /* a19 */;219 220    (void)((const std::string_view){nullptr}) /* a20 */;221    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default222    // CHECK-FIXES: (void)((const std::string_view){}) /* a20 */;223 224    (void)((const std::string_view){(nullptr)}) /* a21 */;225    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default226    // CHECK-FIXES: (void)((const std::string_view){}) /* a21 */;227 228    (void)((const std::string_view){{nullptr}}) /* a22 */;229    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default230    // CHECK-FIXES: (void)((const std::string_view){}) /* a22 */;231 232    (void)((const std::string_view){{(nullptr)}}) /* a23 */;233    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default234    // CHECK-FIXES: (void)((const std::string_view){}) /* a23 */;235 236    // Default `const CharT*`237    (void)((const std::string_view){{}}) /* a24 */;238    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default239    // CHECK-FIXES: (void)((const std::string_view){}) /* a24 */;240  }241 242  // Static Cast243  {244    (void)(static_cast<std::string_view>(nullptr)) /* a25 */;245    // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting to basic_string_view from null is undefined; replace with the empty string246    // CHECK-FIXES: (void)(static_cast<std::string_view>("")) /* a25 */;247 248    (void)(static_cast<std::string_view>((nullptr))) /* a26 */;249    // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting{{.*}}empty string250    // CHECK-FIXES: (void)(static_cast<std::string_view>("")) /* a26 */;251 252    (void)(static_cast<const std::string_view>(nullptr)) /* a27 */;253    // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: casting{{.*}}empty string254    // CHECK-FIXES: (void)(static_cast<const std::string_view>("")) /* a27 */;255 256    (void)(static_cast<const std::string_view>((nullptr))) /* a28 */;257    // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: casting{{.*}}empty string258    // CHECK-FIXES: (void)(static_cast<const std::string_view>("")) /* a28 */;259  }260}261 262void stack_construction() /* b */ {263  // Copy Initialization264  {265    std::string_view b1 = nullptr;266    // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default267    // CHECK-FIXES: std::string_view b1 = {};268 269    std::string_view b2 = (nullptr);270    // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default271    // CHECK-FIXES: std::string_view b2 = {};272 273    const std::string_view b3 = nullptr;274    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default275    // CHECK-FIXES: const std::string_view b3 = {};276 277    const std::string_view b4 = (nullptr);278    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default279    // CHECK-FIXES: const std::string_view b4 = {};280  }281 282  // Copy Initialization With Temporary283  {284    std::string_view b5 = std::string_view(nullptr);285    // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default286    // CHECK-FIXES: std::string_view b5 = std::string_view();287 288    std::string_view b6 = std::string_view{nullptr};289    // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default290    // CHECK-FIXES: std::string_view b6 = std::string_view{};291 292    std::string_view b7 = (std::string_view) nullptr;293    // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default294    // CHECK-FIXES: std::string_view b7 = (std::string_view) {};295 296    std::string_view b8 = (std::string_view){nullptr};297    // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default298    // CHECK-FIXES: std::string_view b8 = (std::string_view){};299 300    std::string_view b9 = static_cast<SV>(nullptr);301    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: casting{{.*}}empty string302    // CHECK-FIXES: std::string_view b9 = static_cast<SV>("");303  }304 305  // Copy List Initialization306  {307    std::string_view b10 = {nullptr};308    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default309    // CHECK-FIXES: std::string_view b10 = {};310 311    std::string_view b11 = {(nullptr)};312    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default313    // CHECK-FIXES: std::string_view b11 = {};314 315    std::string_view b12 = {{nullptr}};316    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default317    // CHECK-FIXES: std::string_view b12 = {};318 319    std::string_view b13 = {{(nullptr)}};320    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default321    // CHECK-FIXES: std::string_view b13 = {};322 323    // Default `const CharT*`324    std::string_view b14 = {{}};325    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default326    // CHECK-FIXES: std::string_view b14 = {};327 328    const std::string_view b15 = {nullptr};329    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default330    // CHECK-FIXES: const std::string_view b15 = {};331 332    const std::string_view b16 = {(nullptr)};333    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default334    // CHECK-FIXES: const std::string_view b16 = {};335 336    const std::string_view b17 = {{nullptr}};337    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default338    // CHECK-FIXES: const std::string_view b17 = {};339 340    const std::string_view b18 = {{(nullptr)}};341    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default342    // CHECK-FIXES: const std::string_view b18 = {};343 344    // Default `const CharT*`345    const std::string_view b19 = {{}};346    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default347    // CHECK-FIXES: const std::string_view b19 = {};348  }349 350  // Copy List Initialization With Temporary351  {352    std::string_view b20 = {std::string_view(nullptr)};353    // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default354    // CHECK-FIXES: std::string_view b20 = {std::string_view()};355 356    std::string_view b21 = {std::string_view{nullptr}};357    // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default358    // CHECK-FIXES: std::string_view b21 = {std::string_view{}};359 360    std::string_view b22 = {(std::string_view) nullptr};361    // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default362    // CHECK-FIXES: std::string_view b22 = {(std::string_view) {}};363 364    std::string_view b23 = {(std::string_view){nullptr}};365    // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default366    // CHECK-FIXES: std::string_view b23 = {(std::string_view){}};367 368    std::string_view b24 = {static_cast<SV>(nullptr)};369    // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: casting{{.*}}empty string370    // CHECK-FIXES: std::string_view b24 = {static_cast<SV>("")};371  }372 373  // Direct Initialization374  {375    std::string_view b25(nullptr);376    // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default377    // CHECK-FIXES: std::string_view b25;378 379    std::string_view b26((nullptr));380    // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default381    // CHECK-FIXES: std::string_view b26;382 383    std::string_view b27({nullptr});384    // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default385    // CHECK-FIXES: std::string_view b27;386 387    std::string_view b28({(nullptr)});388    // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default389    // CHECK-FIXES: std::string_view b28;390 391    // Default `const CharT*`392    std::string_view b29({});393    // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default394    // CHECK-FIXES: std::string_view b29;395 396    const std::string_view b30(nullptr);397    // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default398    // CHECK-FIXES: const std::string_view b30;399 400    const std::string_view b31((nullptr));401    // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default402    // CHECK-FIXES: const std::string_view b31;403 404    const std::string_view b32({nullptr});405    // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default406    // CHECK-FIXES: const std::string_view b32;407 408    const std::string_view b33({(nullptr)});409    // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default410    // CHECK-FIXES: const std::string_view b33;411 412    // Default `const CharT*`413    const std::string_view b34({});414    // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default415    // CHECK-FIXES: const std::string_view b34;416  }417 418  // Direct Initialization With Temporary419  {420    std::string_view b35(std::string_view(nullptr));421    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default422    // CHECK-FIXES: std::string_view b35(std::string_view());423 424    std::string_view b36(std::string_view{nullptr});425    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default426    // CHECK-FIXES: std::string_view b36(std::string_view{});427 428    std::string_view b37((std::string_view) nullptr);429    // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default430    // CHECK-FIXES: std::string_view b37((std::string_view) {});431 432    std::string_view b38((std::string_view){nullptr});433    // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default434    // CHECK-FIXES: std::string_view b38((std::string_view){});435 436    std::string_view b39(static_cast<SV>(nullptr));437    // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting{{.*}}empty string438    // CHECK-FIXES: std::string_view b39(static_cast<SV>(""));439  }440 441  // Direct List Initialization442  {443    std::string_view b40{nullptr};444    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default445    // CHECK-FIXES: std::string_view b40{};446 447    std::string_view b41{(nullptr)};448    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default449    // CHECK-FIXES: std::string_view b41{};450 451    std::string_view b42{{nullptr}};452    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default453    // CHECK-FIXES: std::string_view b42{};454 455    std::string_view b43{{(nullptr)}};456    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default457    // CHECK-FIXES: std::string_view b43{};458 459    // Default `const CharT*`460    std::string_view b44{{}};461    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default462    // CHECK-FIXES: std::string_view b44{};463 464    const std::string_view b45{nullptr};465    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default466    // CHECK-FIXES: const std::string_view b45{};467 468    const std::string_view b46{(nullptr)};469    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default470    // CHECK-FIXES: const std::string_view b46{};471 472    const std::string_view b47{{nullptr}};473    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default474    // CHECK-FIXES: const std::string_view b47{};475 476    const std::string_view b48{{(nullptr)}};477    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default478    // CHECK-FIXES: const std::string_view b48{};479 480    // Default `const CharT*`481    const std::string_view b49{{}};482    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default483    // CHECK-FIXES: const std::string_view b49{};484  }485 486  // Direct List Initialization With Temporary487  {488    std::string_view b50{std::string_view(nullptr)};489    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default490    // CHECK-FIXES: std::string_view b50{std::string_view()};491 492    std::string_view b51{std::string_view{nullptr}};493    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default494    // CHECK-FIXES: std::string_view b51{std::string_view{}};495 496    std::string_view b52{(std::string_view) nullptr};497    // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default498    // CHECK-FIXES: std::string_view b52{(std::string_view) {}};499 500    std::string_view b53{(std::string_view){nullptr}};501    // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default502    // CHECK-FIXES: std::string_view b53{(std::string_view){}};503 504    std::string_view b54{static_cast<SV>(nullptr)};505    // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting{{.*}}empty string506    // CHECK-FIXES: std::string_view b54{static_cast<SV>("")};507  }508}509 510void field_construction() /* c */ {511  // Default Member Initializaers512 513  struct DMICopyInitialization {514    std::string_view c1 = nullptr;515    // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default516    // CHECK-FIXES: std::string_view c1 = {};517 518    std::string_view c2 = (nullptr);519    // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default520    // CHECK-FIXES: std::string_view c2 = {};521 522    const std::string_view c3 = nullptr;523    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default524    // CHECK-FIXES: const std::string_view c3 = {};525 526    const std::string_view c4 = (nullptr);527    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default528    // CHECK-FIXES: const std::string_view c4 = {};529  };530 531  struct DMICopyInitializationWithTemporary {532    std::string_view c5 = std::string_view(nullptr);533    // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default534    // CHECK-FIXES: std::string_view c5 = std::string_view();535 536    std::string_view c6 = std::string_view{nullptr};537    // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default538    // CHECK-FIXES: std::string_view c6 = std::string_view{};539 540    std::string_view c7 = (std::string_view) nullptr;541    // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default542    // CHECK-FIXES: std::string_view c7 = (std::string_view) {};543 544    std::string_view c8 = (std::string_view){nullptr};545    // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default546    // CHECK-FIXES: std::string_view c8 = (std::string_view){};547 548    std::string_view c9 = static_cast<SV>(nullptr);549    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: casting{{.*}}empty string550    // CHECK-FIXES: std::string_view c9 = static_cast<SV>("");551  };552 553  struct DMICopyListInitialization {554    std::string_view c10 = {nullptr};555    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default556    // CHECK-FIXES: std::string_view c10 = {};557 558    std::string_view c11 = {(nullptr)};559    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default560    // CHECK-FIXES: std::string_view c11 = {};561 562    std::string_view c12 = {{nullptr}};563    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default564    // CHECK-FIXES: std::string_view c12 = {};565 566    std::string_view c13 = {{(nullptr)}};567    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default568    // CHECK-FIXES: std::string_view c13 = {};569 570    // Default `const CharT*`571    std::string_view c14 = {{}};572    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default573    // CHECK-FIXES: std::string_view c14 = {};574 575    const std::string_view c15 = {nullptr};576    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default577    // CHECK-FIXES: const std::string_view c15 = {};578 579    const std::string_view c16 = {(nullptr)};580    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default581    // CHECK-FIXES: const std::string_view c16 = {};582 583    const std::string_view c17 = {{nullptr}};584    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default585    // CHECK-FIXES: const std::string_view c17 = {};586 587    const std::string_view c18 = {{(nullptr)}};588    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default589    // CHECK-FIXES: const std::string_view c18 = {};590 591    // Default `const CharT*`592    const std::string_view c19 = {{}};593    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default594    // CHECK-FIXES: const std::string_view c19 = {};595  };596 597  struct DMICopyListInitializationWithTemporary {598    std::string_view c20 = {std::string_view(nullptr)};599    // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default600    // CHECK-FIXES: std::string_view c20 = {std::string_view()};601 602    std::string_view c21 = {std::string_view{nullptr}};603    // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: constructing{{.*}}default604    // CHECK-FIXES: std::string_view c21 = {std::string_view{}};605 606    std::string_view c22 = {(std::string_view) nullptr};607    // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default608    // CHECK-FIXES: std::string_view c22 = {(std::string_view) {}};609 610    std::string_view c23 = {(std::string_view){nullptr}};611    // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default612    // CHECK-FIXES: std::string_view c23 = {(std::string_view){}};613 614    std::string_view c24 = {static_cast<SV>(nullptr)};615    // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: casting{{.*}}empty string616    // CHECK-FIXES: std::string_view c24 = {static_cast<SV>("")};617  };618 619  struct DMIDirectListInitialization {620    std::string_view c25{nullptr};621    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default622    // CHECK-FIXES: std::string_view c25{};623 624    std::string_view c26{(nullptr)};625    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default626    // CHECK-FIXES: std::string_view c26{};627 628    std::string_view c27{{nullptr}};629    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default630    // CHECK-FIXES: std::string_view c27{};631 632    std::string_view c28{{(nullptr)}};633    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default634    // CHECK-FIXES: std::string_view c28{};635 636    // Default `const CharT*`637    std::string_view c29{{}};638    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default639    // CHECK-FIXES: std::string_view c29{};640 641    const std::string_view c30{nullptr};642    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default643    // CHECK-FIXES: const std::string_view c30{};644 645    const std::string_view c31{(nullptr)};646    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default647    // CHECK-FIXES: const std::string_view c31{};648 649    const std::string_view c32{{nullptr}};650    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default651    // CHECK-FIXES: const std::string_view c32{};652 653    const std::string_view c33{{(nullptr)}};654    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default655    // CHECK-FIXES: const std::string_view c33{};656 657    // Default `const CharT*`658    const std::string_view c34{{}};659    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default660    // CHECK-FIXES: const std::string_view c34{};661  };662 663  struct DMIDirectListInitializationWithTemporary {664    std::string_view c35{std::string_view(nullptr)};665    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default666    // CHECK-FIXES: std::string_view c35{std::string_view()};667 668    std::string_view c36{std::string_view{nullptr}};669    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default670    // CHECK-FIXES: std::string_view c36{std::string_view{}};671 672    std::string_view c37{(std::string_view) nullptr};673    // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default674    // CHECK-FIXES: std::string_view c37{(std::string_view) {}};675 676    std::string_view c38{(std::string_view){nullptr}};677    // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: constructing{{.*}}default678    // CHECK-FIXES: std::string_view c38{(std::string_view){}};679 680    std::string_view c39{static_cast<SV>(nullptr)};681    // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: casting{{.*}}empty string682    // CHECK-FIXES: std::string_view c39{static_cast<SV>("")};683  };684 685  // Constructor Initializers686 687  class CIDirectInitialization {688    std::string_view c40;689    std::string_view c41;690    std::string_view c42;691    std::string_view c43;692    std::string_view c44;693 694    CIDirectInitialization()695        : c40(nullptr),696          // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default697          // CHECK-FIXES: : c40(),698 699          c41((nullptr)),700          // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default701          // CHECK-FIXES: c41(),702 703          c42({nullptr}),704          // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default705          // CHECK-FIXES: c42(),706 707          c43({(nullptr)}),708          // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default709          // CHECK-FIXES: c43(),710 711          // Default `const CharT*`712          c44({}) {713      // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default714      // CHECK-FIXES: c44() {715    }716  };717 718  class CIDirectInitializationWithTemporary {719    std::string_view c45;720    std::string_view c46;721    std::string_view c47;722    std::string_view c48;723    std::string_view c49;724 725    CIDirectInitializationWithTemporary()726        : c45(std::string_view(nullptr)),727          // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default728          // CHECK-FIXES: : c45(std::string_view()),729 730          c46(std::string_view{nullptr}),731          // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default732          // CHECK-FIXES: c46(std::string_view{}),733 734          c47((std::string_view) nullptr),735          // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default736          // CHECK-FIXES: c47((std::string_view) {}),737 738          c48((std::string_view){nullptr}),739          // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default740          // CHECK-FIXES: c48((std::string_view){}),741 742          c49(static_cast<SV>(nullptr)) {743      // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: casting{{.*}}empty string744      // CHECK-FIXES: c49(static_cast<SV>("")) {745    }746  };747 748  class CIDirectListInitialization {749    std::string_view c50;750    std::string_view c51;751    std::string_view c52;752    std::string_view c53;753    std::string_view c54;754 755    CIDirectListInitialization()756        : c50{nullptr},757          // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default758          // CHECK-FIXES: : c50{},759 760          c51{(nullptr)},761          // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default762          // CHECK-FIXES: c51{},763 764          c52{{nullptr}},765          // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default766          // CHECK-FIXES: c52{},767 768          c53{{(nullptr)}},769          // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default770          // CHECK-FIXES: c53{},771 772          // Default `const CharT*`773          c54{{}} {774      // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default775      // CHECK-FIXES: c54{} {776    }777  };778 779  class CIDirectListInitializationWithTemporary {780    std::string_view c55;781    std::string_view c56;782    std::string_view c57;783    std::string_view c58;784    std::string_view c59;785 786    CIDirectListInitializationWithTemporary()787        : c55{std::string_view(nullptr)},788          // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default789          // CHECK-FIXES: : c55{std::string_view()},790 791          c56{std::string_view{nullptr}},792          // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default793          // CHECK-FIXES: c56{std::string_view{}},794 795          c57{(std::string_view) nullptr},796          // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default797          // CHECK-FIXES: c57{(std::string_view) {}},798 799          c58{(std::string_view){nullptr}},800          // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default801          // CHECK-FIXES: c58{(std::string_view){}},802 803          c59{static_cast<SV>(nullptr)} {804      // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: casting{{.*}}empty string805      // CHECK-FIXES: c59{static_cast<SV>("")} {806    }807  };808}809 810void default_argument_construction() /* d */ {811  // Copy Initialization812  {813    void d1(std::string_view sv = nullptr);814    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default815    // CHECK-FIXES: void d1(std::string_view sv = {});816 817    void d2(std::string_view sv = (nullptr));818    // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default819    // CHECK-FIXES: void d2(std::string_view sv = {});820 821    void d3(const std::string_view sv = nullptr);822    // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: constructing{{.*}}default823    // CHECK-FIXES: void d3(const std::string_view sv = {});824 825    void d4(const std::string_view sv = (nullptr));826    // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: constructing{{.*}}default827    // CHECK-FIXES: void d4(const std::string_view sv = {});828  }829 830  // Copy Initialization With Temporary831  {832    void d5(std::string_view sv = std::string_view(nullptr));833    // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default834    // CHECK-FIXES: void d5(std::string_view sv = std::string_view());835 836    void d6(std::string_view sv = std::string_view{nullptr});837    // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default838    // CHECK-FIXES: void d6(std::string_view sv = std::string_view{});839 840    void d7(std::string_view sv = (std::string_view) nullptr);841    // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: constructing{{.*}}default842    // CHECK-FIXES: void d7(std::string_view sv = (std::string_view) {});843 844    void d8(std::string_view sv = (std::string_view){nullptr});845    // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: constructing{{.*}}default846    // CHECK-FIXES: void d8(std::string_view sv = (std::string_view){});847 848    void d9(std::string_view sv = static_cast<SV>(nullptr));849    // CHECK-MESSAGES: :[[@LINE-1]]:51: warning: casting{{.*}}empty string850    // CHECK-FIXES: void d9(std::string_view sv = static_cast<SV>(""));851  }852 853  // Copy List Initialization854  {855    void d10(std::string_view sv = {nullptr});856    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default857    // CHECK-FIXES: void d10(std::string_view sv = {});858 859    void d11(std::string_view sv = {(nullptr)});860    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default861    // CHECK-FIXES: void d11(std::string_view sv = {});862 863    void d12(std::string_view sv = {{nullptr}});864    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default865    // CHECK-FIXES: void d12(std::string_view sv = {});866 867    void d13(std::string_view sv = {{(nullptr)}});868    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default869    // CHECK-FIXES: void d13(std::string_view sv = {});870 871    // Default `const CharT*`872    void d14(std::string_view sv = {{}});873    // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default874    // CHECK-FIXES: void d14(std::string_view sv = {});875 876    void d15(const std::string_view sv = {nullptr});877    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default878    // CHECK-FIXES: void d15(const std::string_view sv = {});879 880    void d16(const std::string_view sv = {(nullptr)});881    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default882    // CHECK-FIXES: void d16(const std::string_view sv = {});883 884    void d17(const std::string_view sv = {{nullptr}});885    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default886    // CHECK-FIXES: void d17(const std::string_view sv = {});887 888    void d18(const std::string_view sv = {{(nullptr)}});889    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default890    // CHECK-FIXES: void d18(const std::string_view sv = {});891 892    // Default `const CharT*`893    void d19(const std::string_view sv = {{}});894    // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default895    // CHECK-FIXES: void d19(const std::string_view sv = {});896  }897 898  // Copy List Initialization With Temporary899  {900    void d20(std::string_view sv = {std::string_view(nullptr)});901    // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: constructing{{.*}}default902    // CHECK-FIXES: void d20(std::string_view sv = {std::string_view()});903 904    void d21(std::string_view sv = {std::string_view{nullptr}});905    // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: constructing{{.*}}default906    // CHECK-FIXES: void d21(std::string_view sv = {std::string_view{}});907 908    void d22(std::string_view sv = {(std::string_view) nullptr});909    // CHECK-MESSAGES: :[[@LINE-1]]:56: warning: constructing{{.*}}default910    // CHECK-FIXES: void d22(std::string_view sv = {(std::string_view) {}});911 912    void d23(std::string_view sv = {(std::string_view){nullptr}});913    // CHECK-MESSAGES: :[[@LINE-1]]:56: warning: constructing{{.*}}default914    // CHECK-FIXES: void d23(std::string_view sv = {(std::string_view){}});915 916    void d24(std::string_view sv = {static_cast<SV>(nullptr)});917    // CHECK-MESSAGES: :[[@LINE-1]]:53: warning: casting{{.*}}empty string918    // CHECK-FIXES: void d24(std::string_view sv = {static_cast<SV>("")});919  }920}921 922void heap_construction() /* e */ {923  // Direct Initialization924  {925    (void)(new std::string_view(nullptr)) /* e1 */;926    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default927    // CHECK-FIXES: (void)(new std::string_view()) /* e1 */;928 929    (void)(new std::string_view((nullptr))) /* e2 */;930    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default931    // CHECK-FIXES: (void)(new std::string_view()) /* e2 */;932 933    (void)(new std::string_view({nullptr})) /* e3 */;934    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default935    // CHECK-FIXES: (void)(new std::string_view()) /* e3 */;936 937    (void)(new std::string_view({(nullptr)})) /* e4 */;938    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default939    // CHECK-FIXES: (void)(new std::string_view()) /* e4 */;940 941    // Default `const CharT*`942    (void)(new std::string_view({})) /* e5 */;943    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default944    // CHECK-FIXES: (void)(new std::string_view()) /* e5 */;945 946    (void)(new const std::string_view(nullptr)) /* e6 */;947    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default948    // CHECK-FIXES: (void)(new const std::string_view()) /* e6 */;949 950    (void)(new const std::string_view((nullptr))) /* e7 */;951    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default952    // CHECK-FIXES: (void)(new const std::string_view()) /* e7 */;953 954    (void)(new const std::string_view({nullptr})) /* e8 */;955    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default956    // CHECK-FIXES: (void)(new const std::string_view()) /* e8 */;957 958    (void)(new const std::string_view({(nullptr)})) /* e9 */;959    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default960    // CHECK-FIXES: (void)(new const std::string_view()) /* e9 */;961 962    // Default `const CharT*`963    (void)(new const std::string_view({})) /* e10 */;964    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default965    // CHECK-FIXES: (void)(new const std::string_view()) /* e10 */;966  }967 968  // Direct Initialization With Temporary969  {970    (void)(new std::string_view(std::string_view(nullptr))) /* e11 */;971    // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: constructing{{.*}}default972    // CHECK-FIXES: (void)(new std::string_view(std::string_view())) /* e11 */;973 974    (void)(new std::string_view(std::string_view{nullptr})) /* e12 */;975    // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: constructing{{.*}}default976    // CHECK-FIXES: (void)(new std::string_view(std::string_view{})) /* e12 */;977 978    (void)(new std::string_view((std::string_view) nullptr)) /* e13 */;979    // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default980    // CHECK-FIXES: (void)(new std::string_view((std::string_view) {})) /* e13 */;981 982    (void)(new std::string_view((std::string_view){nullptr})) /* e14 */;983    // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default984    // CHECK-FIXES: (void)(new std::string_view((std::string_view){})) /* e14 */;985 986    (void)(new std::string_view(static_cast<SV>(nullptr))) /* e15 */;987    // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: casting{{.*}}empty string988    // CHECK-FIXES: (void)(new std::string_view(static_cast<SV>(""))) /* e15 */;989  }990 991  // Direct List Initialization992  {993    (void)(new std::string_view{nullptr}) /* e16 */;994    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default995    // CHECK-FIXES: (void)(new std::string_view{}) /* e16 */;996 997    (void)(new std::string_view{(nullptr)}) /* e17 */;998    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default999    // CHECK-FIXES: (void)(new std::string_view{}) /* e17 */;1000 1001    (void)(new std::string_view{{nullptr}}) /* e18 */;1002    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default1003    // CHECK-FIXES: (void)(new std::string_view{}) /* e18 */;1004 1005    (void)(new std::string_view{{(nullptr)}}) /* e19 */;1006    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default1007    // CHECK-FIXES: (void)(new std::string_view{}) /* e19 */;1008 1009    // Default `const CharT*`1010    (void)(new std::string_view{{}}) /* e20 */;1011    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default1012    // CHECK-FIXES: (void)(new std::string_view{}) /* e20 */;1013 1014    (void)(new const std::string_view{nullptr}) /* e21 */;1015    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default1016    // CHECK-FIXES: (void)(new const std::string_view{}) /* e21 */;1017 1018    (void)(new const std::string_view{(nullptr)}) /* e22 */;1019    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default1020    // CHECK-FIXES: (void)(new const std::string_view{}) /* e22 */;1021 1022    (void)(new const std::string_view{{nullptr}}) /* e23 */;1023    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default1024    // CHECK-FIXES: (void)(new const std::string_view{}) /* e23 */;1025 1026    (void)(new const std::string_view{{(nullptr)}}) /* e24 */;1027    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default1028    // CHECK-FIXES: (void)(new const std::string_view{}) /* e24 */;1029 1030    // Default `const CharT*`1031    (void)(new const std::string_view{{}}) /* e25 */;1032    // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default1033    // CHECK-FIXES: (void)(new const std::string_view{}) /* e25 */;1034  }1035 1036  // Direct List Initialization With Temporary1037  {1038    (void)(new std::string_view{std::string_view(nullptr)}) /* e26 */;1039    // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: constructing{{.*}}default1040    // CHECK-FIXES: (void)(new std::string_view{std::string_view()}) /* e26 */;1041 1042    (void)(new std::string_view{std::string_view{nullptr}}) /* e27 */;1043    // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: constructing{{.*}}default1044    // CHECK-FIXES: (void)(new std::string_view{std::string_view{}}) /* e27 */;1045 1046    (void)(new std::string_view{(std::string_view) nullptr}) /* e28 */;1047    // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default1048    // CHECK-FIXES: (void)(new std::string_view{(std::string_view) {}}) /* e28 */;1049 1050    (void)(new std::string_view{(std::string_view){nullptr}}) /* e29 */;1051    // CHECK-MESSAGES: :[[@LINE-1]]:52: warning: constructing{{.*}}default1052    // CHECK-FIXES: (void)(new std::string_view{(std::string_view){}}) /* e29 */;1053 1054    (void)(new std::string_view{static_cast<SV>(nullptr)}) /* e30 */;1055    // CHECK-MESSAGES: :[[@LINE-1]]:49: warning: casting{{.*}}empty string1056    // CHECK-FIXES: (void)(new std::string_view{static_cast<SV>("")}) /* e30 */;1057  }1058}1059 1060void function_argument_initialization() /* f */ {1061  // Function Argument Initialization1062  {1063    function(nullptr) /* f1 */;1064    // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing null as basic_string_view is undefined; replace with the empty string1065    // CHECK-FIXES: function("") /* f1 */;1066 1067    function((nullptr)) /* f2 */;1068    // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string1069    // CHECK-FIXES: function("") /* f2 */;1070 1071    function({nullptr}) /* f3 */;1072    // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string1073    // CHECK-FIXES: function("") /* f3 */;1074 1075    function({(nullptr)}) /* f4 */;1076    // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string1077    // CHECK-FIXES: function("") /* f4 */;1078 1079    // Default `const CharT*`1080    function({{}}) /* f5 */;1081    // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string1082    // CHECK-FIXES: function("") /* f5 */;1083  }1084 1085  // Function Argument Initialization With Temporary1086  {1087    function(std::string_view(nullptr)) /* f6 */;1088    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default1089    // CHECK-FIXES: function(std::string_view()) /* f6 */;1090 1091    function(std::string_view{nullptr}) /* f7 */;1092    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default1093    // CHECK-FIXES: function(std::string_view{}) /* f7 */;1094 1095    function((std::string_view) nullptr) /* f8 */;1096    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default1097    // CHECK-FIXES: function((std::string_view) {}) /* f8 */;1098 1099    function((std::string_view){nullptr}) /* f9 */;1100    // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default1101    // CHECK-FIXES: function((std::string_view){}) /* f9 */;1102 1103    function(static_cast<SV>(nullptr)) /* f10 */;1104    // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: casting{{.*}}empty string1105    // CHECK-FIXES: function(static_cast<SV>("")) /* f10 */;1106  }1107}1108 1109void assignment(std::string_view sv) /* g */ {1110  // Assignment1111  {1112    sv = nullptr /* g1 */;1113    // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment to basic_string_view from null is undefined; replace with the default constructor1114    // CHECK-FIXES: sv = {} /* g1 */;1115 1116    sv = (nullptr) /* g2 */;1117    // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default1118    // CHECK-FIXES: sv = {} /* g2 */;1119 1120    sv = {nullptr} /* g3 */;1121    // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default1122    // CHECK-FIXES: sv = {} /* g3 */;1123 1124    sv = {(nullptr)} /* g4 */;1125    // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default1126    // CHECK-FIXES: sv = {} /* g4 */;1127 1128    // Default `const CharT*`1129    sv = {{}} /* g5 */;1130    // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default1131    // CHECK-FIXES: sv = {} /* g5 */;1132  }1133 1134  // Assignment With Temporary1135  {1136    sv = std::string_view(nullptr) /* g6 */;1137    // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default1138    // CHECK-FIXES: sv = std::string_view() /* g6 */;1139 1140    sv = std::string_view{nullptr} /* g7 */;1141    // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: constructing{{.*}}default1142    // CHECK-FIXES: sv = std::string_view{} /* g7 */;1143 1144    sv = (std::string_view) nullptr /* g8 */;1145    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default1146    // CHECK-FIXES: sv = (std::string_view) {} /* g8 */;1147 1148    sv = (std::string_view){nullptr} /* g9 */;1149    // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default1150    // CHECK-FIXES: sv = (std::string_view){} /* g9 */;1151 1152    sv = static_cast<SV>(nullptr) /* g10 */;1153    // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: casting{{.*}}empty string1154    // CHECK-FIXES: sv = static_cast<SV>("") /* g10 */;1155  }1156}1157 1158void pointer_assignment(std::string_view *sv_ptr) /* h */ {1159  // Assignment1160  {1161    *sv_ptr = nullptr /* h1 */;1162    // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default1163    // CHECK-FIXES: *sv_ptr = {} /* h1 */;1164 1165    *sv_ptr = (nullptr) /* h2 */;1166    // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default1167    // CHECK-FIXES: *sv_ptr = {} /* h2 */;1168 1169    *sv_ptr = {nullptr} /* h3 */;1170    // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default1171    // CHECK-FIXES: *sv_ptr = {} /* h3 */;1172 1173    *sv_ptr = {(nullptr)} /* h4 */;1174    // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default1175    // CHECK-FIXES: *sv_ptr = {} /* h4 */;1176 1177    // Default `const CharT*`1178    *sv_ptr = {{}} /* h5 */;1179    // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default1180    // CHECK-FIXES: *sv_ptr = {} /* h5 */;1181  }1182 1183  // Assignment With Temporary1184  {1185    *sv_ptr = std::string_view(nullptr) /* h6 */;1186    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default1187    // CHECK-FIXES: *sv_ptr = std::string_view() /* h6 */;1188 1189    *sv_ptr = std::string_view{nullptr} /* h7 */;1190    // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default1191    // CHECK-FIXES: *sv_ptr = std::string_view{} /* h7 */;1192 1193    *sv_ptr = (std::string_view) nullptr /* h8 */;1194    // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default1195    // CHECK-FIXES: *sv_ptr = (std::string_view) {} /* h8 */;1196 1197    *sv_ptr = (std::string_view){nullptr} /* h9 */;1198    // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default1199    // CHECK-FIXES: *sv_ptr = (std::string_view){} /* h9 */;1200 1201    *sv_ptr = static_cast<SV>(nullptr) /* h10 */;1202    // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: casting{{.*}}empty string1203    // CHECK-FIXES: *sv_ptr = static_cast<SV>("") /* h10 */;1204  }1205}1206 1207void lesser_comparison(std::string_view sv) /* i */ {1208  // Without Equality1209  {1210    (void)(sv < nullptr) /* i1 */;1211    // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: comparing basic_string_view to null is undefined; replace with the empty string1212    // CHECK-FIXES: (void)(sv < "") /* i1 */;1213 1214    (void)(sv < (nullptr)) /* i2 */;1215    // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: comparing{{.*}}empty string1216    // CHECK-FIXES: (void)(sv < "") /* i2 */;1217 1218    (void)(nullptr < sv) /* i3 */;1219    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1220    // CHECK-FIXES: (void)("" < sv) /* i3 */;1221 1222    (void)((nullptr) < sv) /* i4 */;1223    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1224    // CHECK-FIXES: (void)("" < sv) /* i4 */;1225  }1226 1227  // With Equality1228  {1229    (void)(sv <= nullptr) /* i5 */;1230    // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: comparing{{.*}}empty string1231    // CHECK-FIXES: (void)(sv <= "") /* i5 */;1232 1233    (void)(sv <= (nullptr)) /* i6 */;1234    // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: comparing{{.*}}empty string1235    // CHECK-FIXES: (void)(sv <= "") /* i6 */;1236 1237    (void)(nullptr <= sv) /* i7 */;1238    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1239    // CHECK-FIXES: (void)("" <= sv) /* i7 */;1240 1241    (void)((nullptr) <= sv) /* i8 */;1242    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1243    // CHECK-FIXES: (void)("" <= sv) /* i8 */;1244  }1245}1246 1247void pointer_lesser_comparison(std::string_view *sv_ptr) /* j */ {1248  // Without Equality1249  {1250    (void)(*sv_ptr < nullptr) /* j1 */;1251    // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: comparing{{.*}}empty string1252    // CHECK-FIXES: (void)(*sv_ptr < "") /* j1 */;1253 1254    (void)(*sv_ptr < (nullptr)) /* j2 */;1255    // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: comparing{{.*}}empty string1256    // CHECK-FIXES: (void)(*sv_ptr < "") /* j2 */;1257 1258    (void)(nullptr < *sv_ptr) /* j3 */;1259    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1260    // CHECK-FIXES: (void)("" < *sv_ptr) /* j3 */;1261 1262    (void)((nullptr) < *sv_ptr) /* j4 */;1263    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1264    // CHECK-FIXES: (void)("" < *sv_ptr) /* j4 */;1265  }1266 1267  // With Equality1268  {1269    (void)(*sv_ptr <= nullptr) /* j5 */;1270    // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: comparing{{.*}}empty string1271    // CHECK-FIXES: (void)(*sv_ptr <= "") /* j5 */;1272 1273    (void)(*sv_ptr <= (nullptr)) /* j6 */;1274    // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: comparing{{.*}}empty string1275    // CHECK-FIXES: (void)(*sv_ptr <= "") /* j6 */;1276 1277    (void)(nullptr <= *sv_ptr) /* j7 */;1278    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1279    // CHECK-FIXES: (void)("" <= *sv_ptr) /* j7 */;1280 1281    (void)((nullptr) <= *sv_ptr) /* j8 */;1282    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1283    // CHECK-FIXES: (void)("" <= *sv_ptr) /* j8 */;1284  }1285}1286 1287void greater_comparison(std::string_view sv) /* k */ {1288  // Without Equality1289  {1290    (void)(sv > nullptr) /* k1 */;1291    // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: comparing{{.*}}empty string1292    // CHECK-FIXES: (void)(sv > "") /* k1 */;1293 1294    (void)(sv > (nullptr)) /* k2 */;1295    // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: comparing{{.*}}empty string1296    // CHECK-FIXES: (void)(sv > "") /* k2 */;1297 1298    (void)(nullptr > sv) /* k3 */;1299    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1300    // CHECK-FIXES: (void)("" > sv) /* k3 */;1301 1302    (void)((nullptr) > sv) /* k4 */;1303    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1304    // CHECK-FIXES: (void)("" > sv) /* k4 */;1305  }1306 1307  // With Equality1308  {1309    (void)(sv >= nullptr) /* k5 */;1310    // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: comparing{{.*}}empty string1311    // CHECK-FIXES: (void)(sv >= "") /* k5 */;1312 1313    (void)(sv >= (nullptr)) /* k6 */;1314    // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: comparing{{.*}}empty string1315    // CHECK-FIXES: (void)(sv >= "") /* k6 */;1316 1317    (void)(nullptr >= sv) /* k7 */;1318    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1319    // CHECK-FIXES: (void)("" >= sv) /* k7 */;1320 1321    (void)((nullptr) >= sv) /* k8 */;1322    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1323    // CHECK-FIXES: (void)("" >= sv) /* k8 */;1324  }1325}1326 1327void pointer_greater_comparison(std::string_view *sv_ptr) /* l */ {1328  // Without Equality1329  {1330    (void)(*sv_ptr > nullptr) /* l1 */;1331    // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: comparing{{.*}}empty string1332    // CHECK-FIXES: (void)(*sv_ptr > "") /* l1 */;1333 1334    (void)(*sv_ptr > (nullptr)) /* l2 */;1335    // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: comparing{{.*}}empty string1336    // CHECK-FIXES: (void)(*sv_ptr > "") /* l2 */;1337 1338    (void)(nullptr > *sv_ptr) /* l3 */;1339    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1340    // CHECK-FIXES: (void)("" > *sv_ptr) /* l3 */;1341 1342    (void)((nullptr) > *sv_ptr) /* l4 */;1343    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1344    // CHECK-FIXES: (void)("" > *sv_ptr) /* l4 */;1345  }1346 1347  // With Equality1348  {1349    (void)(*sv_ptr >= nullptr) /* l5 */;1350    // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: comparing{{.*}}empty string1351    // CHECK-FIXES: (void)(*sv_ptr >= "") /* l5 */;1352 1353    (void)(*sv_ptr >= (nullptr)) /* l6 */;1354    // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: comparing{{.*}}empty string1355    // CHECK-FIXES: (void)(*sv_ptr >= "") /* l6 */;1356 1357    (void)(nullptr >= *sv_ptr) /* l7 */;1358    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1359    // CHECK-FIXES: (void)("" >= *sv_ptr) /* l7 */;1360 1361    (void)((nullptr) >= *sv_ptr) /* l8 */;1362    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}empty string1363    // CHECK-FIXES: (void)("" >= *sv_ptr) /* l8 */;1364  }1365}1366 1367void relative_comparison_with_temporary(std::string_view sv) /* m */ {1368  (void)(sv < std::string_view(nullptr)) /* m1 */;1369  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default1370  // CHECK-FIXES: (void)(sv < std::string_view()) /* m1 */;1371 1372  (void)(sv < std::string_view{nullptr}) /* m2 */;1373  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default1374  // CHECK-FIXES: (void)(sv < std::string_view{}) /* m2 */;1375 1376  (void)(sv < (std::string_view) nullptr) /* m3 */;1377  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default1378  // CHECK-FIXES: (void)(sv < (std::string_view) {}) /* m3 */;1379 1380  (void)(sv < (std::string_view){nullptr}) /* m4 */;1381  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: constructing{{.*}}default1382  // CHECK-FIXES: (void)(sv < (std::string_view){}) /* m4 */;1383 1384  (void)(sv < static_cast<SV>(nullptr)) /* m5 */;1385  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: casting{{.*}}empty string1386  // CHECK-FIXES: (void)(sv < static_cast<SV>("")) /* m5 */;1387}1388 1389void equality_comparison(std::string_view sv) /* n */ {1390  // Empty Without Parens1391  {1392    (void)(sv == nullptr) /* n1 */;1393    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing basic_string_view to null is undefined; replace with the emptiness query1394    // CHECK-FIXES: (void)(sv.empty()) /* n1 */;1395 1396    (void)(sv == (nullptr)) /* n2 */;1397    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1398    // CHECK-FIXES: (void)(sv.empty()) /* n2 */;1399 1400    (void)(nullptr == sv) /* n3 */;1401    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1402    // CHECK-FIXES: (void)(sv.empty()) /* n3 */;1403 1404    (void)((nullptr) == sv) /* n4 */;1405    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1406    // CHECK-FIXES: (void)(sv.empty()) /* n4 */;1407  }1408 1409  // Empty With Parens1410  {1411    (void)((sv) == nullptr) /* n5 */;1412    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing basic_string_view to null is undefined; replace with the emptiness query1413    // CHECK-FIXES: (void)(sv.empty()) /* n5 */;1414 1415    (void)((sv) == (nullptr)) /* n6 */;1416    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1417    // CHECK-FIXES: (void)(sv.empty()) /* n6 */;1418 1419    (void)(nullptr == (sv)) /* n7 */;1420    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1421    // CHECK-FIXES: (void)(sv.empty()) /* n7 */;1422 1423    (void)((nullptr) == (sv)) /* n8 */;1424    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1425    // CHECK-FIXES: (void)(sv.empty()) /* n8 */;1426  }1427 1428  // Non-Empty Without Parens1429  {1430    (void)((sv) != nullptr) /* n9 */;1431    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1432    // CHECK-FIXES: (void)(!sv.empty()) /* n9 */;1433 1434    (void)((sv) != (nullptr)) /* n10 */;1435    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1436    // CHECK-FIXES: (void)(!sv.empty()) /* n10 */;1437 1438    (void)(nullptr != (sv)) /* n11 */;1439    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1440    // CHECK-FIXES: (void)(!sv.empty()) /* n11 */;1441 1442    (void)((nullptr) != (sv)) /* n12 */;1443    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1444    // CHECK-FIXES: (void)(!sv.empty()) /* n12 */;1445  }1446 1447  // Non-Empty With Parens1448  {1449    (void)((sv) != nullptr) /* n13 */;1450    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1451    // CHECK-FIXES: (void)(!sv.empty()) /* n13 */;1452 1453    (void)((sv) != (nullptr)) /* n14 */;1454    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1455    // CHECK-FIXES: (void)(!sv.empty()) /* n14 */;1456 1457    (void)(nullptr != (sv)) /* n15 */;1458    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1459    // CHECK-FIXES: (void)(!sv.empty()) /* n15 */;1460 1461    (void)((nullptr) != (sv)) /* n16 */;1462    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1463    // CHECK-FIXES: (void)(!sv.empty()) /* n16 */;1464  }1465}1466 1467void pointer_equality_comparison(std::string_view *sv_ptr) /* o */ {1468  // Empty Without Parens1469  {1470    (void)(*sv_ptr == nullptr) /* o1 */;1471    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1472    // CHECK-FIXES: (void)(sv_ptr->empty()) /* o1 */;1473 1474    (void)(*sv_ptr == (nullptr)) /* o2 */;1475    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1476    // CHECK-FIXES: (void)(sv_ptr->empty()) /* o2 */;1477 1478    (void)(nullptr == *sv_ptr) /* o3 */;1479    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1480    // CHECK-FIXES: (void)(sv_ptr->empty()) /* o3 */;1481 1482    (void)((nullptr) == *sv_ptr) /* o4 */;1483    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1484    // CHECK-FIXES: (void)(sv_ptr->empty()) /* o4 */;1485  }1486 1487  // Empty With Parens1488  {1489    (void)((*sv_ptr) == nullptr) /* o5 */;1490    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1491    // CHECK-FIXES: (void)(sv_ptr->empty()) /* o5 */;1492 1493    (void)((*sv_ptr) == (nullptr)) /* o6 */;1494    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1495    // CHECK-FIXES: (void)(sv_ptr->empty()) /* o6 */;1496 1497    (void)(nullptr == (*sv_ptr)) /* o7 */;1498    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1499    // CHECK-FIXES: (void)(sv_ptr->empty()) /* o7 */;1500 1501    (void)((nullptr) == (*sv_ptr)) /* o8 */;1502    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1503    // CHECK-FIXES: (void)(sv_ptr->empty()) /* o8 */;1504  }1505 1506  // Non-Empty With Parens1507  {1508    (void)((*sv_ptr) != nullptr) /* o9 */;1509    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1510    // CHECK-FIXES: (void)(!sv_ptr->empty()) /* o9 */;1511 1512    (void)((*sv_ptr) != (nullptr)) /* o10 */;1513    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1514    // CHECK-FIXES: (void)(!sv_ptr->empty()) /* o10 */;1515 1516    (void)(nullptr != (*sv_ptr)) /* o11 */;1517    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1518    // CHECK-FIXES: (void)(!sv_ptr->empty()) /* o11 */;1519 1520    (void)((nullptr) != (*sv_ptr)) /* o12 */;1521    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1522    // CHECK-FIXES: (void)(!sv_ptr->empty()) /* o12 */;1523  }1524 1525  // Non-Empty Without Parens1526  {1527    (void)((*sv_ptr) != nullptr) /* o13 */;1528    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1529    // CHECK-FIXES: (void)(!sv_ptr->empty()) /* o13 */;1530 1531    (void)((*sv_ptr) != (nullptr)) /* o14 */;1532    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1533    // CHECK-FIXES: (void)(!sv_ptr->empty()) /* o14 */;1534 1535    (void)(nullptr != (*sv_ptr)) /* o15 */;1536    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1537    // CHECK-FIXES: (void)(!sv_ptr->empty()) /* o15 */;1538 1539    (void)((nullptr) != (*sv_ptr)) /* o16 */;1540    // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: comparing{{.*}}emptiness query1541    // CHECK-FIXES: (void)(!sv_ptr->empty()) /* o16 */;1542  }1543}1544 1545void equality_comparison_with_temporary(std::string_view sv) /* p */ {1546  (void)(sv == std::string_view(nullptr)) /* p1 */;1547  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default1548  // CHECK-FIXES: (void)(sv == std::string_view()) /* p1 */;1549 1550  (void)(sv == std::string_view{nullptr}) /* p2 */;1551  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default1552  // CHECK-FIXES: (void)(sv == std::string_view{}) /* p2 */;1553 1554  (void)(sv == (std::string_view) nullptr) /* p3 */;1555  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default1556  // CHECK-FIXES: (void)(sv == (std::string_view) {}) /* p3 */;1557 1558  (void)(sv == (std::string_view){nullptr}) /* p4 */;1559  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default1560  // CHECK-FIXES: (void)(sv == (std::string_view){}) /* p4 */;1561 1562  (void)(sv == static_cast<SV>(nullptr)) /* p5 */;1563  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: casting{{.*}}empty string1564  // CHECK-FIXES: (void)(sv == static_cast<SV>("")) /* p5 */;1565}1566 1567void return_statement() /* q */ {1568  // Return Statement1569  {1570    []() -> SV { return nullptr; } /* q1 */;1571    // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default1572    // CHECK-FIXES: []() -> SV { return {}; } /* q1 */;1573 1574    []() -> SV { return (nullptr); } /* q2 */;1575    // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default1576    // CHECK-FIXES: []() -> SV { return {}; } /* q2 */;1577 1578    []() -> SV { return {nullptr}; } /* q3 */;1579    // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default1580    // CHECK-FIXES: []() -> SV { return {}; } /* q3 */;1581 1582    []() -> SV { return {(nullptr)}; } /* q4 */;1583    // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default1584    // CHECK-FIXES: []() -> SV { return {}; } /* q4 */;1585 1586    []() -> SV { return {{nullptr}}; } /* q5 */;1587    // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default1588    // CHECK-FIXES: []() -> SV { return {}; } /* q5 */;1589 1590    []() -> SV { return {{(nullptr)}}; } /* q6 */;1591    // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default1592    // CHECK-FIXES: []() -> SV { return {}; } /* q6 */;1593 1594    // Default `const CharT*`1595    []() -> SV { return {{}}; } /* q7 */;1596    // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default1597    // CHECK-FIXES: []() -> SV { return {}; } /* q7 */;1598  }1599 1600  // Return Statement With Temporary1601  {1602    []() -> SV { return SV(nullptr); } /* q8 */;1603    // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default1604    // CHECK-FIXES: []() -> SV { return SV(); } /* q8 */;1605 1606    []() -> SV { return SV{nullptr}; } /* q9 */;1607    // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default1608    // CHECK-FIXES: []() -> SV { return SV{}; } /* q9 */;1609 1610    []() -> SV { return (SV) nullptr; } /* q10 */;1611    // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: constructing{{.*}}default1612    // CHECK-FIXES: []() -> SV { return (SV) {}; } /* q10 */;1613 1614    []() -> SV { return (SV){nullptr}; } /* q11 */;1615    // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: constructing{{.*}}default1616    // CHECK-FIXES: []() -> SV { return (SV){}; } /* q11 */;1617 1618    []() -> SV { return static_cast<SV>(nullptr); } /* q12 */;1619    // CHECK-MESSAGES: :[[@LINE-1]]:41: warning: casting{{.*}}empty string1620    // CHECK-FIXES: []() -> SV { return static_cast<SV>(""); } /* q12 */;1621  }1622}1623 1624void constructor_invocation() /* r */ {1625  struct AcceptsSV {1626    explicit AcceptsSV(std::string_view) {}1627  } r1(nullptr);1628  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: passing{{.*}}empty string1629  // CHECK-FIXES: } r1("");1630 1631  (void)(AcceptsSV{nullptr}) /* r2 */;1632  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: passing{{.*}}empty string1633  // CHECK-FIXES: (void)(AcceptsSV{""}) /* r2 */;1634 1635  AcceptsSV r3{nullptr};1636  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: passing{{.*}}empty string1637  // CHECK-FIXES: AcceptsSV r3{""};1638}1639