diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-07-26 20:04:21 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-07-26 20:04:21 +0000 |
commit | 54529a347e13c789ebb544fdae75a2651085b95f (patch) | |
tree | 6a4b12d423711175142ec3ceb4406694212ef8c6 /clang/test/Analysis/dtor.cpp | |
parent | 05375eb4ecc855a3b13c25356a44eda197e51a7f (diff) | |
download | bcm5719-llvm-54529a347e13c789ebb544fdae75a2651085b95f.tar.gz bcm5719-llvm-54529a347e13c789ebb544fdae75a2651085b95f.zip |
[analyzer] Handle C++ member initializers and destructors.
This uses CFG to tell if a constructor call is for a member, and uses
the member's region appropriately.
llvm-svn: 160808
Diffstat (limited to 'clang/test/Analysis/dtor.cpp')
-rw-r--r-- | clang/test/Analysis/dtor.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/Analysis/dtor.cpp b/clang/test/Analysis/dtor.cpp index 8d67f78a4a7..f5837539cb7 100644 --- a/clang/test/Analysis/dtor.cpp +++ b/clang/test/Analysis/dtor.cpp @@ -103,3 +103,21 @@ void testMultipleInheritance3() { // expected-warning@25 {{Attempt to free released memory}} } } + + +class SmartPointerMember { + SmartPointer P; +public: + SmartPointerMember(void *x) : P(x) {} +}; + +void testSmartPointerMember() { + char *mem = (char*)malloc(4); + { + SmartPointerMember Deleter(mem); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} |