Remove the CovariantThunk struct.

llvm-svn: 90523
This commit is contained in:
Anders Carlsson 2009-12-04 02:22:02 +00:00
parent 597c776c41
commit c521f952d6
1 changed files with 15 additions and 23 deletions

View File

@ -129,20 +129,11 @@ private:
typedef llvm::DenseMap<uint64_t, Thunk> ThunksMapTy; typedef llvm::DenseMap<uint64_t, Thunk> ThunksMapTy;
ThunksMapTy Thunks; ThunksMapTy Thunks;
/// CovariantThunk - Represents a single covariant thunk. /// BaseReturnTypes - Contains the base return types of methods who have been
struct CovariantThunk { /// overridden with methods whose return types require adjustment. Used for
CovariantThunk() { } /// generating covariant thunk information.
typedef llvm::DenseMap<uint64_t, CanQualType> BaseReturnTypesMapTy;
CovariantThunk(CanQualType ReturnType) BaseReturnTypesMapTy BaseReturnTypes;
: ReturnType(ReturnType) { }
/// ReturnType - The return type of the function.
CanQualType ReturnType;
};
/// CovariantThunks - The covariant thunks in a vtable.
typedef llvm::DenseMap<uint64_t, CovariantThunk> CovariantThunksMapTy;
CovariantThunksMapTy CovariantThunks;
/// PureVirtualMethods - Pure virtual methods. /// PureVirtualMethods - Pure virtual methods.
typedef llvm::DenseSet<GlobalDecl> PureVirtualMethodsSetTy; typedef llvm::DenseSet<GlobalDecl> PureVirtualMethodsSetTy;
@ -308,8 +299,8 @@ public:
Index_t Offset, int64_t CurrentVBaseOffset); Index_t Offset, int64_t CurrentVBaseOffset);
void InstallThunks() { void InstallThunks() {
for (CovariantThunksMapTy::const_iterator i = CovariantThunks.begin(), for (BaseReturnTypesMapTy::const_iterator i = BaseReturnTypes.begin(),
e = CovariantThunks.end(); i != e; ++i) { e = BaseReturnTypes.end(); i != e; ++i) {
uint64_t Index = i->first; uint64_t Index = i->first;
GlobalDecl GD = Methods[Index]; GlobalDecl GD = Methods[Index];
@ -317,7 +308,8 @@ public:
if (MD->isPure()) if (MD->isPure())
continue; continue;
const CovariantThunk &Thunk = i->second; QualType BaseReturnType = i->second;
assert(Index == VtableBuilder::Index[GD] && "Thunk index mismatch!"); assert(Index == VtableBuilder::Index[GD] && "Thunk index mismatch!");
// Check if there is an adjustment for the 'this' pointer. // Check if there is an adjustment for the 'this' pointer.
@ -334,17 +326,17 @@ public:
MD->getType()->getAs<FunctionType>()->getResultType(); MD->getType()->getAs<FunctionType>()->getResultType();
int64_t NonVirtualAdjustment = int64_t NonVirtualAdjustment =
getNVOffset(Thunk.ReturnType, DerivedType) / 8; getNVOffset(BaseReturnType, DerivedType) / 8;
int64_t VirtualAdjustment = int64_t VirtualAdjustment =
getVbaseOffset(Thunk.ReturnType, DerivedType); getVbaseOffset(BaseReturnType, DerivedType);
ThunkAdjustment ReturnAdjustment(NonVirtualAdjustment, VirtualAdjustment); ThunkAdjustment ReturnAdjustment(NonVirtualAdjustment, VirtualAdjustment);
CovariantThunkAdjustment Adjustment(ThisAdjustment, ReturnAdjustment); CovariantThunkAdjustment Adjustment(ThisAdjustment, ReturnAdjustment);
submethods[Index] = CGM.BuildCovariantThunk(MD, Extern, Adjustment); submethods[Index] = CGM.BuildCovariantThunk(MD, Extern, Adjustment);
} }
CovariantThunks.clear(); BaseReturnTypes.clear();
for (ThunksMapTy::const_iterator i = Thunks.begin(), e = Thunks.end(); for (ThunksMapTy::const_iterator i = Thunks.begin(), e = Thunks.end();
i != e; ++i) { i != e; ++i) {
@ -854,15 +846,15 @@ bool VtableBuilder::OverrideMethod(GlobalDecl GD, llvm::Constant *m,
// Check if we need a return type adjustment. // Check if we need a return type adjustment.
if (TypeConversionRequiresAdjustment(CGM.getContext(), ReturnType, if (TypeConversionRequiresAdjustment(CGM.getContext(), ReturnType,
OverriddenReturnType)) { OverriddenReturnType)) {
CovariantThunk &Adjustment = CovariantThunks[i]; CanQualType &BaseReturnType = BaseReturnTypes[i];
// Get the canonical return type. // Get the canonical return type.
CanQualType CanReturnType = CanQualType CanReturnType =
CGM.getContext().getCanonicalType(ReturnType); CGM.getContext().getCanonicalType(ReturnType);
// Insert the base return type. // Insert the base return type.
if (Adjustment.ReturnType.isNull()) if (BaseReturnType.isNull())
Adjustment.ReturnType = BaseReturnType =
CGM.getContext().getCanonicalType(OverriddenReturnType); CGM.getContext().getCanonicalType(OverriddenReturnType);
} }