Remove ASTContext::isObjCObjectPointerType().
Convert all clients to use the new predicate on Type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76076 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index fb28188..dd9e963 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -3133,6 +3133,7 @@
/// isObjCNSObjectType - Return true if this is an NSObject object using
/// NSObject attribute on a c-style pointer type.
/// FIXME - Make it work directly on types.
+/// FIXME: Move to Type.
///
bool ASTContext::isObjCNSObjectType(QualType Ty) const {
if (TypedefType *TDT = dyn_cast<TypedefType>(Ty)) {
@@ -3143,46 +3144,6 @@
return false;
}
-/// isObjCObjectPointerType - Returns true if type is an Objective-C pointer
-/// to an object type. This includes "id" and "Class" (two 'special' pointers
-/// to struct), Interface* (pointer to ObjCInterfaceType) and id<P> (qualified
-/// ID type).
-bool ASTContext::isObjCObjectPointerType(QualType Ty) const {
- if (Ty->isObjCObjectPointerType())
- return true;
- if (Ty->isObjCQualifiedIdType())
- return true;
-
- // Blocks are objects.
- if (Ty->isBlockPointerType())
- return true;
-
- // All other object types are pointers.
- const PointerType *PT = Ty->getAsPointerType();
- if (PT == 0)
- return false;
-
- // If this a pointer to an interface (e.g. NSString*), it is ok.
- if (PT->getPointeeType()->isObjCInterfaceType() ||
- // If is has NSObject attribute, OK as well.
- isObjCNSObjectType(Ty))
- return true;
-
- // 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
/// garbage collection attribute.
///
@@ -3195,14 +3156,14 @@
// (or pointers to them) be treated as though they were declared
// as __strong.
if (GCAttrs == QualType::GCNone) {
- if (isObjCObjectPointerType(Ty))
+ if (Ty->isObjCObjectPointerType())
GCAttrs = QualType::Strong;
else if (Ty->isPointerType())
return getObjCGCAttrKind(Ty->getAsPointerType()->getPointeeType());
}
// Non-pointers have none gc'able attribute regardless of the attribute
// set on them.
- else if (!Ty->isPointerType() && !isObjCObjectPointerType(Ty))
+ else if (!Ty->isAnyPointerType() && !Ty->isBlockPointerType())
return QualType::GCNone;
}
return GCAttrs;
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 44b8dc2..5d22f38 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -991,7 +991,7 @@
QualType T = VD->getType();
// dereferencing to an object pointer is always a gc'able candidate
if (T->isPointerType() &&
- Ctx.isObjCObjectPointerType(T->getAsPointerType()->getPointeeType()))
+ T->getAsPointerType()->getPointeeType()->isObjCObjectPointerType())
return true;
}