Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaExprCXX.cpp +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp @@ -4720,10 +4720,24 @@ // regard to cv-qualifiers. const RecordType *lhsRecord = LhsT->getAs(); - if (!lhsRecord) return false; - const RecordType *rhsRecord = RhsT->getAs(); - if (!rhsRecord) return false; + if (!rhsRecord || !lhsRecord) { + const ObjCObjectType *LHSObjTy = LhsT->getAs(); + const ObjCObjectType *RHSObjTy = RhsT->getAs(); + if (!LHSObjTy || !RHSObjTy) + return false; + + ObjCInterfaceDecl *BaseInterface = LHSObjTy->getInterface(); + ObjCInterfaceDecl *DerivedInterface = RHSObjTy->getInterface(); + if (!BaseInterface || !DerivedInterface) + return false; + + if (Self.RequireCompleteType( + KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr)) + return false; + + return BaseInterface->isSuperClassOf(DerivedInterface); + } assert(Self.Context.hasSameUnqualifiedType(LhsT, RhsT) == (lhsRecord == rhsRecord)); Index: cfe/trunk/test/SemaObjCXX/is-base-of.mm =================================================================== --- cfe/trunk/test/SemaObjCXX/is-base-of.mm +++ cfe/trunk/test/SemaObjCXX/is-base-of.mm @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +@interface NSObj +@end + +@interface NSChild : NSObj +@end + +static_assert(__is_base_of(NSObj, NSChild), ""); +static_assert(!__is_base_of(NSChild, NSObj), ""); + +static_assert(__is_base_of(NSObj, NSObj), ""); + +static_assert(!__is_base_of(NSObj *, NSChild *), ""); +static_assert(!__is_base_of(NSChild *, NSObj *), ""); + +static_assert(__is_base_of(const volatile NSObj, NSChild), ""); +static_assert(__is_base_of(NSObj, const volatile NSChild), ""); + +@class NSForward; // expected-note{{forward declaration of class}} + +static_assert(!__is_base_of(NSForward, NSObj), ""); +static_assert(!__is_base_of(NSObj, NSForward), ""); // expected-error{{incomplete type 'NSForward'}} + +static_assert(!__is_base_of(id, NSObj), "");