[PATCH] [analysis] Add test for missing -dealloc method in classes with an ivar
David Kilzer
ddkilzer at kilzer.net
Fri Aug 22 04:08:43 PDT 2014
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.
+
+ at interface MissingDeallocWithIvar : NSObject {
+ NSObject *_ivar;
+}
+ at end
+
+ at implementation MissingDeallocWithIvar // expected-warning {{Objective-C class 'MissingDeallocWithIvar' lacks a 'dealloc' instance method}}
+ at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5023.12837.patch
Type: text/x-patch
Size: 1176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140822/4415f23c/attachment.bin>
More information about the cfe-commits
mailing list