aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/CheckObjCDealloc.cpp9
-rw-r--r--test/Analysis/NSString.m4
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/Analysis/CheckObjCDealloc.cpp b/lib/Analysis/CheckObjCDealloc.cpp
index 38736dff3d..1f627216ef 100644
--- a/lib/Analysis/CheckObjCDealloc.cpp
+++ b/lib/Analysis/CheckObjCDealloc.cpp
@@ -47,10 +47,15 @@ void clang::CheckObjCDealloc(ObjCImplementationDecl* D,
assert (LOpts.getGCMode() != LangOptions::GCOnly);
ASTContext& Ctx = BR.getContext();
-
+ ObjCInterfaceDecl* ID = D->getClassInterface();
+
+ // Does the class contain any ivars? If not, skip the check entirely.
+
+ if (ID->ivar_empty())
+ return;
+
// Determine if the class subclasses NSObject.
IdentifierInfo* NSObjectII = &Ctx.Idents.get("NSObject");
- ObjCInterfaceDecl* ID = D->getClassInterface();
for ( ; ID ; ID = ID->getSuperClass())
if (ID->getIdentifier() == NSObjectII)
diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m
index 9a0b94ddca..a85a87aace 100644
--- a/test/Analysis/NSString.m
+++ b/test/Analysis/NSString.m
@@ -143,7 +143,7 @@ NSString* f10() {
- (NSString*) getShared;
+ (C1*) sharedInstance;
@end
-@implementation C1 : NSObject {} // expected-warning{{Objective-C class 'C1' lacks a 'dealloc' instance method}}
+@implementation C1 : NSObject {}
- (NSString*) getShared {
static NSString* s = 0;
if (!s) s = [[NSString alloc] init];
@@ -161,7 +161,7 @@ NSString* f10() {
@interface SharedClass : NSObject
+ (id)sharedInstance;
@end
-@implementation SharedClass // expected-warning {{Objective-C class 'SharedClass' lacks a 'dealloc' instance method}}
+@implementation SharedClass
- (id)_init {
if ((self = [super init])) {