/// 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.
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,
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
// 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,
CXXInfo->VBaseOffsets = VBaseOffsets;
CXXInfo->HasOwnVFPtr = hasOwnVFPtr;
CXXInfo->VBPtrOffset = vbptroffset;
- CXXInfo->HasVFPtr = hasVFPtr;
+ CXXInfo->HasExtendableVFPtr = hasExtendableVFPtr;
CXXInfo->BaseSharingVBPtr = BaseSharingVBPtr;
CXXInfo->AlignAfterVBases = AlignAfterVBases;
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).
// Initialize information about the bases.
HasVBPtr = false;
- HasVFPtr = false;
+ HasExtendableVFPtr = false;
SharedVBPtrBase = 0;
PrimaryBase = 0;
VirtualAlignment = CharUnits::One();
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()) {
// 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
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,