forked from OSchip/llvm-project
No functional change. Renaming a variable in RecordLayoutBuilder and
improving comments to make documentation more accurate. Differential Revision:http://llvm-reviews.chandlerc.com/D2172 llvm-svn: 194609
This commit is contained in:
parent
5e3de7a7eb
commit
486e71460d
|
@ -95,9 +95,10 @@ private:
|
|||
/// its base classes?
|
||||
bool HasOwnVFPtr : 1;
|
||||
|
||||
/// HasVFPtr - Does this class have a vftable at all (could be inherited
|
||||
/// from its primary base.)
|
||||
bool HasVFPtr : 1;
|
||||
/// HasVFPtr - Does this class have a vftable that could be extended by
|
||||
/// a derived class. The class may have inherited this pointer from
|
||||
/// a primary base class.
|
||||
bool HasExtendableVFPtr : 1;
|
||||
|
||||
/// AlignAfterVBases - Force appropriate alignment after virtual bases are
|
||||
/// laid out in MS-C++-ABI.
|
||||
|
@ -133,7 +134,7 @@ private:
|
|||
typedef CXXRecordLayoutInfo::BaseOffsetsMapTy BaseOffsetsMapTy;
|
||||
ASTRecordLayout(const ASTContext &Ctx,
|
||||
CharUnits size, CharUnits alignment,
|
||||
bool hasOwnVFPtr, bool hasVFPtr,
|
||||
bool hasOwnVFPtr, bool hasExtendableVFPtr,
|
||||
CharUnits vbptroffset,
|
||||
CharUnits datasize,
|
||||
const uint64_t *fieldoffsets, unsigned fieldcount,
|
||||
|
@ -240,10 +241,12 @@ public:
|
|||
return CXXInfo->HasOwnVFPtr;
|
||||
}
|
||||
|
||||
/// hasVFPtr - Does this class have a virtual function table pointer.
|
||||
bool hasVFPtr() const {
|
||||
/// hasVFPtr - Does this class have a virtual function table pointer
|
||||
/// that can be extended by a derived class? This is synonymous with
|
||||
/// this class having a VFPtr at offset zero.
|
||||
bool hasExtendableVFPtr() const {
|
||||
assert(CXXInfo && "Record layout does not have C++ specific info!");
|
||||
return CXXInfo->HasVFPtr;
|
||||
return CXXInfo->HasExtendableVFPtr;
|
||||
}
|
||||
|
||||
/// hasOwnVBPtr - Does this class provide its own virtual-base
|
||||
|
|
|
@ -43,7 +43,7 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx, CharUnits size,
|
|||
// Constructor for C++ records.
|
||||
ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
|
||||
CharUnits size, CharUnits alignment,
|
||||
bool hasOwnVFPtr, bool hasVFPtr,
|
||||
bool hasOwnVFPtr, bool hasExtendableVFPtr,
|
||||
CharUnits vbptroffset,
|
||||
CharUnits datasize,
|
||||
const uint64_t *fieldoffsets,
|
||||
|
@ -74,7 +74,7 @@ ASTRecordLayout::ASTRecordLayout(const ASTContext &Ctx,
|
|||
CXXInfo->VBaseOffsets = VBaseOffsets;
|
||||
CXXInfo->HasOwnVFPtr = hasOwnVFPtr;
|
||||
CXXInfo->VBPtrOffset = vbptroffset;
|
||||
CXXInfo->HasVFPtr = hasVFPtr;
|
||||
CXXInfo->HasExtendableVFPtr = hasExtendableVFPtr;
|
||||
CXXInfo->BaseSharingVBPtr = BaseSharingVBPtr;
|
||||
CXXInfo->AlignAfterVBases = AlignAfterVBases;
|
||||
|
||||
|
|
|
@ -2118,8 +2118,10 @@ public:
|
|||
const CXXRecordDecl *PrimaryBase;
|
||||
/// \brief The class we share our vb-pointer with.
|
||||
const CXXRecordDecl *SharedVBPtrBase;
|
||||
/// \brief True if the class has a (not necessarily its own) vftable pointer.
|
||||
bool HasVFPtr : 1;
|
||||
/// \brief True if the class has a vftable pointer that can be extended
|
||||
/// by this class or classes derived from it. Such a vfptr will always occur
|
||||
/// at offset 0.
|
||||
bool HasExtendableVFPtr : 1;
|
||||
/// \brief True if the class has a (not necessarily its own) vbtable pointer.
|
||||
bool HasVBPtr : 1;
|
||||
/// \brief Offset to the virtual base table pointer (if one exists).
|
||||
|
@ -2226,7 +2228,7 @@ MicrosoftRecordLayoutBuilder::initializeCXXLayout(const CXXRecordDecl *RD) {
|
|||
|
||||
// Initialize information about the bases.
|
||||
HasVBPtr = false;
|
||||
HasVFPtr = false;
|
||||
HasExtendableVFPtr = false;
|
||||
SharedVBPtrBase = 0;
|
||||
PrimaryBase = 0;
|
||||
VirtualAlignment = CharUnits::One();
|
||||
|
@ -2251,9 +2253,9 @@ MicrosoftRecordLayoutBuilder::initializeCXXLayout(const CXXRecordDecl *RD) {
|
|||
continue;
|
||||
}
|
||||
// We located a primary base class!
|
||||
if (!PrimaryBase && Layout.hasVFPtr()) {
|
||||
if (!PrimaryBase && Layout.hasExtendableVFPtr()) {
|
||||
PrimaryBase = BaseDecl;
|
||||
HasVFPtr = true;
|
||||
HasExtendableVFPtr = true;
|
||||
}
|
||||
// We located a base to share a VBPtr with!
|
||||
if (!SharedVBPtrBase && Layout.hasVBPtr()) {
|
||||
|
@ -2279,12 +2281,12 @@ void MicrosoftRecordLayoutBuilder::layoutVFPtr(const CXXRecordDecl *RD) {
|
|||
|
||||
// Look at all of our methods to determine if we need a VFPtr. We need a
|
||||
// vfptr if we define a new virtual function.
|
||||
if (!HasVFPtr && RD->isDynamicClass())
|
||||
if (!HasExtendableVFPtr && RD->isDynamicClass())
|
||||
for (CXXRecordDecl::method_iterator i = RD->method_begin(),
|
||||
e = RD->method_end();
|
||||
!HasVFPtr && i != e; ++i)
|
||||
HasVFPtr = i->isVirtual() && i->size_overridden_methods() == 0;
|
||||
if (!HasVFPtr)
|
||||
!HasExtendableVFPtr && i != e; ++i)
|
||||
HasExtendableVFPtr = i->isVirtual() && i->size_overridden_methods() == 0;
|
||||
if (!HasExtendableVFPtr)
|
||||
return;
|
||||
|
||||
// MSVC 32 (but not 64) potentially over-aligns the vf-table pointer by giving
|
||||
|
@ -2672,7 +2674,8 @@ ASTContext::BuildMicrosoftASTRecordLayout(const RecordDecl *D) const {
|
|||
Builder.cxxLayout(RD);
|
||||
return new (*this) ASTRecordLayout(
|
||||
*this, Builder.Size, Builder.Alignment,
|
||||
Builder.HasVFPtr && !Builder.PrimaryBase, Builder.HasVFPtr,
|
||||
Builder.HasExtendableVFPtr && !Builder.PrimaryBase,
|
||||
Builder.HasExtendableVFPtr,
|
||||
Builder.VBPtrOffset, Builder.DataSize, Builder.FieldOffsets.data(),
|
||||
Builder.FieldOffsets.size(), Builder.DataSize,
|
||||
Builder.NonVirtualAlignment, CharUnits::Zero(), Builder.PrimaryBase,
|
||||
|
|
Loading…
Reference in New Issue