summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/NewDelete-checker-test.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2014-01-08 18:46:55 +0000
committerJordan Rose <jordan_rose@apple.com>2014-01-08 18:46:55 +0000
commit656fdd55dd0dffb9177b8008fe030c24300507cb (patch)
tree70fcd75b358ce31567b4ef5b5429d34b1cd5fa73 /clang/test/Analysis/NewDelete-checker-test.cpp
parentdf1e1960ac8168d6970f1fbf669c2005b0537372 (diff)
downloadbcm5719-llvm-656fdd55dd0dffb9177b8008fe030c24300507cb.tar.gz
bcm5719-llvm-656fdd55dd0dffb9177b8008fe030c24300507cb.zip
[analyzer] Warn about double-delete in C++ at the second delete...
...rather somewhere in the destructor when we try to access something and realize the object has already been deleted. This is necessary because the destructor is processed before the 'delete' itself. Patch by Karthik Bhat! llvm-svn: 198779
Diffstat (limited to 'clang/test/Analysis/NewDelete-checker-test.cpp')
-rw-r--r--clang/test/Analysis/NewDelete-checker-test.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/test/Analysis/NewDelete-checker-test.cpp b/clang/test/Analysis/NewDelete-checker-test.cpp
index cc9725128bc..855b05d6633 100644
--- a/clang/test/Analysis/NewDelete-checker-test.cpp
+++ b/clang/test/Analysis/NewDelete-checker-test.cpp
@@ -338,13 +338,13 @@ class DerefClass{
public:
int *x;
DerefClass() {}
- ~DerefClass() {*x = 1;} //expected-warning {{Use of memory after it is freed}}
+ ~DerefClass() {*x = 1;}
};
void testDoubleDeleteClassInstance() {
DerefClass *foo = new DerefClass();
delete foo;
- delete foo; // FIXME: We should ideally report warning here instead of inside the destructor.
+ delete foo; // expected-warning {{Attempt to delete released memory}}
}
class EmptyClass{
@@ -356,5 +356,5 @@ public:
void testDoubleDeleteEmptyClass() {
EmptyClass *foo = new EmptyClass();
delete foo;
- delete foo; //expected-warning {{Attempt to free released memory}}
+ delete foo; // expected-warning {{Attempt to delete released memory}}
}
OpenPOWER on IntegriCloud