[cfe-commits] r53100 - in /cfe/trunk: lib/Analysis/CheckObjCDealloc.cpp test/Analysis/NSString.m
Ted Kremenek
kremenek at apple.com
Thu Jul 3 08:37:11 PDT 2008
Author: kremenek
Date: Thu Jul 3 10:37:02 2008
New Revision: 53100
URL: http://llvm.org/viewvc/llvm-project?rev=53100&view=rev
Log:
Skip the "-dealloc" check if a ObjC class contains no ivars.
Modified:
cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
cfe/trunk/test/Analysis/NSString.m
Modified: cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp?rev=53100&r1=53099&r2=53100&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp Thu Jul 3 10:37:02 2008
@@ -47,10 +47,15 @@
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)
Modified: cfe/trunk/test/Analysis/NSString.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NSString.m?rev=53100&r1=53099&r2=53100&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/NSString.m (original)
+++ cfe/trunk/test/Analysis/NSString.m Thu Jul 3 10:37:02 2008
@@ -143,7 +143,7 @@
- (NSString*) getShared;
+ (C1*) sharedInstance;
@end
- at implementation C1 : NSObject {} // expected-warning{{Objective-C class 'C1' lacks a 'dealloc' instance method}}
+ at implementation C1 : NSObject {}
- (NSString*) getShared {
static NSString* s = 0;
if (!s) s = [[NSString alloc] init];
@@ -161,7 +161,7 @@
@interface SharedClass : NSObject
+ (id)sharedInstance;
@end
- at implementation SharedClass // expected-warning {{Objective-C class 'SharedClass' lacks a 'dealloc' instance method}}
+ at implementation SharedClass
- (id)_init {
if ((self = [super init])) {
More information about the cfe-commits
mailing list