[PATCH] D21298: [Clang-tidy] delete null check
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 17 05:48:39 PST 2016
aaron.ballman added inline comments.
================
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]
----------------
hokein wrote:
> Does it work the case like:
>
> ```
> int *p = nullptr;
> if (p == nullptr) {
> p = new int[3];
> delete[] p;
> }
> ```
>
> ?
Similarly, it should not mishandle a case like:
void f(int *p) {
if (p) {
delete p;
} else {
// Do something else
}
}
================
Comment at: test/clang-tidy/readability-delete-null-pointer.cpp:59
+}
\ No newline at end of file
----------------
Please add a newline.
https://reviews.llvm.org/D21298
More information about the cfe-commits
mailing list