File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
test/Interop/Cxx/class/inheritance Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -460,8 +460,14 @@ namespace {
460
460
461
461
unsigned baseOffset = 0 ;
462
462
if (auto cxxRecord = dyn_cast<clang::CXXRecordDecl>(ClangDecl)) {
463
- baseOffset =
464
- std::distance (cxxRecord->bases ().begin (), cxxRecord->bases ().end ());
463
+ baseOffset = llvm::count_if (cxxRecord->bases (), [](auto base) {
464
+ auto baseType = base.getType ().getCanonicalType ();
465
+
466
+ auto baseRecord = cast<clang::RecordType>(baseType)->getDecl ();
467
+ auto baseCxxRecord = cast<clang::CXXRecordDecl>(baseRecord);
468
+
469
+ return !baseCxxRecord->isEmpty ();
470
+ });
465
471
}
466
472
467
473
// Otherwise, project from the base.
Original file line number Diff line number Diff line change @@ -49,3 +49,12 @@ struct DerivedFromDerived : Derived {
49
49
};
50
50
51
51
struct DerivedFromNonTrivial : NonTrivial {};
52
+
53
+ struct EmptyBaseClass {
54
+ const char *inBase () const { return " EmptyBaseClass::inBase" ; }
55
+ };
56
+
57
+ struct DerivedFromEmptyBaseClass : EmptyBaseClass {
58
+ int a = 42 ;
59
+ int b = 42 ;
60
+ };
Original file line number Diff line number Diff line change @@ -69,4 +69,10 @@ FunctionsTestSuite.test("base member from derived from non trivial") {
69
69
expectEqual ( String ( cString: dnt. inNonTrivialWithArgs ( 0 , 1 ) !) , " NonTrivial::inNonTrivialWithArgs " )
70
70
}
71
71
72
+ FunctionsTestSuite . test ( " non-empty derived from empty class " ) {
73
+ let derived = DerivedFromEmptyBaseClass ( )
74
+ expectEqual ( String ( cString: derived. inBase ( ) !) , " EmptyBaseClass::inBase " )
75
+ expectEqual ( derived. b, 42 )
76
+ }
77
+
72
78
runAllTests ( )
You can’t perform that action at this time.
0 commit comments