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

Chris Lattner sabre at nondot.org
Sun Apr 6 21:17:40 PDT 2008


Author: lattner
Date: Sun Apr  6 23:17:40 2008
New Revision: 49307

URL: http://llvm.org/viewvc/llvm-project?rev=49307&view=rev
Log:
make QualifiedInterfaceTypesAreCompatible a static function
and start simplifying it.

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Sun Apr  6 23:17:40 2008
@@ -335,7 +335,6 @@
   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 {

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

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Apr  6 23:17:40 2008
@@ -1443,25 +1443,20 @@
   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 @@
   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");
   }





More information about the cfe-commits mailing list