diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-04-07 04:13:03 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-04-07 04:13:03 +0000 |
| commit | ae1b6078e3d6010a6e798c95062a2ddf6a4edbc4 (patch) | |
| tree | c7aefe605ce2d83ab200ae865ade1db2c3254998 /clang/lib/AST/ASTContext.cpp | |
| parent | ddfdaf9a696f3e9cd96042bf95bccc465b8c4f97 (diff) | |
| download | bcm5719-llvm-ae1b6078e3d6010a6e798c95062a2ddf6a4edbc4.tar.gz bcm5719-llvm-ae1b6078e3d6010a6e798c95062a2ddf6a4edbc4.zip | |
This predicate is just a generic "issuperclass" predicate, move it to the
ObjCInterfaceType as a method.
llvm-svn: 49306
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a0bbac74855..6e0bfa1a98c 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1443,20 +1443,6 @@ bool ASTContext::objcTypesAreCompatible(QualType LHS, QualType RHS) { return false; } -/// isCompatibleInterfaceAssign - Return true if it is ok to assign a -/// pointer from the RHS interface to the LHS interface. This is true if the -/// RHS is exactly LHS or if it is a subclass of LHS. -static bool isCompatibleInterfaceAssign(ObjCInterfaceDecl *LHS, - ObjCInterfaceDecl *RHS) { - // If RHS is derived from LHS it is OK; else it is not OK. - while (RHS != NULL) { - if (RHS == LHS) - return true; - RHS = RHS->getSuperClass(); - } - return false; -} - bool ASTContext::QualifiedInterfaceTypesAreCompatible(QualType lhs, QualType rhs) { const ObjCQualifiedInterfaceType *lhsQI = @@ -1465,7 +1451,9 @@ bool ASTContext::QualifiedInterfaceTypesAreCompatible(QualType lhs, rhs->getAsObjCQualifiedInterfaceType(); assert(lhsQI && rhsQI && "QualifiedInterfaceTypesAreCompatible - bad type"); - if (!isCompatibleInterfaceAssign(lhsQI->getDecl(), rhsQI->getDecl())) + // Verify that the base decls are compatible, the RHS must be a subclass of + // the LHS. + if (!lhsQI->getDecl()->isSuperClassOf(rhsQI->getDecl())) return false; // All protocols in lhs must have a presence in rhs. @@ -1857,8 +1845,9 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) { case Type::Builtin: return builtinTypesAreCompatible(LHS, RHS); case Type::ObjCInterface: - return isCompatibleInterfaceAssign(cast<ObjCInterfaceType>(LHS)->getDecl(), - cast<ObjCInterfaceType>(RHS)->getDecl()); + // The LHS must be a superclass of the RHS. + return cast<ObjCInterfaceType>(LHS)->getDecl()->isSuperClassOf( + cast<ObjCInterfaceType>(RHS)->getDecl()); case Type::Vector: case Type::OCUVector: return vectorTypesAreCompatible(LHS, RHS); |

