summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-07-16 15:41:00 +0000
committerSteve Naroff <snaroff@apple.com>2009-07-16 15:41:00 +0000
commitf49545602089be5b1f744e04326b8a566f6d8773 (patch)
treec6a833eba46840cff3d65f06772865ffe525c711
parent95b851e55c328af4b69da7bfc1124bf258c0ffe5 (diff)
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
-rw-r--r--include/clang/AST/ASTContext.h6
-rw-r--r--lib/AST/ASTContext.cpp45
-rw-r--r--lib/AST/Expr.cpp2
-rw-r--r--lib/Analysis/CFRefCount.cpp2
-rw-r--r--lib/Analysis/CheckObjCDealloc.cpp4
-rw-r--r--lib/Analysis/GRExprEngineInternalChecks.cpp4
-rw-r--r--lib/Analysis/Store.cpp2
-rw-r--r--lib/CodeGen/CGBlocks.h2
-rw-r--r--lib/CodeGen/CGExpr.cpp2
-rw-r--r--lib/CodeGen/CGObjCMac.cpp2
-rw-r--r--lib/Sema/SemaDecl.cpp2
-rw-r--r--lib/Sema/SemaDeclObjC.cpp8
-rw-r--r--lib/Sema/SemaExpr.cpp4
-rw-r--r--lib/Sema/SemaOverload.cpp2
-rw-r--r--lib/Sema/SemaStmt.cpp10
15 files changed, 27 insertions, 70 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index f10c6b6631..19a4fbcdba 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -534,12 +534,6 @@ private:
//===--------------------------------------------------------------------===//
public:
- /// 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 isObjCObjectPointerType(QualType Ty) const;
-
/// getObjCGCAttr - Returns one of GCNone, Weak or Strong objc's
/// garbage collection attribute.
///
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index fb28188789..dd9e9632b2 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -3133,6 +3133,7 @@ QualType ASTContext::getFromTargetType(unsigned Type) const {
/// 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 @@ bool ASTContext::isObjCNSObjectType(QualType Ty) const {
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 @@ QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const {
// (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 44b8dc2c36..5d22f38770 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -991,7 +991,7 @@ bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {
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;
}
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 1cfd783492..3d2e3ac9a8 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -881,7 +881,7 @@ RetainSummaryManager::getPersistentSummary(ArgEffects AE, RetEffect RetEff,
//===----------------------------------------------------------------------===//
bool RetainSummaryManager::isTrackedObjCObjectType(QualType Ty) {
- if (!Ctx.isObjCObjectPointerType(Ty))
+ if (!Ty->isObjCObjectPointerType())
return false;
const ObjCObjectPointerType *PT = Ty->getAsObjCObjectPointerType();
diff --git a/lib/Analysis/CheckObjCDealloc.cpp b/lib/Analysis/CheckObjCDealloc.cpp
index a14ae26512..7e6023a1f5 100644
--- a/lib/Analysis/CheckObjCDealloc.cpp
+++ b/lib/Analysis/CheckObjCDealloc.cpp
@@ -108,7 +108,7 @@ void clang::CheckObjCDealloc(ObjCImplementationDecl* D,
ObjCIvarDecl* ID = *I;
QualType T = ID->getType();
- if (!Ctx.isObjCObjectPointerType(T) ||
+ if (!T->isObjCObjectPointerType() ||
ID->getAttr<IBOutletAttr>()) // Skip IBOutlets.
continue;
@@ -210,7 +210,7 @@ void clang::CheckObjCDealloc(ObjCImplementationDecl* D,
continue;
QualType T = ID->getType();
- if (!Ctx.isObjCObjectPointerType(T)) // Skip non-pointer ivars
+ if (!T->isObjCObjectPointerType()) // Skip non-pointer ivars
continue;
const ObjCPropertyDecl* PD = (*I)->getPropertyDecl();
diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp
index a2ce79a2f3..bb35274cb5 100644
--- a/lib/Analysis/GRExprEngineInternalChecks.cpp
+++ b/lib/Analysis/GRExprEngineInternalChecks.cpp
@@ -718,7 +718,7 @@ public:
ASTContext &C = BRC.getASTContext();
if (R->isBoundable()) {
if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) {
- if (C.isObjCObjectPointerType(TR->getValueType(C))) {
+ if (TR->getValueType(C)->isObjCObjectPointerType()) {
os << "initialized to nil";
b = true;
}
@@ -749,7 +749,7 @@ public:
ASTContext &C = BRC.getASTContext();
if (R->isBoundable()) {
if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) {
- if (C.isObjCObjectPointerType(TR->getValueType(C))) {
+ if (TR->getValueType(C)->isObjCObjectPointerType()) {
os << "nil object reference stored to ";
b = true;
}
diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp
index c7f9eecc73..b939a0df9c 100644
--- a/lib/Analysis/Store.cpp
+++ b/lib/Analysis/Store.cpp
@@ -55,7 +55,7 @@ StoreManager::NewCastRegion(const GRState *state, const MemRegion* R,
QualType ToTy = Ctx.getCanonicalType(CastToTy);
// Handle casts to Objective-C objects.
- if (Ctx.isObjCObjectPointerType(CastToTy)) {
+ if (CastToTy->isObjCObjectPointerType()) {
state = setCastType(state, R, CastToTy);
return CastResult(state, R);
}
diff --git a/lib/CodeGen/CGBlocks.h b/lib/CodeGen/CGBlocks.h
index 05d66de3f9..5a0af04b24 100644
--- a/lib/CodeGen/CGBlocks.h
+++ b/lib/CodeGen/CGBlocks.h
@@ -223,7 +223,7 @@ public:
return true;
if (getContext().isObjCNSObjectType(Ty))
return true;
- if (getContext().isObjCObjectPointerType(Ty))
+ if (Ty->isObjCObjectPointerType())
return true;
return false;
}
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 377834d247..346b6703d3 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1070,7 +1070,7 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue,
if (attr == QualType::Weak)
attr = QualType::GCNone;
}
- else if (getContext().isObjCObjectPointerType(Ty))
+ else if (Ty->isObjCObjectPointerType())
attr = QualType::Strong;
}
LValue LV =
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 70eb6a70e1..661f75a057 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -3005,7 +3005,7 @@ static QualType::GCAttrTypes GetGCAttrTypeForType(ASTContext &Ctx,
if (FQT.isObjCGCWeak())
return QualType::Weak;
- if (Ctx.isObjCObjectPointerType(FQT))
+ if (FQT->isObjCObjectPointerType())
return QualType::Strong;
if (const PointerType *PT = FQT->getAsPointerType())
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index d069fb06b9..92afc343f3 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -4271,7 +4271,7 @@ void Sema::ActOnFields(Scope* S,
else if (getLangOptions().ObjC1 &&
getLangOptions().getGCMode() != LangOptions::NonGC &&
Record &&
- (Context.isObjCObjectPointerType(FD->getType()) ||
+ (FD->getType()->isObjCObjectPointerType() ||
FD->getType().isObjCGCStrong()))
Record->setHasObjectMember(true);
// Keep track of the number of named members.
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index b8a9834b50..8dc14eebe4 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -25,7 +25,7 @@ bool Sema::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
if (GetterMethod &&
GetterMethod->getResultType() != property->getType()) {
AssignConvertType result = Incompatible;
- if (Context.isObjCObjectPointerType(property->getType()))
+ if (property->getType()->isObjCObjectPointerType())
result = CheckAssignmentConstraints(GetterMethod->getResultType(), property->getType());
if (result != Compatible) {
Diag(Loc, diag::warn_accessor_property_type_mismatch)
@@ -1739,7 +1739,9 @@ void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
// Check for copy or retain on non-object types.
if ((Attributes & (ObjCDeclSpec::DQ_PR_copy | ObjCDeclSpec::DQ_PR_retain)) &&
- !Context.isObjCObjectPointerType(PropertyTy)) {
+ !PropertyTy->isObjCObjectPointerType() &&
+ !PropertyTy->isBlockPointerType() &&
+ !Context.isObjCNSObjectType(PropertyTy)) {
Diag(Loc, diag::err_objc_property_requires_object)
<< (Attributes & ObjCDeclSpec::DQ_PR_copy ? "copy" : "retain");
Attributes &= ~(ObjCDeclSpec::DQ_PR_copy | ObjCDeclSpec::DQ_PR_retain);
@@ -1770,7 +1772,7 @@ void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
if (!(Attributes & (ObjCDeclSpec::DQ_PR_assign | ObjCDeclSpec::DQ_PR_copy |
ObjCDeclSpec::DQ_PR_retain)) &&
!(Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
- Context.isObjCObjectPointerType(PropertyTy)) {
+ PropertyTy->isObjCObjectPointerType()) {
// Skip this warning in gc-only mode.
if (getLangOptions().getGCMode() != LangOptions::GCOnly)
Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index d6224f1f7b..4b3f40aa93 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4500,9 +4500,9 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS,
// Special case of NSObject attributes on c-style pointer types.
if (ConvTy == IncompatiblePointer &&
((Context.isObjCNSObjectType(LHSType) &&
- Context.isObjCObjectPointerType(RHSType)) ||
+ RHSType->isObjCObjectPointerType()) ||
(Context.isObjCNSObjectType(RHSType) &&
- Context.isObjCObjectPointerType(LHSType))))
+ LHSType->isObjCObjectPointerType())))
ConvTy = Compatible;
// If the RHS is a unary plus or minus, check to see if they = and + are
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 35c5567503..d0d61c6ed1 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -907,7 +907,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
return true;
// Conversion from a null pointer constant to any Objective-C pointer type.
- if (Context.isObjCObjectPointerType(ToType) &&
+ if (ToType->isObjCObjectPointerType() &&
From->isNullPointerConstant(Context)) {
ConvertedType = ToType;
return true;
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 63191e0e00..bd2b0aef3d 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -669,14 +669,14 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
FirstType = static_cast<Expr*>(First)->getType();
}
- if (!Context.isObjCObjectPointerType(FirstType))
+ if (!FirstType->isObjCObjectPointerType())
Diag(ForLoc, diag::err_selector_element_type)
<< FirstType << First->getSourceRange();
}
if (Second) {
DefaultFunctionArrayConversion(Second);
QualType SecondType = Second->getType();
- if (!Context.isObjCObjectPointerType(SecondType))
+ if (!SecondType->isObjCObjectPointerType())
Diag(ForLoc, diag::err_collection_expr_type)
<< SecondType << Second->getSourceRange();
}
@@ -1161,7 +1161,7 @@ Sema::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
if (PVD->isInvalidDecl())
return StmtError();
- if (!Context.isObjCObjectPointerType(PVD->getType()))
+ if (!PVD->getType()->isObjCObjectPointerType())
return StmtError(Diag(PVD->getLocation(),
diag::err_catch_param_not_objc_type));
if (PVD->getType()->isObjCQualifiedIdType())
@@ -1203,7 +1203,7 @@ Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, ExprArg expr,Scope *CurScope) {
} else {
QualType ThrowType = ThrowExpr->getType();
// Make sure the expression type is an ObjC pointer or "void *".
- if (!Context.isObjCObjectPointerType(ThrowType)) {
+ if (!ThrowType->isObjCObjectPointerType()) {
const PointerType *PT = ThrowType->getAsPointerType();
if (!PT || !PT->getPointeeType()->isVoidType())
return StmtError(Diag(AtLoc, diag::error_objc_throw_expects_object)
@@ -1220,7 +1220,7 @@ Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, ExprArg SynchExpr,
// Make sure the expression type is an ObjC pointer or "void *".
Expr *SyncExpr = static_cast<Expr*>(SynchExpr.get());
- if (!Context.isObjCObjectPointerType(SyncExpr->getType())) {
+ if (!SyncExpr->getType()->isObjCObjectPointerType()) {
const PointerType *PT = SyncExpr->getType()->getAsPointerType();
if (!PT || !PT->getPointeeType()->isVoidType())
return StmtError(Diag(AtLoc, diag::error_objc_synchronized_expects_object)