Convert offset parameter in LayoutPrimaryAndSecondaryVTables() to CharUnits.

No change in functionality intended.

llvm-svn: 128393
This commit is contained in:
Ken Dyck 2011-03-27 20:33:38 +00:00
parent 9a7e532dd8
commit f9742cca31
1 changed files with 16 additions and 16 deletions

View File

@ -1127,7 +1127,7 @@ private:
void LayoutPrimaryAndSecondaryVTables(BaseSubobject Base, void LayoutPrimaryAndSecondaryVTables(BaseSubobject Base,
bool BaseIsMorallyVirtual, bool BaseIsMorallyVirtual,
bool BaseIsVirtualInLayoutClass, bool BaseIsVirtualInLayoutClass,
uint64_t OffsetInLayoutClass); CharUnits OffsetInLayoutClass);
/// LayoutSecondaryVTables - Layout the secondary vtables for the given base /// LayoutSecondaryVTables - Layout the secondary vtables for the given base
/// subobject. /// subobject.
@ -1728,7 +1728,7 @@ void VTableBuilder::LayoutVTable() {
CharUnits::Zero()), CharUnits::Zero()),
/*BaseIsMorallyVirtual=*/false, /*BaseIsMorallyVirtual=*/false,
MostDerivedClassIsVirtual, MostDerivedClassIsVirtual,
Context.toBits(MostDerivedClassOffset)); MostDerivedClassOffset);
VisitedVirtualBasesSetTy VBases; VisitedVirtualBasesSetTy VBases;
@ -1744,13 +1744,13 @@ void
VTableBuilder::LayoutPrimaryAndSecondaryVTables(BaseSubobject Base, VTableBuilder::LayoutPrimaryAndSecondaryVTables(BaseSubobject Base,
bool BaseIsMorallyVirtual, bool BaseIsMorallyVirtual,
bool BaseIsVirtualInLayoutClass, bool BaseIsVirtualInLayoutClass,
uint64_t OffsetInLayoutClass) { CharUnits OffsetInLayoutClass) {
assert(Base.getBase()->isDynamicClass() && "class does not have a vtable!"); assert(Base.getBase()->isDynamicClass() && "class does not have a vtable!");
// Add vcall and vbase offsets for this vtable. // Add vcall and vbase offsets for this vtable.
VCallAndVBaseOffsetBuilder Builder(MostDerivedClass, LayoutClass, &Overriders, VCallAndVBaseOffsetBuilder Builder(MostDerivedClass, LayoutClass, &Overriders,
Base, BaseIsVirtualInLayoutClass, Base, BaseIsVirtualInLayoutClass,
OffsetInLayoutClass); Context.toBits(OffsetInLayoutClass));
Components.append(Builder.components_begin(), Builder.components_end()); Components.append(Builder.components_begin(), Builder.components_end());
// Check if we need to add these vcall offsets. // Check if we need to add these vcall offsets.
@ -1767,10 +1767,9 @@ VTableBuilder::LayoutPrimaryAndSecondaryVTables(BaseSubobject Base,
VBaseOffsetOffsets = Builder.getVBaseOffsetOffsets(); VBaseOffsetOffsets = Builder.getVBaseOffsetOffsets();
// Add the offset to top. // Add the offset to top.
// FIXME: We should not use / 8 here. CharUnits OffsetToTop = MostDerivedClassOffset - OffsetInLayoutClass;
int64_t OffsetToTop = -(int64_t)(OffsetInLayoutClass - Components.push_back(
Context.toBits(MostDerivedClassOffset)) / 8; VTableComponent::MakeOffsetToTop(OffsetToTop.getQuantity()));
Components.push_back(VTableComponent::MakeOffsetToTop(OffsetToTop));
// Next, add the RTTI. // Next, add the RTTI.
Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass)); Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass));
@ -1779,8 +1778,8 @@ VTableBuilder::LayoutPrimaryAndSecondaryVTables(BaseSubobject Base,
// Now go through all virtual member functions and add them. // Now go through all virtual member functions and add them.
PrimaryBasesSetVectorTy PrimaryBases; PrimaryBasesSetVectorTy PrimaryBases;
AddMethods(Base, Context.toCharUnitsFromBits(OffsetInLayoutClass), AddMethods(Base, OffsetInLayoutClass,
Base.getBase(), Context.toCharUnitsFromBits(OffsetInLayoutClass), Base.getBase(), OffsetInLayoutClass,
PrimaryBases); PrimaryBases);
// Compute 'this' pointer adjustments. // Compute 'this' pointer adjustments.
@ -1790,7 +1789,7 @@ VTableBuilder::LayoutPrimaryAndSecondaryVTables(BaseSubobject Base,
const CXXRecordDecl *RD = Base.getBase(); const CXXRecordDecl *RD = Base.getBase();
while (true) { while (true) {
AddressPoints.insert(std::make_pair( AddressPoints.insert(std::make_pair(
BaseSubobject(RD, Context.toCharUnitsFromBits(OffsetInLayoutClass)), BaseSubobject(RD, OffsetInLayoutClass),
AddressPoint)); AddressPoint));
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD); const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
@ -1805,7 +1804,7 @@ VTableBuilder::LayoutPrimaryAndSecondaryVTables(BaseSubobject Base,
const ASTRecordLayout &LayoutClassLayout = const ASTRecordLayout &LayoutClassLayout =
Context.getASTRecordLayout(LayoutClass); Context.getASTRecordLayout(LayoutClass);
if (LayoutClassLayout.getVBaseClassOffsetInBits(PrimaryBase) != if (LayoutClassLayout.getVBaseClassOffset(PrimaryBase) !=
OffsetInLayoutClass) { OffsetInLayoutClass) {
// We don't want to add this class (or any of its primary bases). // We don't want to add this class (or any of its primary bases).
break; break;
@ -1816,7 +1815,8 @@ VTableBuilder::LayoutPrimaryAndSecondaryVTables(BaseSubobject Base,
} }
// Layout secondary vtables. // Layout secondary vtables.
LayoutSecondaryVTables(Base, BaseIsMorallyVirtual, OffsetInLayoutClass); LayoutSecondaryVTables(Base, BaseIsMorallyVirtual,
Context.toBits(OffsetInLayoutClass));
} }
void VTableBuilder::LayoutSecondaryVTables(BaseSubobject Base, void VTableBuilder::LayoutSecondaryVTables(BaseSubobject Base,
@ -1875,7 +1875,7 @@ void VTableBuilder::LayoutSecondaryVTables(BaseSubobject Base,
BaseSubobject(BaseDecl, BaseOffset), BaseSubobject(BaseDecl, BaseOffset),
BaseIsMorallyVirtual, BaseIsMorallyVirtual,
/*BaseIsVirtualInLayoutClass=*/false, /*BaseIsVirtualInLayoutClass=*/false,
Context.toBits(BaseOffsetInLayoutClass)); BaseOffsetInLayoutClass);
} }
} }
@ -1961,8 +1961,8 @@ VTableBuilder::LayoutVTablesForVirtualBases(const CXXRecordDecl *RD,
const ASTRecordLayout &LayoutClassLayout = const ASTRecordLayout &LayoutClassLayout =
Context.getASTRecordLayout(LayoutClass); Context.getASTRecordLayout(LayoutClass);
uint64_t BaseOffsetInLayoutClass = CharUnits BaseOffsetInLayoutClass =
LayoutClassLayout.getVBaseClassOffsetInBits(BaseDecl); LayoutClassLayout.getVBaseClassOffset(BaseDecl);
LayoutPrimaryAndSecondaryVTables( LayoutPrimaryAndSecondaryVTables(
BaseSubobject(BaseDecl, Context.toCharUnitsFromBits(BaseOffset)), BaseSubobject(BaseDecl, Context.toCharUnitsFromBits(BaseOffset)),