================
@@ -1625,14 +1624,29 @@ void constructor_invocation() /* r */ {
struct AcceptsSV {
explicit AcceptsSV(std::string_view) {}
} r1(nullptr);
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: passing{{.*}}empty string
+ // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructing
// CHECK-FIXES: } r1("");
(void)(AcceptsSV{nullptr}) /* r2 */;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: passing{{.*}}empty string
+ // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: constructing
// CHECK-FIXES: (void)(AcceptsSV{""}) /* r2 */;
AcceptsSV r3{nullptr};
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: passing{{.*}}empty string
+ // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: constructing
// CHECK-FIXES: AcceptsSV r3{""};
}
+
+void different_ways_of_spelling_nullptr() {
+ std::string_view sv1 {0};
+ // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing
+ // CHECK-FIXES: std::string_view sv1 {};
+
+ std::string_view sv2 {NULL};
+ // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing
+ // CHECK-FIXES: std::string_view sv2 {};
+
+ const char * const null_char_ptr = nullptr;
+ std::string_view sv3 {null_char_ptr};
+ // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing
+ // CHECK-FIXES: std::string_view sv3 {};
----------------
localspook wrote:
Yep, it does fancy constant folding tricks:
https://github.com/llvm/llvm-project/blob/a6f40eed9b4cb1976d5c92be2700bf0931673057/clang/include/clang/AST/Expr.h#L657-L664
https://github.com/llvm/llvm-project/pull/192889
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits