diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/VTableBuilder.cpp | 5 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGVTT.cpp | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGVTables.cpp | 23 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGVTables.h | 12 |
4 files changed, 17 insertions, 26 deletions
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp index 63ac6f2c4a0..408fbad17a2 100644 --- a/clang/lib/AST/VTableBuilder.cpp +++ b/clang/lib/AST/VTableBuilder.cpp @@ -2282,8 +2282,7 @@ VTableLayout::VTableLayout(uint64_t NumVTableComponents, VTableLayout::~VTableLayout() { } ItaniumVTableContext::ItaniumVTableContext(ASTContext &Context) - : IsMicrosoftABI(Context.getTargetInfo().getCXXABI().isMicrosoft()) { -} + : VTableContextBase(/*MS=*/false) {} ItaniumVTableContext::~ItaniumVTableContext() { llvm::DeleteContainerSeconds(VTableLayouts); @@ -2348,8 +2347,6 @@ static VTableLayout *CreateVTableLayout(const ItaniumVTableBuilder &Builder) { void ItaniumVTableContext::computeVTableRelatedInformation(const CXXRecordDecl *RD) { - assert(!IsMicrosoftABI && "Shouldn't be called in this ABI!"); - const VTableLayout *&Entry = VTableLayouts[RD]; // Check if we've computed this information before. diff --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp index bfff4705889..bca5f29d946 100644 --- a/clang/lib/CodeGen/CGVTT.cpp +++ b/clang/lib/CodeGen/CGVTT.cpp @@ -66,7 +66,8 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT, if (VTTVT.getBase() == RD) { // Just get the address point for the regular vtable. AddressPoint = - ItaniumVTContext.getVTableLayout(RD).getAddressPoint(i->VTableBase); + getItaniumVTableContext().getVTableLayout(RD).getAddressPoint( + i->VTableBase); assert(AddressPoint != 0 && "Did not find vtable address point!"); } else { AddressPoint = VTableAddressPoints[i->VTableIndex].lookup(i->VTableBase); diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index a5967fddf24..2edce5d27dd 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -29,14 +29,11 @@ using namespace clang; using namespace CodeGen; -CodeGenVTables::CodeGenVTables(CodeGenModule &CGM) - : CGM(CGM), ItaniumVTContext(CGM.getContext()) { - if (CGM.getTarget().getCXXABI().isMicrosoft()) { - // FIXME: Eventually, we should only have one of V*TContexts available. - // Today we use both in the Microsoft ABI as MicrosoftVFTableContext - // is not completely supported in CodeGen yet. - MicrosoftVTContext.reset(new MicrosoftVTableContext(CGM.getContext())); - } +CodeGenVTables::CodeGenVTables(CodeGenModule &CGM) : CGM(CGM) { + if (CGM.getTarget().getCXXABI().isMicrosoft()) + VTContext.reset(new MicrosoftVTableContext(CGM.getContext())); + else + VTContext.reset(new ItaniumVTableContext(CGM.getContext())); } llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD, @@ -465,12 +462,8 @@ void CodeGenVTables::EmitThunks(GlobalDecl GD) if (isa<CXXDestructorDecl>(MD) && GD.getDtorType() == Dtor_Base) return; - const VTableContextBase::ThunkInfoVectorTy *ThunkInfoVector; - if (MicrosoftVTContext.isValid()) { - ThunkInfoVector = MicrosoftVTContext->getThunkInfo(GD); - } else { - ThunkInfoVector = ItaniumVTContext.getThunkInfo(GD); - } + const VTableContextBase::ThunkInfoVectorTy *ThunkInfoVector = + VTContext->getThunkInfo(GD); if (!ThunkInfoVector) return; @@ -608,7 +601,7 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD, DI->completeClassData(Base.getBase()); OwningPtr<VTableLayout> VTLayout( - ItaniumVTContext.createConstructionVTableLayout( + getItaniumVTableContext().createConstructionVTableLayout( Base.getBase(), Base.getBaseOffset(), BaseIsVirtual, RD)); // Add the address points. diff --git a/clang/lib/CodeGen/CGVTables.h b/clang/lib/CodeGen/CGVTables.h index e8cd55eed80..a8768c22cc2 100644 --- a/clang/lib/CodeGen/CGVTables.h +++ b/clang/lib/CodeGen/CGVTables.h @@ -31,10 +31,8 @@ namespace CodeGen { class CodeGenVTables { CodeGenModule &CGM; - // FIXME: Consider moving ItaniumVTContext and MicrosoftVTContext into - // respective CXXABI classes? - ItaniumVTableContext ItaniumVTContext; - OwningPtr<MicrosoftVTableContext> MicrosoftVTContext; + // FIXME: Consider moving VTContext into respective CXXABI classes? + OwningPtr<VTableContextBase> VTContext; /// VTableAddressPointsMapTy - Address points for a single vtable. typedef llvm::DenseMap<BaseSubobject, uint64_t> VTableAddressPointsMapTy; @@ -72,10 +70,12 @@ public: CodeGenVTables(CodeGenModule &CGM); - ItaniumVTableContext &getItaniumVTableContext() { return ItaniumVTContext; } + ItaniumVTableContext &getItaniumVTableContext() { + return *cast<ItaniumVTableContext>(VTContext.get()); + } MicrosoftVTableContext &getMicrosoftVTableContext() { - return *MicrosoftVTContext.get(); + return *cast<MicrosoftVTableContext>(VTContext.get()); } /// getSubVTTIndex - Return the index of the sub-VTT for the base class of the |