]> granicus.if.org Git - clang/commitdiff
Move isObjCObjectPointerType() from Sema to ASTContext.
authorTed Kremenek <kremenek@apple.com>
Thu, 24 Jul 2008 23:58:27 +0000 (23:58 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 24 Jul 2008 23:58:27 +0000 (23:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53998 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ASTContext.h
lib/AST/ASTContext.cpp
lib/Sema/Sema.cpp
lib/Sema/Sema.h
lib/Sema/SemaStmt.cpp

index 7572d18ca3611d7d1a44d080bf62c6dd3cadadc2..c981aa4116b4e178f006e548392f27c77f3b05f8 100644 (file)
@@ -288,6 +288,16 @@ public:
   void setBuiltinVaListType(QualType T);
   QualType getBuiltinVaListType() const { return BuiltinVaListType; }
     
+  //===--------------------------------------------------------------------===//
+  //                         Type Predicates.
+  //===--------------------------------------------------------------------===//
+  
+  /// 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;
+    
   //===--------------------------------------------------------------------===//
   //                         Type Sizing and Analysis
   //===--------------------------------------------------------------------===//
index fa12364c52f6789c6afdd674770c9d57da1e519e..54cc8e00683e5e04c0f4bbec4d5ba09b86298026 100644 (file)
@@ -1500,6 +1500,32 @@ void ASTContext::setObjCConstantStringInterface(ObjCInterfaceDecl *Decl) {
   ObjCConstantStringType = getObjCInterfaceType(Decl);
 }
 
+
+//===----------------------------------------------------------------------===//
+//                        Type Predicates.
+//===----------------------------------------------------------------------===//
+
+/// 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->isObjCQualifiedIdType())
+    return true;
+  
+  if (!Ty->isPointerType())
+    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 == getObjCIdType() || Ty == getObjCClassType())
+    return true;
+  
+  // If this a pointer to an interface (e.g. NSString*), it is ok.
+  return Ty->getAsPointerType()->getPointeeType()->isObjCInterfaceType();
+}
+
 //===----------------------------------------------------------------------===//
 //                        Type Compatibility Testing
 //===----------------------------------------------------------------------===//
index 32c769b64d98f61f9af2ce11abc893dd793b4f25..e2986a87a54dac2370b3d9d9474dfdef44ab8a82 100644 (file)
@@ -26,27 +26,6 @@ bool Sema::isBuiltinObjCType(TypedefDecl *TD) {
          strcmp(typeName, "SEL") == 0 || strcmp(typeName, "Protocol") == 0;
 }
 
-/// 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 Sema::isObjCObjectPointerType(QualType Ty) const {
-  if (Ty->isObjCQualifiedIdType())
-    return true;
-  
-  if (!Ty->isPointerType())
-    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 == Context.getObjCIdType() || Ty == Context.getObjCClassType())
-    return true;
-  
-  // If this a pointer to an interface (e.g. NSString*), it is ok.
-  return Ty->getAsPointerType()->getPointeeType()->isObjCInterfaceType();
-}
-
 void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
   TUScope = S;
   CurContext = Context.getTranslationUnitDecl();
index d34e7f374053bd108a235db0380722d789aadda6..b87008256acb5e0afcedf777296a5d86a1cc4adb 100644 (file)
@@ -344,12 +344,6 @@ private:
   /// isBuiltinObjCType - Returns true of the type is "id", "SEL", "Class"
   /// or "Protocol".
   bool isBuiltinObjCType(TypedefDecl *TD);
-  
-  /// 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 type) const;
 
   /// AddInstanceMethodToGlobalPool - All instance methods in a translation
   /// unit are added to a global pool. This allows us to efficiently associate
index 5b2da087840be32ebf85526db5a3859d621dc305..1462d3d57c25f2fee689edefaddddcd0982f6e47 100644 (file)
@@ -563,14 +563,14 @@ Sema::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
         return Diag(D->getLocation(), diag::err_toomany_element_decls);
     } else
       FirstType = static_cast<Expr*>(first)->getType();
-    if (!isObjCObjectPointerType(FirstType))
+    if (!Context.isObjCObjectPointerType(FirstType))
         Diag(ForLoc, diag::err_selector_element_type,
              FirstType.getAsString(), First->getSourceRange());
   }
   if (Second) {
     DefaultFunctionArrayConversion(Second);
     QualType SecondType = Second->getType();
-    if (!isObjCObjectPointerType(SecondType))
+    if (!Context.isObjCObjectPointerType(SecondType))
       Diag(ForLoc, diag::err_collection_expr_type,
            SecondType.getAsString(), Second->getSourceRange());
   }