diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp index 2b8b064f2683..58989ede0bc9 100644 --- a/clang/lib/CodeGen/CGVtable.cpp +++ b/clang/lib/CodeGen/CGVtable.cpp @@ -985,10 +985,17 @@ VtableBuilder::AddVCallAndVBaseOffsets(BaseSubobject Base, void VtableBuilder::AddVCallOffsets(BaseSubobject Base) { const CXXRecordDecl *RD = Base.getBase(); - const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD); + + // Handle the primary base first. const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase(); - assert(!PrimaryBase && "FIXME: Handle the primary base!"); + if (PrimaryBase && Layout.getPrimaryBaseWasVirtual()) { + // Get the base offset of the primary base. + uint64_t PrimaryBaseOffset = Base.getBaseOffset() + + Layout.getBaseClassOffset(PrimaryBase); + + AddVCallOffsets(BaseSubobject(PrimaryBase, PrimaryBaseOffset)); + } // Add the vcall offsets. for (CXXRecordDecl::method_iterator I = RD->method_begin(),