[clang-tools-extra] [clang-tidy] modernize-use-nullptr matches "NULL" in templates (PR #109169)
Florian Mayer via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 19 10:10:22 PDT 2024
================
@@ -84,6 +84,28 @@ void test_macro_expansion4() {
#undef MY_NULL
}
+template <typename T> struct pear {
+ // If you say __null (or NULL), we assume that T will always be a pointer
+ // type, so we suggest replacing it with nullptr.
+ void f() { x = __null; }
+ // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use nullptr [modernize-use-nullptr]
+ // CHECK-FIXES: x = nullptr;
+
+ // But if you say 0, we allow the possibility that T can be used with integral
+ // and pointer types, and "0" is an acceptable initializer (even if "{}" might
+ // be even better).
+ void g() { y = 0; }
----------------
fmayer wrote:
`CHECK-MESSAGES-NOT`?
https://github.com/llvm/llvm-project/pull/109169
More information about the cfe-commits
mailing list