[cfe-commits] r76076 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/AST/Expr.cpp lib/Analysis/CFRefCount.cpp lib/Analysis/CheckObjCDealloc.cpp lib/Analysis/GRExprEngineInternalChecks.cpp lib/Analysis/Store.cpp lib/CodeGen/CGBlocks.h lib/CodeGen/CGExpr.cpp lib/CodeGen/CGObjCMac.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaOverload.cpp lib/Sema/SemaStmt.cpp

Steve Naroff snaroff at apple.com
Thu Jul 16 08:41:00 PDT 2009


Author: snaroff
Date: Thu Jul 16 10:41:00 2009
New Revision: 76076

URL: http://llvm.org/viewvc/llvm-project?rev=76076&view=rev
Log:
Remove ASTContext::isObjCObjectPointerType().
Convert all clients to use the new predicate on Type.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/Analysis/CFRefCount.cpp
    cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
    cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp
    cfe/trunk/lib/Analysis/Store.cpp
    cfe/trunk/lib/CodeGen/CGBlocks.h
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/CodeGen/CGObjCMac.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Jul 16 10:41:00 2009
@@ -534,12 +534,6 @@
   //===--------------------------------------------------------------------===//
  
 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.
   ///

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Jul 16 10:41:00 2009
@@ -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;

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Jul 16 10:41:00 2009
@@ -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;
         
     }

Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Jul 16 10:41:00 2009
@@ -881,7 +881,7 @@
 //===----------------------------------------------------------------------===//
 
 bool RetainSummaryManager::isTrackedObjCObjectType(QualType Ty) {
-  if (!Ctx.isObjCObjectPointerType(Ty))
+  if (!Ty->isObjCObjectPointerType())
     return false;
 
   const ObjCObjectPointerType *PT = Ty->getAsObjCObjectPointerType();

Modified: cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckObjCDealloc.cpp Thu Jul 16 10:41:00 2009
@@ -108,7 +108,7 @@
     ObjCIvarDecl* ID = *I;
     QualType T = ID->getType();
     
-    if (!Ctx.isObjCObjectPointerType(T) ||
+    if (!T->isObjCObjectPointerType() ||
         ID->getAttr<IBOutletAttr>()) // Skip IBOutlets.
       continue;
     
@@ -210,7 +210,7 @@
       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();

Modified: cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngineInternalChecks.cpp Thu Jul 16 10:41:00 2009
@@ -718,7 +718,7 @@
           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 @@
         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;
             }

Modified: cfe/trunk/lib/Analysis/Store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Store.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/Store.cpp (original)
+++ cfe/trunk/lib/Analysis/Store.cpp Thu Jul 16 10:41:00 2009
@@ -55,7 +55,7 @@
   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);
   }

Modified: cfe/trunk/lib/CodeGen/CGBlocks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.h (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.h Thu Jul 16 10:41:00 2009
@@ -223,7 +223,7 @@
       return true;
     if (getContext().isObjCNSObjectType(Ty))
       return true;
-    if (getContext().isObjCObjectPointerType(Ty))
+    if (Ty->isObjCObjectPointerType())
       return true;
     return false;
   }

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jul 16 10:41:00 2009
@@ -1070,7 +1070,7 @@
       if (attr == QualType::Weak)
         attr = QualType::GCNone;
     }
-    else if (getContext().isObjCObjectPointerType(Ty))
+    else if (Ty->isObjCObjectPointerType())
       attr = QualType::Strong;
   }
   LValue LV =  

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Jul 16 10:41:00 2009
@@ -3005,7 +3005,7 @@
   if (FQT.isObjCGCWeak())
     return QualType::Weak;
 
-  if (Ctx.isObjCObjectPointerType(FQT))
+  if (FQT->isObjCObjectPointerType())
     return QualType::Strong;
 
   if (const PointerType *PT = FQT->getAsPointerType())

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jul 16 10:41:00 2009
@@ -4271,7 +4271,7 @@
     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.

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jul 16 10:41:00 2009
@@ -25,7 +25,7 @@
   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 @@
 
   // 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 @@
   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);

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jul 16 10:41:00 2009
@@ -4500,9 +4500,9 @@
     // 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

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Jul 16 10:41:00 2009
@@ -907,7 +907,7 @@
     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;

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=76076&r1=76075&r2=76076&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Jul 16 10:41:00 2009
@@ -669,14 +669,14 @@
 
       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 @@
     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 @@
   } 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 @@
 
   // 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)





More information about the cfe-commits mailing list