[cfe-commits] r53998 - in /cfe/trunk: include/clang/AST/ASTContext.h lib/AST/ASTContext.cpp lib/Sema/Sema.cpp lib/Sema/Sema.h lib/Sema/SemaStmt.cpp

Ted Kremenek kremenek at apple.com
Thu Jul 24 16:58:27 PDT 2008


Author: kremenek
Date: Thu Jul 24 18:58:27 2008
New Revision: 53998

URL: http://llvm.org/viewvc/llvm-project?rev=53998&view=rev
Log:
Move isObjCObjectPointerType() from Sema to ASTContext.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/Sema.h
    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=53998&r1=53997&r2=53998&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Jul 24 18:58:27 2008
@@ -289,6 +289,16 @@
   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
   //===--------------------------------------------------------------------===//
   

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

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Jul 24 18:58:27 2008
@@ -1500,6 +1500,32 @@
   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
 //===----------------------------------------------------------------------===//

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Jul 24 18:58:27 2008
@@ -26,27 +26,6 @@
          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();

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=53998&r1=53997&r2=53998&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Jul 24 18:58:27 2008
@@ -344,12 +344,6 @@
   /// 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

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Jul 24 18:58:27 2008
@@ -563,14 +563,14 @@
         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());
   }





More information about the cfe-commits mailing list