28#define DUMP_OVERRIDERS 0
32 bool GenerateDefinition)
33 : Ctx(Ctx), MostDerivedClass(MostDerivedClass),
34 MostDerivedClassLayout(Ctx.getASTRecordLayout(MostDerivedClass)),
35 GenerateDefinition(GenerateDefinition) {
44 if (VTableClass == MostDerivedClass) {
45 assert(!SecondaryVirtualPointerIndices.count(
Base) &&
46 "A virtual pointer index already exists for this base subobject!");
47 SecondaryVirtualPointerIndices[
Base] = VTTComponents.size();
50 if (!GenerateDefinition) {
55 VTTComponents.push_back(VTTComponent(VTableIndex, Base));
59 const CXXRecordDecl *RD =
Base.getBase();
61 for (
const auto &I : RD->
bases()) {
66 const auto *BaseDecl = I.getType()->castAsCXXRecordDecl();
67 const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(RD);
68 CharUnits BaseOffset =
Base.getBaseOffset() +
72 LayoutVTT(BaseSubobject(BaseDecl, BaseOffset),
false);
78 bool BaseIsMorallyVirtual,
81 VisitedVirtualBasesSetTy &VBases) {
82 const CXXRecordDecl *RD =
Base.getBase();
89 for (
const auto &I : RD->
bases()) {
90 const auto *BaseDecl = I.getType()->castAsCXXRecordDecl();
99 if (!BaseDecl->isDynamicClass())
102 bool BaseDeclIsMorallyVirtual = BaseIsMorallyVirtual;
103 bool BaseDeclIsNonVirtualPrimaryBase =
false;
104 CharUnits BaseOffset;
107 if (!VBases.insert(BaseDecl).second)
110 BaseOffset = MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
111 BaseDeclIsMorallyVirtual =
true;
113 const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(RD);
115 BaseOffset =
Base.getBaseOffset() +
120 BaseDeclIsNonVirtualPrimaryBase =
true;
128 if (!BaseDeclIsNonVirtualPrimaryBase &&
129 (BaseDecl->getNumVBases() || BaseDeclIsMorallyVirtual)) {
131 AddVTablePointer(BaseSubobject(BaseDecl, BaseOffset), VTableIndex,
136 LayoutSecondaryVirtualPointers(BaseSubobject(BaseDecl, BaseOffset),
137 BaseDeclIsMorallyVirtual, VTableIndex,
138 VTableClass, VBases);
143VTTBuilder::LayoutSecondaryVirtualPointers(
BaseSubobject Base,
144 uint64_t VTableIndex) {
145 VisitedVirtualBasesSetTy VBases;
146 LayoutSecondaryVirtualPointers(Base,
false,
147 VTableIndex,
Base.getBase(), VBases);
151 VisitedVirtualBasesSetTy &VBases) {
152 for (
const auto &I : RD->
bases()) {
153 const auto *BaseDecl = I.getType()->castAsCXXRecordDecl();
158 if (!VBases.insert(BaseDecl).second)
161 CharUnits BaseOffset =
162 MostDerivedClassLayout.getVBaseClassOffset(BaseDecl);
164 LayoutVTT(BaseSubobject(BaseDecl, BaseOffset),
true);
169 if (BaseDecl->getNumVBases())
170 LayoutVirtualVTTs(BaseDecl, VBases);
174void VTTBuilder::LayoutVTT(
BaseSubobject Base,
bool BaseIsVirtual) {
175 const CXXRecordDecl *RD =
Base.getBase();
183 bool IsPrimaryVTT =
Base.getBase() == MostDerivedClass;
187 SubVTTIndices[
Base] = VTTComponents.size();
190 uint64_t VTableIndex = VTTVTables.size();
191 VTTVTables.push_back(VTTVTable(Base, BaseIsVirtual));
194 AddVTablePointer(Base, VTableIndex, RD);
197 LayoutSecondaryVTTs(Base);
200 LayoutSecondaryVirtualPointers(Base, VTableIndex);
204 VisitedVirtualBasesSetTy VBases;
205 LayoutVirtualVTTs(
Base.getBase(), VBases);
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
const CXXRecordDecl * getPrimaryBase() const
getPrimaryBase - Get the primary base for this record.
bool isPrimaryBaseVirtual() const
isPrimaryBaseVirtual - Get whether the primary base for this record is virtual or not.
Represents a C++ struct/union/class.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
VTTBuilder(ASTContext &Ctx, const CXXRecordDecl *MostDerivedClass, bool GenerateDefinition)
The JSON file list parser is used to communicate input to InstallAPI.