diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2008-01-07 20:12:21 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-01-07 20:12:21 +0000 |
commit | c5ae5cf88ff108f7a325c7b686f78c02517a44e5 (patch) | |
tree | 86101571f60c96f8dbcad83c9c22358df0f27b5b | |
parent | 4d730461735cc5cb8ecbd2f6106da9ec234064ad (diff) |
Verify/add code to make sure types passed to interfaceTypesAreCompatible
are canonical. Asst in interfaceTypesAreCompatible if they are not.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45717 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | AST/ASTContext.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index a9a3d57293..e8e5bcc6ab 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -1250,7 +1250,13 @@ bool ASTContext::objcTypesAreCompatible(QualType lhs, QualType rhs) { return false; } +/// Check that 'lhs' and 'rhs' are compatible interface types. Both types +/// must be canonical types. bool ASTContext::interfaceTypesAreCompatible(QualType lhs, QualType rhs) { + assert (lhs->isCanonical() && + "interfaceTypesAreCompatible strip typedefs of lhs"); + assert (rhs->isCanonical() && + "interfaceTypesAreCompatible strip typedefs of rhs"); if (lhs == rhs) return true; ObjCInterfaceType *lhsIT = cast<ObjCInterfaceType>(lhs.getTypePtr()); @@ -1274,8 +1280,9 @@ bool ASTContext::QualifiedInterfaceTypesAreCompatible(QualType lhs, ObjCQualifiedInterfaceType *rhsQI = dyn_cast<ObjCQualifiedInterfaceType>(rhs.getCanonicalType().getTypePtr()); assert(rhsQI && "QualifiedInterfaceTypesAreCompatible - bad rhs type"); - if (!interfaceTypesAreCompatible(getObjCInterfaceType(lhsQI->getDecl()), - getObjCInterfaceType(rhsQI->getDecl()))) + if (!interfaceTypesAreCompatible( + getObjCInterfaceType(lhsQI->getDecl()).getCanonicalType(), + getObjCInterfaceType(rhsQI->getDecl()).getCanonicalType())) return false; /* All protocols in lhs must have a presense in rhs. */ for (unsigned i =0; i < lhsQI->getNumProtocols(); i++) { |