[cfe-commits] r58432 - /cfe/trunk/test/Analysis/PR2978.m
Ted Kremenek
kremenek at apple.com
Thu Oct 30 08:19:43 PDT 2008
Author: kremenek
Date: Thu Oct 30 10:19:43 2008
New Revision: 58432
URL: http://llvm.org/viewvc/llvm-project?rev=58432&view=rev
Log:
Patch by Nikita Zhuk: test case for fix for false positive reported in PR2978.
Added:
cfe/trunk/test/Analysis/PR2978.m
Added: cfe/trunk/test/Analysis/PR2978.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR2978.m?rev=58432&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/PR2978.m (added)
+++ cfe/trunk/test/Analysis/PR2978.m Thu Oct 30 10:19:43 2008
@@ -0,0 +1,55 @@
+// RUN: clang -warn-objc-missing-dealloc %s -verify
+
+// Tests for the checker which checks missing/extra ivar 'release' calls
+// in dealloc.
+
+ at interface NSObject
+- (void)release;
+ at end
+
+ at interface MyClass : NSObject {
+ at private
+ id _X;
+ id _Y;
+ id _Z;
+ id _K;
+ id _N;
+ id _M;
+ id _V;
+ id _W;
+}
+ at property(retain) id X;
+ at property(retain) id Y;
+ at property(assign) id Z;
+ at property(assign) id K;
+ at property(assign, readonly) id N;
+ at property(retain) id M;
+ at property(retain) id V;
+ at property(retain) id W;
+ at end
+
+ at implementation MyClass
+ at synthesize X = _X;
+ at synthesize Y = _Y; // expected-warning{{The '_Y' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}}
+ at synthesize Z = _Z; // expected-warning{{The '_Z' instance variable was not retained by a synthesized property but was released in 'dealloc'}}
+ at synthesize K = _K;
+ at synthesize N = _N;
+ at synthesize M = _M;
+ at synthesize V = _V;
+ at synthesize W = _W; // expected-warning{{The '_W' instance variable was retained by a synthesized property but wasn't released in 'dealloc'}}
+
+- (void)dealloc
+{
+ [_X release];
+ [_Z release];
+ [_N release];
+
+ self.M = 0; // This will release '_M'
+ [self setV:0]; // This will release '_V'
+ [self setW:@"newW"]; // This will release '_W', but retain the new value
+
+ [super dealloc];
+}
+
+ at end
+
More information about the cfe-commits
mailing list