Hi jordan_rose,
Current tests only cover exceptions to the rule. This adds a
test that actually produces a warning message for classes that
contain an ivar with an Objective-C pointer type.
http://reviews.llvm.org/D5023
Files:
test/Analysis/MissingDealloc.m
Index: test/Analysis/MissingDealloc.m
===================================================================
--- test/Analysis/MissingDealloc.m
+++ test/Analysis/MissingDealloc.m
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc %s
-verify
-// expected-no-diagnostics
+
typedef signed char BOOL;
@protocol NSObject
- (BOOL)isEqual:(id)object;
@@ -13,6 +13,18 @@
typedef struct objc_selector *SEL;
+//===------------------------------------------------------------------------===
+// Warn about missing -dealloc method.
+
+@interface MissingDeallocWithIvar : NSObject {
+ NSObject *_ivar;
+}
+@end
+
+@implementation MissingDeallocWithIvar // expected-warning {{Objective-C class
'MissingDeallocWithIvar' lacks a 'dealloc' instance method}}
+@end
+
+//===------------------------------------------------------------------------===
// <rdar://problem/6380411>: 'myproperty' has kind 'assign' and thus the
// assignment through the setter does not perform a release.
@@ -26,7 +38,7 @@
@synthesize myproperty=_myproperty; // no-warning
- (void)dealloc {
self.myproperty = 0;
- [super dealloc];
+ [super dealloc];
}
@end
Index: test/Analysis/MissingDealloc.m
===================================================================
--- test/Analysis/MissingDealloc.m
+++ test/Analysis/MissingDealloc.m
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc %s -verify
-// expected-no-diagnostics
+
typedef signed char BOOL;
@protocol NSObject
- (BOOL)isEqual:(id)object;
@@ -13,6 +13,18 @@
typedef struct objc_selector *SEL;
+//===------------------------------------------------------------------------===
+// Warn about missing -dealloc method.
+
+@interface MissingDeallocWithIvar : NSObject {
+ NSObject *_ivar;
+}
+@end
+
+@implementation MissingDeallocWithIvar // expected-warning {{Objective-C class 'MissingDeallocWithIvar' lacks a 'dealloc' instance method}}
+@end
+
+//===------------------------------------------------------------------------===
// <rdar://problem/6380411>: 'myproperty' has kind 'assign' and thus the
// assignment through the setter does not perform a release.
@@ -26,7 +38,7 @@
@synthesize myproperty=_myproperty; // no-warning
- (void)dealloc {
self.myproperty = 0;
- [super dealloc];
+ [super dealloc];
}
@end
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits