]> granicus.if.org Git - clang/commitdiff
Skip the "-dealloc" check if a ObjC class contains no ivars.
authorTed Kremenek <kremenek@apple.com>
Thu, 3 Jul 2008 15:37:02 +0000 (15:37 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 3 Jul 2008 15:37:02 +0000 (15:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53100 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CheckObjCDealloc.cpp
test/Analysis/NSString.m

index 38736dff3deb978740d8bccd0615f0e29452b77e..1f627216ef5d45eb39c9a8f64492013b7ba48a3a 100644 (file)
@@ -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)
index 9a0b94ddcaece139dc8d3ccdff57a4dd623bc4de..a85a87aace022e1b4ed96fd3c69f2b196775694a 100644 (file)
@@ -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])) {