From b5b32f5292a8c4e1be8fd5c2865ce48767ec63d5 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Thu, 3 Dec 2009 03:15:31 +0000 Subject: [PATCH] Use Eli's ComputeThunkAdjustment for calculating the return adjustment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90402 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGVtable.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index 007960e998..caac827016 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -274,18 +274,20 @@ public: Thunks.erase(i); } - - // Construct the return adjustment. + + QualType BaseType = QualType(Thunk.ReturnType)->getPointeeType(); QualType DerivedType = - MD->getType()->getAs()->getResultType(); + MD->getType()->getAs()->getResultType()->getPointeeType(); - int64_t NonVirtualAdjustment = - getNVOffset(Thunk.ReturnType, DerivedType) / 8; + const CXXRecordDecl *BaseDecl = + cast(BaseType->getAs()->getDecl()); - int64_t VirtualAdjustment = - getVbaseOffset(Thunk.ReturnType, DerivedType); + const CXXRecordDecl *DerivedDecl = + cast(DerivedType->getAs()->getDecl()); - ThunkAdjustment ReturnAdjustment(NonVirtualAdjustment, VirtualAdjustment); + // Construct the return adjustment. + ThunkAdjustment ReturnAdjustment = + CGM.ComputeThunkAdjustment(DerivedDecl, BaseDecl); CovariantThunkAdjustment Adjustment(ThisAdjustment, ReturnAdjustment); submethods[Index] = CGM.BuildCovariantThunk(MD, Extern, Adjustment); @@ -745,7 +747,7 @@ TypeConversionRequiresAdjustment(ASTContext &Ctx, } const CXXRecordDecl *DerivedDecl = - cast(cast(CanDerivedType)->getDecl()); + cast(cast(CanDerivedType)->getDecl()); const CXXRecordDecl *BaseDecl = cast(cast(CanBaseType)->getDecl()); -- 2.40.0