[cfe-commits] r53987 - in /cfe/trunk: lib/Analysis/CheckObjCDealloc.cpp test/Analysis/IBOutlet.m test/Analysis/MissingDealloc_SEL.m
Ted Kremenek
kremenek at apple.com
Thu Jul 24 10:45:56 PDT 2008
Author: kremenek
Date: Thu Jul 24 12:45:56 2008
New Revision: 53987
URL: http://llvm.org/viewvc/llvm-project?rev=53987&view=rev
Log:
Don't issue a missing +dealloc warning for classes that just contain SEL ivars.
This fixes PR 2592: http://llvm.org/bugs/show_bug.cgi?id=2592
Added:
cfe/trunk/test/Analysis/MissingDealloc_SEL.m
Removed:
cfe/trunk/test/Analysis/IBOutlet.m
Modified:
cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
Modified: cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp?rev=53987&r1=53986&r2=53987&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp Thu Jul 24 12:45:56 2008
@@ -42,6 +42,13 @@
return false;
}
+static bool isSEL(QualType T, IdentifierInfo* SelII) {
+ if (const TypedefType* Ty = T->getAsTypedefType())
+ return Ty->getDecl()->getIdentifier() == SelII;
+
+ return false;
+}
+
void clang::CheckObjCDealloc(ObjCImplementationDecl* D,
const LangOptions& LOpts, BugReporter& BR) {
@@ -56,6 +63,7 @@
// http://llvm.org/bugs/show_bug.cgi?id=2517
bool containsPointerIvar = false;
+ IdentifierInfo* SelII = &Ctx.Idents.get("SEL");
for (ObjCInterfaceDecl::ivar_iterator I=ID->ivar_begin(), E=ID->ivar_end();
I!=E; ++I) {
@@ -64,7 +72,8 @@
QualType T = ID->getType();
if ((T->isPointerType() || T->isObjCQualifiedIdType()) &&
- ID->getAttr<IBOutletAttr>() == 0) { // Skip IBOutlets.
+ (ID->getAttr<IBOutletAttr>() == 0 && // Skip IBOutlets.
+ !isSEL(T, SelII))) { // Skip SEL ivars.
containsPointerIvar = true;
break;
}
Removed: cfe/trunk/test/Analysis/IBOutlet.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/IBOutlet.m?rev=53986&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/IBOutlet.m (original)
+++ cfe/trunk/test/Analysis/IBOutlet.m (removed)
@@ -1,20 +0,0 @@
-// RUN: clang -warn-objc-missing-dealloc '-DIBOutlet=__attribute__((iboutlet))' %s --verify
-
-#ifndef IBOutlet
-#define IBOutlet
-#endif
-
- at class NSWindow;
-
- at interface NSObject {}
-- (void)dealloc;
- at end
-
- at interface A : NSObject {
-IBOutlet NSWindow *window;
-}
- at end
-
- at implementation A // no-warning
- at end
-
Added: cfe/trunk/test/Analysis/MissingDealloc_SEL.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/MissingDealloc_SEL.m?rev=53987&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/MissingDealloc_SEL.m (added)
+++ cfe/trunk/test/Analysis/MissingDealloc_SEL.m Thu Jul 24 12:45:56 2008
@@ -0,0 +1,30 @@
+// RUN: clang -warn-objc-missing-dealloc -verify %s
+
+typedef struct objc_selector *SEL;
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+ at protocol NSObject
+- (BOOL)isEqual:(id)object;
+ at end
+ at interface NSObject <NSObject> {}
+- (id)init;
+ at end
+
+ at interface TestSELs : NSObject {
+ SEL a;
+ SEL b;
+}
+
+ at end
+
+ at implementation TestSELs // no-warning
+- (id)init {
+ if( (self = [super init]) ) {
+ a = @selector(a);
+ b = @selector(b);
+ }
+
+ return self;
+}
+ at end
More information about the cfe-commits
mailing list