forked from OSchip/llvm-project
Rename getBaseClassOffset to getBaseClassOffsetInBits and introduce a getBaseClassOffset which returns the offset in CharUnits. Do the same thing for getVBaseClassOffset.
llvm-svn: 117881
This commit is contained in:
parent
baa5126dbc
commit
fd88a6160d
|
@ -213,21 +213,39 @@ public:
|
|||
return getPrimaryBaseInfo().isVirtual();
|
||||
}
|
||||
|
||||
/// getBaseClassOffset - Get the offset, in bits, for the given base class.
|
||||
uint64_t getBaseClassOffset(const CXXRecordDecl *Base) const {
|
||||
/// getBaseClassOffset - Get the offset, in chars, for the given base class.
|
||||
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const {
|
||||
assert(CXXInfo && "Record layout does not have C++ specific info!");
|
||||
assert(CXXInfo->BaseOffsets.count(Base) && "Did not find base!");
|
||||
|
||||
return CXXInfo->BaseOffsets[Base].getQuantity() *
|
||||
Base->getASTContext().getCharWidth();
|
||||
return CXXInfo->BaseOffsets[Base];
|
||||
}
|
||||
|
||||
/// getVBaseClassOffset - Get the offset, in bits, for the given base class.
|
||||
uint64_t getVBaseClassOffset(const CXXRecordDecl *VBase) const {
|
||||
/// getVBaseClassOffset - Get the offset, in chars, for the given base class.
|
||||
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const {
|
||||
assert(CXXInfo && "Record layout does not have C++ specific info!");
|
||||
assert(CXXInfo->VBaseOffsets.count(VBase) && "Did not find base!");
|
||||
|
||||
return CXXInfo->VBaseOffsets[VBase].getQuantity() *
|
||||
return CXXInfo->VBaseOffsets[VBase];
|
||||
}
|
||||
|
||||
/// getBaseClassOffsetInBits - Get the offset, in bits, for the given
|
||||
/// base class.
|
||||
uint64_t getBaseClassOffsetInBits(const CXXRecordDecl *Base) const {
|
||||
assert(CXXInfo && "Record layout does not have C++ specific info!");
|
||||
assert(CXXInfo->BaseOffsets.count(Base) && "Did not find base!");
|
||||
|
||||
return getBaseClassOffset(Base).getQuantity() *
|
||||
Base->getASTContext().getCharWidth();
|
||||
}
|
||||
|
||||
/// getVBaseClassOffsetInBits - Get the offset, in bits, for the given
|
||||
/// base class.
|
||||
uint64_t getVBaseClassOffsetInBits(const CXXRecordDecl *VBase) const {
|
||||
assert(CXXInfo && "Record layout does not have C++ specific info!");
|
||||
assert(CXXInfo->VBaseOffsets.count(VBase) && "Did not find base!");
|
||||
|
||||
return getVBaseClassOffset(VBase).getQuantity() *
|
||||
VBase->getASTContext().getCharWidth();
|
||||
}
|
||||
|
||||
|
|
|
@ -594,7 +594,7 @@ bool PointerExprEvaluator::VisitCastExpr(CastExpr* E) {
|
|||
const CXXRecordDecl *BaseDecl = Base->getType()->getAsCXXRecordDecl();
|
||||
const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(DerivedDecl);
|
||||
|
||||
Offset += Layout.getBaseClassOffset(BaseDecl);
|
||||
Offset += Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
DerivedDecl = BaseDecl;
|
||||
}
|
||||
|
||||
|
@ -1621,7 +1621,7 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *E) {
|
|||
|
||||
// Add the offset to the base.
|
||||
Result += CharUnits::fromQuantity(
|
||||
RL.getBaseClassOffset(cast<CXXRecordDecl>(BaseRT->getDecl()))
|
||||
RL.getBaseClassOffsetInBits(cast<CXXRecordDecl>(BaseRT->getDecl()))
|
||||
/ Info.Ctx.getCharWidth());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -69,10 +69,10 @@ ASTRecordLayout::ASTRecordLayout(ASTContext &Ctx,
|
|||
#ifndef NDEBUG
|
||||
if (const CXXRecordDecl *PrimaryBase = getPrimaryBase()) {
|
||||
if (getPrimaryBaseWasVirtual())
|
||||
assert(getVBaseClassOffset(PrimaryBase) == 0 &&
|
||||
assert(getVBaseClassOffsetInBits(PrimaryBase) == 0 &&
|
||||
"Primary virtual base must be at offset 0!");
|
||||
else
|
||||
assert(getBaseClassOffset(PrimaryBase) == 0 &&
|
||||
assert(getBaseClassOffsetInBits(PrimaryBase) == 0 &&
|
||||
"Primary base must be at offset 0!");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -245,7 +245,7 @@ EmptySubobjectMap::CanPlaceBaseSubobjectAtOffset(const BaseSubobjectInfo *Info,
|
|||
continue;
|
||||
|
||||
CharUnits BaseOffset =
|
||||
Offset + toCharUnits(Layout.getBaseClassOffset(Base->Class));
|
||||
Offset + toCharUnits(Layout.getBaseClassOffsetInBits(Base->Class));
|
||||
|
||||
if (!CanPlaceBaseSubobjectAtOffset(Base, BaseOffset))
|
||||
return false;
|
||||
|
@ -298,7 +298,7 @@ void EmptySubobjectMap::UpdateEmptyBaseSubobjects(const BaseSubobjectInfo *Info,
|
|||
continue;
|
||||
|
||||
CharUnits BaseOffset =
|
||||
Offset + toCharUnits(Layout.getBaseClassOffset(Base->Class));
|
||||
Offset + toCharUnits(Layout.getBaseClassOffsetInBits(Base->Class));
|
||||
UpdateEmptyBaseSubobjects(Base, BaseOffset, PlacingEmptyBase);
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
|
|||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
CharUnits BaseOffset =
|
||||
Offset + toCharUnits(Layout.getBaseClassOffset(BaseDecl));
|
||||
Offset + toCharUnits(Layout.getBaseClassOffsetInBits(BaseDecl));
|
||||
if (!CanPlaceFieldSubobjectAtOffset(BaseDecl, Class, BaseOffset))
|
||||
return false;
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ EmptySubobjectMap::CanPlaceFieldSubobjectAtOffset(const CXXRecordDecl *RD,
|
|||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
CharUnits VBaseOffset = Offset +
|
||||
toCharUnits(Layout.getVBaseClassOffset(VBaseDecl));
|
||||
toCharUnits(Layout.getVBaseClassOffsetInBits(VBaseDecl));
|
||||
if (!CanPlaceFieldSubobjectAtOffset(VBaseDecl, Class, VBaseOffset))
|
||||
return false;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD,
|
|||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
CharUnits BaseOffset =
|
||||
Offset + toCharUnits(Layout.getBaseClassOffset(BaseDecl));
|
||||
Offset + toCharUnits(Layout.getBaseClassOffsetInBits(BaseDecl));
|
||||
UpdateEmptyFieldSubobjects(BaseDecl, Class, BaseOffset);
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ void EmptySubobjectMap::UpdateEmptyFieldSubobjects(const CXXRecordDecl *RD,
|
|||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
CharUnits VBaseOffset =
|
||||
Offset + toCharUnits(Layout.getVBaseClassOffset(VBaseDecl));
|
||||
Offset + toCharUnits(Layout.getVBaseClassOffsetInBits(VBaseDecl));
|
||||
UpdateEmptyFieldSubobjects(VBaseDecl, Class, VBaseOffset);
|
||||
}
|
||||
}
|
||||
|
@ -1068,7 +1068,7 @@ RecordLayoutBuilder::AddPrimaryVirtualBaseOffsets(const BaseSubobjectInfo *Info,
|
|||
continue;
|
||||
|
||||
CharUnits BaseOffset =
|
||||
Offset + toCharUnits(Layout.getBaseClassOffset(Base->Class));
|
||||
Offset + toCharUnits(Layout.getBaseClassOffsetInBits(Base->Class));
|
||||
AddPrimaryVirtualBaseOffsets(Base, BaseOffset);
|
||||
}
|
||||
}
|
||||
|
@ -1840,7 +1840,7 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS,
|
|||
const CXXRecordDecl *Base =
|
||||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
uint64_t BaseOffset = Offset + Info.getBaseClassOffset(Base) / 8;
|
||||
uint64_t BaseOffset = Offset + Info.getBaseClassOffsetInBits(Base) / 8;
|
||||
|
||||
DumpCXXRecordLayout(OS, Base, C, BaseOffset, IndentLevel,
|
||||
Base == PrimaryBase ? "(primary base)" : "(base)",
|
||||
|
@ -1877,7 +1877,7 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS,
|
|||
const CXXRecordDecl *VBase =
|
||||
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
uint64_t VBaseOffset = Offset + Info.getVBaseClassOffset(VBase) / 8;
|
||||
uint64_t VBaseOffset = Offset + Info.getVBaseClassOffsetInBits(VBase) / 8;
|
||||
DumpCXXRecordLayout(OS, VBase, C, VBaseOffset, IndentLevel,
|
||||
VBase == PrimaryBase ?
|
||||
"(primary virtual base)" : "(virtual base)",
|
||||
|
|
|
@ -103,7 +103,7 @@ bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
|
|||
|
||||
// If the base is at a non-zero offset, give up.
|
||||
const ASTRecordLayout &ClassLayout = Context.getASTRecordLayout(Class);
|
||||
if (ClassLayout.getBaseClassOffset(UniqueBase) != 0)
|
||||
if (ClassLayout.getBaseClassOffsetInBits(UniqueBase) != 0)
|
||||
return true;
|
||||
|
||||
return TryEmitDefinitionAsAlias(GlobalDecl(D, Dtor_Base),
|
||||
|
|
|
@ -41,7 +41,7 @@ ComputeNonVirtualBaseClassOffset(ASTContext &Context,
|
|||
cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
// Add the offset.
|
||||
Offset += Layout.getBaseClassOffset(BaseDecl);
|
||||
Offset += Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
|
||||
RD = BaseDecl;
|
||||
}
|
||||
|
@ -87,9 +87,9 @@ CodeGenFunction::GetAddressOfDirectBaseInCompleteClass(llvm::Value *This,
|
|||
uint64_t Offset;
|
||||
const ASTRecordLayout &Layout = getContext().getASTRecordLayout(Derived);
|
||||
if (BaseIsVirtual)
|
||||
Offset = Layout.getVBaseClassOffset(Base);
|
||||
Offset = Layout.getVBaseClassOffsetInBits(Base);
|
||||
else
|
||||
Offset = Layout.getBaseClassOffset(Base);
|
||||
Offset = Layout.getBaseClassOffsetInBits(Base);
|
||||
|
||||
// Shift and cast down to the base type.
|
||||
// TODO: for complete types, this should be possible with a GEP.
|
||||
|
@ -295,7 +295,8 @@ static llvm::Value *GetVTTParameter(CodeGenFunction &CGF, GlobalDecl GD,
|
|||
const ASTRecordLayout &Layout =
|
||||
CGF.getContext().getASTRecordLayout(RD);
|
||||
uint64_t BaseOffset = ForVirtualBase ?
|
||||
Layout.getVBaseClassOffset(Base) : Layout.getBaseClassOffset(Base);
|
||||
Layout.getVBaseClassOffsetInBits(Base) :
|
||||
Layout.getBaseClassOffsetInBits(Base);
|
||||
|
||||
SubVTTIndex =
|
||||
CGF.CGM.getVTables().getSubVTTIndex(RD, BaseSubobject(Base, BaseOffset));
|
||||
|
@ -1355,15 +1356,16 @@ CodeGenFunction::InitializeVTablePointers(BaseSubobject Base,
|
|||
const ASTRecordLayout &Layout =
|
||||
getContext().getASTRecordLayout(VTableClass);
|
||||
|
||||
BaseOffset = Layout.getVBaseClassOffset(BaseDecl);
|
||||
BaseOffset = Layout.getVBaseClassOffsetInBits(BaseDecl);
|
||||
BaseOffsetFromNearestVBase = 0;
|
||||
BaseDeclIsNonVirtualPrimaryBase = false;
|
||||
} else {
|
||||
const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD);
|
||||
|
||||
BaseOffset = Base.getBaseOffset() + Layout.getBaseClassOffset(BaseDecl);
|
||||
BaseOffset =
|
||||
Base.getBaseOffset() + Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
BaseOffsetFromNearestVBase =
|
||||
OffsetFromNearestVBase + Layout.getBaseClassOffset(BaseDecl);
|
||||
OffsetFromNearestVBase + Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
BaseDeclIsNonVirtualPrimaryBase = Layout.getPrimaryBase() == BaseDecl;
|
||||
}
|
||||
|
||||
|
|
|
@ -855,7 +855,7 @@ CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile Unit,
|
|||
BaseOffset = 0 - CGM.getVTables().getVirtualBaseOffsetOffset(RD, Base);
|
||||
BFlags = llvm::DIDescriptor::FlagVirtual;
|
||||
} else
|
||||
BaseOffset = RL.getBaseClassOffset(Base);
|
||||
BaseOffset = RL.getBaseClassOffsetInBits(Base);
|
||||
|
||||
AccessSpecifier Access = BI->getAccessSpecifier();
|
||||
if (Access == clang::AS_private)
|
||||
|
|
|
@ -980,7 +980,7 @@ FillInNullDataMemberPointers(CodeGenModule &CGM, QualType T,
|
|||
if (CGM.getTypes().isZeroInitializable(BaseDecl))
|
||||
continue;
|
||||
|
||||
uint64_t BaseOffset = Layout.getBaseClassOffset(BaseDecl);
|
||||
uint64_t BaseOffset = Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
FillInNullDataMemberPointers(CGM, I->getType(),
|
||||
Elements, StartOffset + BaseOffset);
|
||||
}
|
||||
|
|
|
@ -1407,7 +1407,7 @@ Value *ScalarExprEmitter::VisitOffsetOfExpr(OffsetOfExpr *E) {
|
|||
// Compute the offset to the base.
|
||||
const RecordType *BaseRT = CurrentType->getAs<RecordType>();
|
||||
CXXRecordDecl *BaseRD = cast<CXXRecordDecl>(BaseRT->getDecl());
|
||||
int64_t OffsetInt = RL.getBaseClassOffset(BaseRD) /
|
||||
int64_t OffsetInt = RL.getBaseClassOffsetInBits(BaseRD) /
|
||||
CGF.getContext().getCharWidth();
|
||||
Offset = llvm::ConstantInt::get(ResultType, OffsetInt);
|
||||
break;
|
||||
|
|
|
@ -823,7 +823,7 @@ void RTTIBuilder::BuildVMIClassTypeInfo(const CXXRecordDecl *RD) {
|
|||
OffsetFlags = CGM.getVTables().getVirtualBaseOffsetOffset(RD, BaseDecl);
|
||||
else {
|
||||
const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
|
||||
OffsetFlags = Layout.getBaseClassOffset(BaseDecl) / 8;
|
||||
OffsetFlags = Layout.getBaseClassOffsetInBits(BaseDecl) / 8;
|
||||
};
|
||||
|
||||
OffsetFlags <<= 8;
|
||||
|
|
|
@ -516,7 +516,7 @@ CGRecordLayoutBuilder::LayoutNonVirtualBases(const CXXRecordDecl *RD,
|
|||
if (BaseDecl == PrimaryBase && !Layout.getPrimaryBaseWasVirtual())
|
||||
continue;
|
||||
|
||||
LayoutNonVirtualBase(BaseDecl, Layout.getBaseClassOffset(BaseDecl));
|
||||
LayoutNonVirtualBase(BaseDecl, Layout.getBaseClassOffsetInBits(BaseDecl));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ void VTTBuilder::LayoutSecondaryVTTs(BaseSubobject Base) {
|
|||
|
||||
const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
|
||||
uint64_t BaseOffset = Base.getBaseOffset() +
|
||||
Layout.getBaseClassOffset(BaseDecl);
|
||||
Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
|
||||
// Layout the VTT for this base.
|
||||
LayoutVTT(BaseSubobject(BaseDecl, BaseOffset), /*BaseIsVirtual=*/false);
|
||||
|
@ -262,12 +262,13 @@ VTTBuilder::LayoutSecondaryVirtualPointers(BaseSubobject Base,
|
|||
if (!VBases.insert(BaseDecl))
|
||||
continue;
|
||||
|
||||
BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
|
||||
BaseOffset = MostDerivedClassLayout.getVBaseClassOffsetInBits(BaseDecl);
|
||||
BaseDeclIsMorallyVirtual = true;
|
||||
} else {
|
||||
const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
|
||||
|
||||
BaseOffset = Base.getBaseOffset() + Layout.getBaseClassOffset(BaseDecl);
|
||||
BaseOffset =
|
||||
Base.getBaseOffset() + Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
|
||||
if (!Layout.getPrimaryBaseWasVirtual() &&
|
||||
Layout.getPrimaryBase() == BaseDecl)
|
||||
|
@ -316,7 +317,7 @@ void VTTBuilder::LayoutVirtualVTTs(const CXXRecordDecl *RD,
|
|||
continue;
|
||||
|
||||
uint64_t BaseOffset =
|
||||
MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
|
||||
MostDerivedClassLayout.getVBaseClassOffsetInBits(BaseDecl);
|
||||
|
||||
LayoutVTT(BaseSubobject(BaseDecl, BaseOffset), /*BaseIsVirtual=*/true);
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ static BaseOffset ComputeBaseOffset(ASTContext &Context,
|
|||
const RecordType *BaseType = Element.Base->getType()->getAs<RecordType>();
|
||||
const CXXRecordDecl *Base = cast<CXXRecordDecl>(BaseType->getDecl());
|
||||
|
||||
NonVirtualOffset += Layout.getBaseClassOffset(Base);
|
||||
NonVirtualOffset += Layout.getBaseClassOffsetInBits(Base);
|
||||
}
|
||||
|
||||
// FIXME: This should probably use CharUnits or something. Maybe we should
|
||||
|
@ -358,12 +358,12 @@ FinalOverriders::ComputeBaseOffsets(BaseSubobject Base, bool IsVirtual,
|
|||
const ASTRecordLayout &LayoutClassLayout =
|
||||
Context.getASTRecordLayout(LayoutClass);
|
||||
|
||||
BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
|
||||
BaseOffset = MostDerivedClassLayout.getVBaseClassOffsetInBits(BaseDecl);
|
||||
BaseOffsetInLayoutClass =
|
||||
LayoutClassLayout.getVBaseClassOffset(BaseDecl);
|
||||
LayoutClassLayout.getVBaseClassOffsetInBits(BaseDecl);
|
||||
} else {
|
||||
const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
|
||||
uint64_t Offset = Layout.getBaseClassOffset(BaseDecl);
|
||||
uint64_t Offset = Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
|
||||
BaseOffset = Base.getBaseOffset() + Offset;
|
||||
BaseOffsetInLayoutClass = OffsetInLayoutClass + Offset;
|
||||
|
@ -396,9 +396,9 @@ void FinalOverriders::dump(llvm::raw_ostream &Out, BaseSubobject Base,
|
|||
continue;
|
||||
}
|
||||
|
||||
BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
|
||||
BaseOffset = MostDerivedClassLayout.getVBaseClassOffsetInBits(BaseDecl);
|
||||
} else {
|
||||
BaseOffset = Layout.getBaseClassOffset(BaseDecl) +
|
||||
BaseOffset = Layout.getBaseClassOffsetInBits(BaseDecl) +
|
||||
Base.getBaseOffset();
|
||||
}
|
||||
|
||||
|
@ -799,16 +799,16 @@ VCallAndVBaseOffsetBuilder::AddVCallAndVBaseOffsets(BaseSubobject Base,
|
|||
|
||||
// Get the base offset of the primary base.
|
||||
if (PrimaryBaseIsVirtual) {
|
||||
assert(Layout.getVBaseClassOffset(PrimaryBase) == 0 &&
|
||||
assert(Layout.getVBaseClassOffsetInBits(PrimaryBase) == 0 &&
|
||||
"Primary vbase should have a zero offset!");
|
||||
|
||||
const ASTRecordLayout &MostDerivedClassLayout =
|
||||
Context.getASTRecordLayout(MostDerivedClass);
|
||||
|
||||
PrimaryBaseOffset =
|
||||
MostDerivedClassLayout.getVBaseClassOffset(PrimaryBase);
|
||||
MostDerivedClassLayout.getVBaseClassOffsetInBits(PrimaryBase);
|
||||
} else {
|
||||
assert(Layout.getBaseClassOffset(PrimaryBase) == 0 &&
|
||||
assert(Layout.getBaseClassOffsetInBits(PrimaryBase) == 0 &&
|
||||
"Primary base should have a zero offset!");
|
||||
|
||||
PrimaryBaseOffset = Base.getBaseOffset();
|
||||
|
@ -851,7 +851,7 @@ void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base,
|
|||
// primary base will have its vcall and vbase offsets emitted already.
|
||||
if (PrimaryBase && !Layout.getPrimaryBaseWasVirtual()) {
|
||||
// Get the base offset of the primary base.
|
||||
assert(Layout.getBaseClassOffset(PrimaryBase) == 0 &&
|
||||
assert(Layout.getBaseClassOffsetInBits(PrimaryBase) == 0 &&
|
||||
"Primary base should have a zero offset!");
|
||||
|
||||
AddVCallOffsets(BaseSubobject(PrimaryBase, Base.getBaseOffset()),
|
||||
|
@ -903,7 +903,7 @@ void VCallAndVBaseOffsetBuilder::AddVCallOffsets(BaseSubobject Base,
|
|||
|
||||
// Get the base offset of this base.
|
||||
uint64_t BaseOffset = Base.getBaseOffset() +
|
||||
Layout.getBaseClassOffset(BaseDecl);
|
||||
Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
|
||||
AddVCallOffsets(BaseSubobject(BaseDecl, BaseOffset), VBaseOffset);
|
||||
}
|
||||
|
@ -924,7 +924,7 @@ void VCallAndVBaseOffsetBuilder::AddVBaseOffsets(const CXXRecordDecl *RD,
|
|||
if (I->isVirtual() && VisitedVirtualBases.insert(BaseDecl)) {
|
||||
// FIXME: We shouldn't use / 8 here.
|
||||
int64_t Offset =
|
||||
(int64_t)(LayoutClassLayout.getVBaseClassOffset(BaseDecl) -
|
||||
(int64_t)(LayoutClassLayout.getVBaseClassOffsetInBits(BaseDecl) -
|
||||
OffsetInLayoutClass) / 8;
|
||||
|
||||
// Add the vbase offset offset.
|
||||
|
@ -1372,7 +1372,7 @@ VTableBuilder::ComputeThisAdjustmentBaseOffset(BaseSubobject Base,
|
|||
/// Get the virtual base offset, relative to the most derived class
|
||||
/// layout.
|
||||
OffsetToBaseSubobject +=
|
||||
LayoutClassLayout.getVBaseClassOffset(Offset.VirtualBase);
|
||||
LayoutClassLayout.getVBaseClassOffsetInBits(Offset.VirtualBase);
|
||||
} else {
|
||||
// Otherwise, the non-virtual offset is relative to the derived class
|
||||
// offset.
|
||||
|
@ -1521,7 +1521,7 @@ VTableBuilder::IsOverriderUsed(const CXXMethodDecl *Overrider,
|
|||
break;
|
||||
|
||||
if (Layout.getPrimaryBaseWasVirtual()) {
|
||||
assert(Layout.getVBaseClassOffset(PrimaryBase) == 0 &&
|
||||
assert(Layout.getVBaseClassOffsetInBits(PrimaryBase) == 0 &&
|
||||
"Primary base should always be at offset 0!");
|
||||
|
||||
const ASTRecordLayout &LayoutClassLayout =
|
||||
|
@ -1529,13 +1529,13 @@ VTableBuilder::IsOverriderUsed(const CXXMethodDecl *Overrider,
|
|||
|
||||
// Now check if this is the primary base that is not a primary base in the
|
||||
// most derived class.
|
||||
if (LayoutClassLayout.getVBaseClassOffset(PrimaryBase) !=
|
||||
if (LayoutClassLayout.getVBaseClassOffsetInBits(PrimaryBase) !=
|
||||
FirstBaseOffsetInLayoutClass) {
|
||||
// We found it, stop walking the chain.
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
assert(Layout.getBaseClassOffset(PrimaryBase) == 0 &&
|
||||
assert(Layout.getBaseClassOffsetInBits(PrimaryBase) == 0 &&
|
||||
"Primary base should always be at offset 0!");
|
||||
}
|
||||
|
||||
|
@ -1587,22 +1587,22 @@ VTableBuilder::AddMethods(BaseSubobject Base, uint64_t BaseOffsetInLayoutClass,
|
|||
uint64_t PrimaryBaseOffset;
|
||||
uint64_t PrimaryBaseOffsetInLayoutClass;
|
||||
if (Layout.getPrimaryBaseWasVirtual()) {
|
||||
assert(Layout.getVBaseClassOffset(PrimaryBase) == 0 &&
|
||||
assert(Layout.getVBaseClassOffsetInBits(PrimaryBase) == 0 &&
|
||||
"Primary vbase should have a zero offset!");
|
||||
|
||||
const ASTRecordLayout &MostDerivedClassLayout =
|
||||
Context.getASTRecordLayout(MostDerivedClass);
|
||||
|
||||
PrimaryBaseOffset =
|
||||
MostDerivedClassLayout.getVBaseClassOffset(PrimaryBase);
|
||||
MostDerivedClassLayout.getVBaseClassOffsetInBits(PrimaryBase);
|
||||
|
||||
const ASTRecordLayout &LayoutClassLayout =
|
||||
Context.getASTRecordLayout(LayoutClass);
|
||||
|
||||
PrimaryBaseOffsetInLayoutClass =
|
||||
LayoutClassLayout.getVBaseClassOffset(PrimaryBase);
|
||||
LayoutClassLayout.getVBaseClassOffsetInBits(PrimaryBase);
|
||||
} else {
|
||||
assert(Layout.getBaseClassOffset(PrimaryBase) == 0 &&
|
||||
assert(Layout.getBaseClassOffsetInBits(PrimaryBase) == 0 &&
|
||||
"Primary base should have a zero offset!");
|
||||
|
||||
PrimaryBaseOffset = Base.getBaseOffset();
|
||||
|
@ -1785,7 +1785,7 @@ VTableBuilder::LayoutPrimaryAndSecondaryVTables(BaseSubobject Base,
|
|||
const ASTRecordLayout &LayoutClassLayout =
|
||||
Context.getASTRecordLayout(LayoutClass);
|
||||
|
||||
if (LayoutClassLayout.getVBaseClassOffset(PrimaryBase) !=
|
||||
if (LayoutClassLayout.getVBaseClassOffsetInBits(PrimaryBase) !=
|
||||
OffsetInLayoutClass) {
|
||||
// We don't want to add this class (or any of its primary bases).
|
||||
break;
|
||||
|
@ -1835,7 +1835,7 @@ void VTableBuilder::LayoutSecondaryVTables(BaseSubobject Base,
|
|||
}
|
||||
|
||||
// Get the base offset of this base.
|
||||
uint64_t RelativeBaseOffset = Layout.getBaseClassOffset(BaseDecl);
|
||||
uint64_t RelativeBaseOffset = Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
uint64_t BaseOffset = Base.getBaseOffset() + RelativeBaseOffset;
|
||||
|
||||
uint64_t BaseOffsetInLayoutClass = OffsetInLayoutClass + RelativeBaseOffset;
|
||||
|
@ -1876,7 +1876,7 @@ VTableBuilder::DeterminePrimaryVirtualBases(const CXXRecordDecl *RD,
|
|||
Context.getASTRecordLayout(LayoutClass);
|
||||
|
||||
uint64_t PrimaryBaseOffsetInLayoutClass =
|
||||
LayoutClassLayout.getVBaseClassOffset(PrimaryBase);
|
||||
LayoutClassLayout.getVBaseClassOffsetInBits(PrimaryBase);
|
||||
|
||||
// We know that the base is not a primary base in the layout class if
|
||||
// the base offsets are different.
|
||||
|
@ -1904,10 +1904,11 @@ VTableBuilder::DeterminePrimaryVirtualBases(const CXXRecordDecl *RD,
|
|||
const ASTRecordLayout &LayoutClassLayout =
|
||||
Context.getASTRecordLayout(LayoutClass);
|
||||
|
||||
BaseOffsetInLayoutClass = LayoutClassLayout.getVBaseClassOffset(BaseDecl);
|
||||
BaseOffsetInLayoutClass =
|
||||
LayoutClassLayout.getVBaseClassOffsetInBits(BaseDecl);
|
||||
} else {
|
||||
BaseOffsetInLayoutClass =
|
||||
OffsetInLayoutClass + Layout.getBaseClassOffset(BaseDecl);
|
||||
OffsetInLayoutClass + Layout.getBaseClassOffsetInBits(BaseDecl);
|
||||
}
|
||||
|
||||
DeterminePrimaryVirtualBases(BaseDecl, BaseOffsetInLayoutClass, VBases);
|
||||
|
@ -1933,12 +1934,12 @@ VTableBuilder::LayoutVTablesForVirtualBases(const CXXRecordDecl *RD,
|
|||
const ASTRecordLayout &MostDerivedClassLayout =
|
||||
Context.getASTRecordLayout(MostDerivedClass);
|
||||
uint64_t BaseOffset =
|
||||
MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
|
||||
MostDerivedClassLayout.getVBaseClassOffsetInBits(BaseDecl);
|
||||
|
||||
const ASTRecordLayout &LayoutClassLayout =
|
||||
Context.getASTRecordLayout(LayoutClass);
|
||||
uint64_t BaseOffsetInLayoutClass =
|
||||
LayoutClassLayout.getVBaseClassOffset(BaseDecl);
|
||||
LayoutClassLayout.getVBaseClassOffsetInBits(BaseDecl);
|
||||
|
||||
LayoutPrimaryAndSecondaryVTables(BaseSubobject(BaseDecl, BaseOffset),
|
||||
/*BaseIsMorallyVirtual=*/true,
|
||||
|
|
|
@ -1142,7 +1142,7 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase,
|
|||
// single eightbyte, each is classified separately. Each eightbyte gets
|
||||
// initialized to class NO_CLASS.
|
||||
Class FieldLo, FieldHi;
|
||||
uint64_t Offset = OffsetBase + Layout.getBaseClassOffset(Base);
|
||||
uint64_t Offset = OffsetBase + Layout.getBaseClassOffsetInBits(Base);
|
||||
classify(i->getType(), Offset, FieldLo, FieldHi);
|
||||
Lo = merge(Lo, FieldLo);
|
||||
Hi = merge(Hi, FieldHi);
|
||||
|
@ -1341,7 +1341,7 @@ static bool BitsContainNoUserData(QualType Ty, unsigned StartBit,
|
|||
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
|
||||
|
||||
// If the base is after the span we care about, ignore it.
|
||||
unsigned BaseOffset = (unsigned)Layout.getBaseClassOffset(Base);
|
||||
unsigned BaseOffset = (unsigned)Layout.getBaseClassOffsetInBits(Base);
|
||||
if (BaseOffset >= EndBit) continue;
|
||||
|
||||
unsigned BaseStart = BaseOffset < StartBit ? StartBit-BaseOffset :0;
|
||||
|
|
Loading…
Reference in New Issue