================ @@ -6027,6 +6027,33 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceI return cast<CXXRecordDecl>(rhsRecord->getDecl()) ->isDerivedFrom(cast<CXXRecordDecl>(lhsRecord->getDecl())); } + case BTT_IsVirtualBaseOf: { + const RecordType *BaseRecord = LhsT->getAs<RecordType>(); + const RecordType *DerivedRecord = RhsT->getAs<RecordType>(); + + if (!BaseRecord || !DerivedRecord) { + DiagnoseVLAInCXXTypeTrait(Self, Lhs, tok::kw___is_virtual_base_of); + DiagnoseVLAInCXXTypeTrait(Self, Rhs, tok::kw___is_virtual_base_of); + return false; + } + + if (BaseRecord->isUnionType() || DerivedRecord->isUnionType()) + return false; + + if (!BaseRecord->isStructureOrClassType() || + !DerivedRecord->isStructureOrClassType()) + return false; + + if (Self.RequireCompleteType(Rhs->getTypeLoc().getBeginLoc(), RhsT, ---------------- AaronBallman wrote:
I hadn't realized that `is_base_of` already has the same requirement, so I don't insist on a change here. But that said, this presumes users don't have typos they'd like to catch. e.g., ``` struct Bee { }; struct Be; struct Derived : virtual Bee {}; static_assert(!__is_virtual_base_of(Be, Derived)); // Oops, I can't spell very well! ``` I think it would be *much* kinder to tell the user that `Be` is incomplete than let them be surprised. https://github.com/llvm/llvm-project/pull/100393 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits