Fix a crash when ivar type is a __strong SEL. Fallout from
recent change to make SEL a builtin type (fixes radar 7425510).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90145 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 5b09ef0..349487f 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -2548,12 +2548,7 @@
     return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) &&
            !Protocols.size();
   }
-
-  /// isObjCSelType - true for "SEL".
-  bool isObjCSelType() const {
-    return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCSel);
-  }
-
+  
   /// isObjCQualifiedIdType - true for "id <p>".
   bool isObjCQualifiedIdType() const {
     return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) &&
@@ -2902,8 +2897,8 @@
   return false;
 }
 inline bool Type::isObjCSelType() const {
-  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
-    return OPT->isObjCSelType();
+  if (const PointerType *OPT = getAs<PointerType>())
+    return OPT->getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCSel);
   return false;
 }
 inline bool Type::isObjCBuiltinType() const {
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 2579a6e..6c9ecf0 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -3413,13 +3413,13 @@
     return;
   }
   
-  if (isObjCSelType(T)) {
-    S += ':';
-    return;
-  }
-
   if (const PointerType *PT = T->getAs<PointerType>()) {
+    if (PT->isObjCSelType()) {
+      S += ':';
+      return;
+    }
     QualType PointeeTy = PT->getPointeeType();
+    
     bool isReadOnly = false;
     // For historical/compatibility reasons, the read-only qualifier of the
     // pointee gets emitted _before_ the '^'.  The read-only qualifier of
diff --git a/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m
index 7aca79a..db8470b 100644
--- a/test/CodeGenObjC/encode-test.m
+++ b/test/CodeGenObjC/encode-test.m
@@ -66,6 +66,7 @@
 @interface Test 
 {
 	int ivar;
+         __attribute__((objc_gc(weak))) SEL selector;
 }
 -(void) test3: (Test*  [3] [4])b ; 
 - (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3;