23#include "llvm/Support/Casting.h"
29#define DUMP_OVERRIDERS 0
33 bool GenerateDefinition)
34 : Ctx(Ctx), MostDerivedClass(MostDerivedClass),
35 MostDerivedClassLayout(Ctx.getASTRecordLayout(MostDerivedClass)),
36 GenerateDefinition(GenerateDefinition) {
45 if (VTableClass == MostDerivedClass) {
46 assert(!SecondaryVirtualPointerIndices.count(
Base) &&
47 "A virtual pointer index already exists for this base subobject!");
48 SecondaryVirtualPointerIndices[
Base] = VTTComponents.size();
51 if (!GenerateDefinition) {
62 for (
const auto &I : RD->
bases()) {
67 const auto *BaseDecl =
81 bool BaseIsMorallyVirtual,
84 VisitedVirtualBasesSetTy &VBases) {
92 for (
const auto &I : RD->
bases()) {
93 const auto *BaseDecl =
103 if (!BaseDecl->isDynamicClass())
106 bool BaseDeclIsMorallyVirtual = BaseIsMorallyVirtual;
107 bool BaseDeclIsNonVirtualPrimaryBase =
false;
111 if (!VBases.insert(BaseDecl).second)
115 BaseDeclIsMorallyVirtual =
true;
119 BaseOffset =
Base.getBaseOffset() +
124 BaseDeclIsNonVirtualPrimaryBase =
true;
132 if (!BaseDeclIsNonVirtualPrimaryBase &&
133 (BaseDecl->getNumVBases() || BaseDeclIsMorallyVirtual)) {
135 AddVTablePointer(
BaseSubobject(BaseDecl, BaseOffset), VTableIndex,
140 LayoutSecondaryVirtualPointers(
BaseSubobject(BaseDecl, BaseOffset),
141 BaseDeclIsMorallyVirtual, VTableIndex,
142 VTableClass, VBases);
148 uint64_t VTableIndex) {
149 VisitedVirtualBasesSetTy VBases;
150 LayoutSecondaryVirtualPointers(
Base,
false,
151 VTableIndex,
Base.getBase(), VBases);
155 VisitedVirtualBasesSetTy &VBases) {
156 for (
const auto &I : RD->
bases()) {
157 const auto *BaseDecl =
163 if (!VBases.insert(BaseDecl).second)
174 if (BaseDecl->getNumVBases())
175 LayoutVirtualVTTs(BaseDecl, VBases);
188 bool IsPrimaryVTT =
Base.getBase() == MostDerivedClass;
192 SubVTTIndices[
Base] = VTTComponents.size();
195 uint64_t VTableIndex = VTTVTables.size();
199 AddVTablePointer(
Base, VTableIndex, RD);
202 LayoutSecondaryVTTs(
Base);
205 LayoutSecondaryVirtualPointers(
Base, VTableIndex);
209 VisitedVirtualBasesSetTy VBases;
210 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 ...
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - 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.
CharUnits - This is an opaque type for sizes expressed in character units.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
VTTBuilder(ASTContext &Ctx, const CXXRecordDecl *MostDerivedClass, bool GenerateDefinition)
The JSON file list parser is used to communicate input to InstallAPI.