diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-07 04:17:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-07 04:17:40 +0000 |
commit | 3b27546b42bc3d5ec261f3228192350affb370be (patch) | |
tree | 37d7ba78ea9b0c227039ec0ea28cd5b130d36bac /lib/AST/ASTContext.cpp | |
parent | 53efc251792bf2c9c5f295bd3507facc51a1fe7e (diff) |
make QualifiedInterfaceTypesAreCompatible a static function
and start simplifying it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49307 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 6e0bfa1a98..9131db84f6 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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"); } |