From: Anders Carlsson Date: Mon, 29 Mar 2010 01:04:16 +0000 (+0000) Subject: Two bug fixes, we weren't updating the thunk index when creating the vtable initializ... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f6da6a082cc97cd496260875742241f9457185f5;p=clang Two bug fixes, we weren't updating the thunk index when creating the vtable initializer and we weren't storing the secondary virtual pointer indices. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99786 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGVTT.cpp b/lib/CodeGen/CGVTT.cpp index f2b2945290..6b21046b4c 100644 --- a/lib/CodeGen/CGVTT.cpp +++ b/lib/CodeGen/CGVTT.cpp @@ -165,6 +165,13 @@ VTTBuilder::GetAddrOfVTable(BaseSubobject Base, bool BaseIsVirtual, void VTTBuilder::AddVTablePointer(BaseSubobject Base, llvm::Constant *VTable, const CXXRecordDecl *VTableClass, const AddressPointsMapTy& AddressPoints) { + // Store the vtable pointer index if we're generating the primary VTT. + if (Base.getBase() == MostDerivedClass) { + assert(!SecondaryVirtualPointerIndices.count(Base) && + "A virtual pointer index already exists for this base subobject!"); + SecondaryVirtualPointerIndices[Base] = VTTComponents.size(); + } + if (!GenerateDefinition) { VTTComponents.push_back(0); return; diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index 4bdda985aa..804c684361 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -4080,6 +4080,8 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD, const ThunkInfo &Thunk = VTableThunks[NextVTableThunkIndex].second; Init = CGM.GetAddrOfThunk(GD, Thunk); + + NextVTableThunkIndex++; } else { const CXXMethodDecl *MD = cast(GD.getDecl()); const llvm::Type *Ty = CGM.getTypes().GetFunctionTypeForVtable(MD);