diff options
author | Mads Ravn <madsravn@gmail.com> | 2017-02-12 20:09:59 +0000 |
---|---|---|
committer | Mads Ravn <madsravn@gmail.com> | 2017-02-12 20:09:59 +0000 |
commit | 6ff978fd54f09d2ad902457c39a2358e53669cf6 (patch) | |
tree | f16d4653a24820c58330f7afc8c95e14d8a0abd9 /clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp | |
parent | e826cbf4f304aa26f613337a43f9d7b2c8461fec (diff) | |
download | bcm5719-llvm-6ff978fd54f09d2ad902457c39a2358e53669cf6.tar.gz bcm5719-llvm-6ff978fd54f09d2ad902457c39a2358e53669cf6.zip |
[clang-tidy] Fix for bug 31838: readability-delete-null-pointer does not work for class members
I have made a small fix for readability-delete-null-pointer check so it also checks for class members.
Example of case that it fixes
```
struct A {
void foo() {
if(mp)
delete mp;
}
int *mp;
};
```
Reviewers: JDevlieghere, aaron.ballman, alexfh, malcolm.parsons
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D29726
llvm-svn: 294912
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp b/clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp index 400714b44d9..b46e52a754b 100644 --- a/clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-delete-null-pointer.cpp @@ -59,6 +59,16 @@ void f() { } else { c2 = c; } + struct A { + void foo() { + if (mp) // #6 + delete mp; + // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] + // CHECK-FIXES: {{^ }}// #6 + // CHECK-FIXES-NEXT: delete mp; + } + int *mp; + }; } void g() { |