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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53987 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CheckObjCDealloc.cpp b/lib/Analysis/CheckObjCDealloc.cpp
index 7bb0015..6da52ba 100644
--- a/lib/Analysis/CheckObjCDealloc.cpp
+++ b/lib/Analysis/CheckObjCDealloc.cpp
@@ -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;
     }
diff --git a/test/Analysis/IBOutlet.m b/test/Analysis/IBOutlet.m
deleted file mode 100644
index 4049e79..0000000
--- a/test/Analysis/IBOutlet.m
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: clang -warn-objc-missing-dealloc '-DIBOutlet=__attribute__((iboutlet))' %s --verify
-
-#ifndef IBOutlet
-#define IBOutlet
-#endif
-
-@class NSWindow;
-
-@interface NSObject {}
-- (void)dealloc;
-@end
-
-@interface A : NSObject {
-IBOutlet NSWindow *window;
-}
-@end
-
-@implementation A // no-warning
-@end
-
diff --git a/test/Analysis/MissingDealloc_SEL.m b/test/Analysis/MissingDealloc_SEL.m
new file mode 100644
index 0000000..be3e0b7
--- /dev/null
+++ b/test/Analysis/MissingDealloc_SEL.m
@@ -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;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+@end
+@interface NSObject <NSObject> {}
+- (id)init;
+@end
+
+@interface TestSELs : NSObject {
+  SEL a;
+  SEL b;
+}
+
+@end
+
+@implementation TestSELs // no-warning
+- (id)init {
+  if( (self = [super init]) ) {
+    a = @selector(a);
+    b = @selector(b);
+  }
+
+  return self;
+}
+@end