return true;
// All other object types are pointers.
- if (!Ty->isPointerType())
+ const PointerType *PT = Ty->getAsPointerType();
+ if (PT == 0)
return false;
- // Check to see if this is 'id' or 'Class', both of which are typedefs for
- // pointer types. This looks for the typedef specifically, not for the
- // underlying type.
- if (Ty.getUnqualifiedType() == getObjCIdType() ||
- Ty.getUnqualifiedType() == getObjCClassType())
- return true;
-
// If this a pointer to an interface (e.g. NSString*), it is ok.
- if (Ty->getAsPointerType()->getPointeeType()->isObjCInterfaceType())
+ if (PT->getPointeeType()->isObjCInterfaceType() ||
+ // If is has NSObject attribute, OK as well.
+ isObjCNSObjectType(Ty))
return true;
- // If is has NSObject attribute, OK as well.
- return isObjCNSObjectType(Ty);
+ // Check to see if this is 'id' or 'Class', both of which are typedefs for
+ // pointer types. This looks for the typedef specifically, not for the
+ // underlying type. Iteratively strip off typedefs so that we can handle
+ // typedefs of typedefs.
+ while (TypedefType *TDT = dyn_cast<TypedefType>(Ty)) {
+ if (Ty.getUnqualifiedType() == getObjCIdType() ||
+ Ty.getUnqualifiedType() == getObjCClassType())
+ return true;
+
+ Ty = TDT->getDecl()->getUnderlyingType();
+ }
+
+ return false;
}
/// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's