From 104f45c685e5a97306aa72c79f4d068e2999db62 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 12 Feb 2010 17:37:14 +0000 Subject: [PATCH] Start stubbing out more of the covariant thunk support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95990 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGVtable.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index 360201e088..93153e31b6 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -104,9 +104,10 @@ TypeConversionRequiresAdjustment(ASTContext &Ctx, } static bool -ReturnTypeConversionRequiresAdjustment(ASTContext &Context, - const CXXMethodDecl *DerivedMD, +ReturnTypeConversionRequiresAdjustment(const CXXMethodDecl *DerivedMD, const CXXMethodDecl *BaseMD) { + ASTContext &Context = DerivedMD->getASTContext(); + const FunctionType *BaseFT = BaseMD->getType()->getAs(); const FunctionType *DerivedFT = DerivedMD->getType()->getAs(); @@ -290,8 +291,7 @@ void FinalOverriders::PropagateOverrider(const CXXMethodDecl *OldMD, /// need to have their return types adjusted. if (!Overrider.NeedsReturnAdjustment) { Overrider.NeedsReturnAdjustment = - ReturnTypeConversionRequiresAdjustment(Context, NewMD, - OverriddenMD); + ReturnTypeConversionRequiresAdjustment(NewMD, OverriddenMD); } // Set the new overrider. @@ -540,6 +540,17 @@ private: /// AddressPoints - Address points for the vtable being built. CGVtableInfo::AddressPointsMapTy AddressPoints; + /// ReturnAdjustment - A return adjustment thunk. + struct ReturnAdjustment { + /// NonVirtual - The non-virtual adjustment from the derived object to its + /// nearest virtual base. + int64_t NonVirtual; + + /// VBaseOffsetIndex - The index relative to the address point of the + /// virtual base class offset. + int64_t VBaseOffsetIndex; + }; + void layoutVirtualMemberFunctions(BaseSubobject Base, PrimaryBasesSetTy &PrimaryBases); @@ -614,10 +625,10 @@ VtableBuilder::layoutVirtualMemberFunctions(BaseSubobject Base, // Check if this virtual member function overrides a method in a primary // base. If this is the case, and the return type doesn't require adjustment // then we can just use the member function from the primary base. - if (OverridesMethodInPrimaryBase(MD, PrimaryBases)) { - assert(!ReturnTypeConversionRequiresAdjustment(Context, Overrider.Method, - MD) && - "FIXME: Handle covariant thunks!"); + if (const CXXMethodDecl *OverriddenMD = + OverridesMethodInPrimaryBase(MD, PrimaryBases)) { + assert(!ReturnTypeConversionRequiresAdjustment(MD, OverriddenMD) + && "FIXME: Handle covariant thunks!"); continue; } @@ -1920,8 +1931,7 @@ void CGVtableInfo::ComputeMethodVtableIndices(const CXXRecordDecl *RD) { OverridesMethodInPrimaryBase(MD, PrimaryBases)) { // Check if converting from the return type of the method to the // return type of the overridden method requires conversion. - if (!ReturnTypeConversionRequiresAdjustment(CGM.getContext(), - MD, OverriddenMD)) { + if (!ReturnTypeConversionRequiresAdjustment(MD, OverriddenMD)) { // This index is shared between the index in the vtable of the primary // base class. if (const CXXDestructorDecl *DD = dyn_cast(MD)) { -- 2.40.0