[PATCH] D21298: [Clang-tidy] delete null check

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 17 02:37:15 PST 2016


hokein added inline comments.


================
Comment at: test/clang-tidy/readability-delete-null-pointer.cpp:3
+
+#include <cstdlib>
+
----------------
We don't rely on implementations of standard headers in lit test. You should fake the function/class that you need in this test. 


================
Comment at: test/clang-tidy/readability-delete-null-pointer.cpp:7
+  int *p = 0;
+  if (p) {
+    // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer]
----------------
Does it work the case like:

```
int *p = nullptr;
if (p == nullptr) {
   p = new int[3];
   delete[] p;
}
```

?


https://reviews.llvm.org/D21298





More information about the cfe-commits mailing list