From 439dbadeada35a73e0b182270456ed76dda635d4 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 7 Apr 2008 01:30:37 +0000 Subject: [PATCH] simplify the logic in ASTContext::objcTypesAreCompatible git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49302 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 12eb5a15de..36c0a4dc6f 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1422,23 +1422,23 @@ bool ASTContext::builtinTypesAreCompatible(QualType lhs, QualType rhs) { /// are of different class; one is interface type or is /// a qualified interface type and the other type is of a different class. /// Example, II or II

. -bool ASTContext::objcTypesAreCompatible(QualType lhs, QualType rhs) { - if (lhs->isObjCInterfaceType() && isObjCIdType(rhs)) +bool ASTContext::objcTypesAreCompatible(QualType LHS, QualType RHS) { + // ID is compatible with all interface types. + if (LHS->isObjCInterfaceType() && isObjCIdType(RHS)) return true; - else if (isObjCIdType(lhs) && rhs->isObjCInterfaceType()) + else if (isObjCIdType(LHS) && RHS->isObjCInterfaceType()) return true; - if (const ObjCInterfaceType *lhsIT = lhs->getAsObjCInterfaceType()) { - const ObjCQualifiedInterfaceType *rhsQI = - rhs->getAsObjCQualifiedInterfaceType(); - if (!isa(lhsIT)) - return rhsQI && (lhsIT->getDecl() == rhsQI->getDecl()); - } - if (const ObjCInterfaceType *rhsIT = rhs->getAsObjCInterfaceType()) { - const ObjCQualifiedInterfaceType *lhsQI = - lhs->getAsObjCQualifiedInterfaceType(); - if (!isa(rhsIT)) - return lhsQI && (rhsIT->getDecl() == lhsQI->getDecl()); + // II is compatible with II

if the base is the same. Otherwise, no two + // qualified interface types are the same. + if (const ObjCInterfaceType *LHSIT = LHS->getAsObjCInterfaceType()) { + if (const ObjCInterfaceType *RHSIT = RHS->getAsObjCInterfaceType()) { + // If the base decls match and one is a qualified interface and one isn't, + // then they are compatible. + return LHSIT->getDecl() == RHSIT->getDecl() && + isa(LHSIT) != + isa(RHSIT); + } } return false; } -- 2.40.0