]> granicus.if.org Git - clang/commitdiff
make QualifiedInterfaceTypesAreCompatible a static function
authorChris Lattner <sabre@nondot.org>
Mon, 7 Apr 2008 04:17:40 +0000 (04:17 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 7 Apr 2008 04:17:40 +0000 (04:17 +0000)
and start simplifying it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49307 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 2accd9bf4b60a9ce89b94452bb4dcdde9bf0689c..188d440407d16ea4efa31efd66859c82f1ffe3ee 100644 (file)
@@ -335,7 +335,6 @@ public:
   bool builtinTypesAreCompatible(QualType, QualType);
   bool vectorTypesAreCompatible(QualType, QualType);
   
-  bool QualifiedInterfaceTypesAreCompatible(QualType, QualType);
   bool ObjCQualifiedIdTypesAreCompatible(QualType, QualType, bool = false);
   bool objcTypesAreCompatible(QualType, QualType);
   bool isObjCIdType(QualType T) const {
index 6e0bfa1a98c0e41972afca3bec93637ebfb14d5e..9131db84f6279576c73ad5ae6fb45a4938fd919f 100644 (file)
@@ -1443,25 +1443,20 @@ bool ASTContext::objcTypesAreCompatible(QualType LHS, QualType RHS) {
   return false;
 }
 
-bool ASTContext::QualifiedInterfaceTypesAreCompatible(QualType lhs, 
-                                                      QualType rhs) {
-  const ObjCQualifiedInterfaceType *lhsQI =
-    lhs->getAsObjCQualifiedInterfaceType();
-  const ObjCQualifiedInterfaceType *rhsQI = 
-    rhs->getAsObjCQualifiedInterfaceType();
-  assert(lhsQI && rhsQI && "QualifiedInterfaceTypesAreCompatible - bad type");
-  
-  // Verify that the base decls are compatible, the RHS must be a subclass of
+static bool 
+areCompatObjCQualInterfaces(const ObjCQualifiedInterfaceType *LHS, 
+                            const ObjCQualifiedInterfaceType *RHS) {
+  // Verify that the base decls are compatible: the RHS must be a subclass of
   // the LHS.
-  if (!lhsQI->getDecl()->isSuperClassOf(rhsQI->getDecl()))
+  if (!LHS->getDecl()->isSuperClassOf(RHS->getDecl()))
     return false;
   
-  // All protocols in lhs must have a presence in rhs.
-  for (unsigned i = 0; i != lhsQI->getNumProtocols(); ++i) {
+  // All protocols in LHS must have a presence in RHS.
+  for (unsigned i = 0; i != LHS->getNumProtocols(); ++i) {
     bool match = false;
-    ObjCProtocolDecl *lhsProto = lhsQI->getProtocols(i);
-    for (unsigned j = 0; j != rhsQI->getNumProtocols(); ++j) {
-      ObjCProtocolDecl *rhsProto = rhsQI->getProtocols(j);
+    ObjCProtocolDecl *lhsProto = LHS->getProtocols(i);
+    for (unsigned j = 0; j != RHS->getNumProtocols(); ++j) {
+      ObjCProtocolDecl *rhsProto = RHS->getProtocols(j);
       if (lhsProto == rhsProto) {
         match = true;
         break;
@@ -1852,7 +1847,8 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) {
   case Type::OCUVector:
     return vectorTypesAreCompatible(LHS, RHS);
   case Type::ObjCQualifiedInterface:
-    return QualifiedInterfaceTypesAreCompatible(LHS, RHS);
+    return areCompatObjCQualInterfaces(cast<ObjCQualifiedInterfaceType>(LHS),
+                                       cast<ObjCQualifiedInterfaceType>(RHS));
   default:
     assert(0 && "unexpected type");
   }