Cleanups.

llvm-svn: 81072
This commit is contained in:
Mike Stump 2009-09-05 08:37:03 +00:00
parent db14a73606
commit ea8eea2c45
1 changed files with 29 additions and 5 deletions

View File

@ -1077,6 +1077,32 @@ public:
return AddressPoint; return AddressPoint;
} }
void Primaries(const CXXRecordDecl *RD, bool forPrimary,
bool MorallyVirtual, int64_t Offset, bool ForVirtualBase) {
if (!RD->isDynamicClass())
return;
const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase();
const bool PrimaryBaseWasVirtual = Layout.getPrimaryBaseWasVirtual();
std::vector<llvm::Constant *> offsets;
bool Top = true;
// vtables are composed from the chain of primaries.
if (PrimaryBase) {
if (PrimaryBaseWasVirtual)
IndirectPrimary.insert(PrimaryBase);
Top = false;
Primaries(PrimaryBase, true, PrimaryBaseWasVirtual|MorallyVirtual,
Offset, PrimaryBaseWasVirtual);
}
// And add the virtuals for the class to the primary vtable.
AddMethods(RD, MorallyVirtual, Offset);
}
int64_t GenerateVtableForBase(const CXXRecordDecl *RD, bool forPrimary, int64_t GenerateVtableForBase(const CXXRecordDecl *RD, bool forPrimary,
bool Bottom, bool MorallyVirtual, bool Bottom, bool MorallyVirtual,
int64_t Offset, bool ForVirtualBase) { int64_t Offset, bool ForVirtualBase) {
@ -1089,8 +1115,7 @@ public:
std::vector<llvm::Constant *> offsets; std::vector<llvm::Constant *> offsets;
// FIXME: Audit, is this right? // FIXME: Audit, is this right?
if (Bottom && (PrimaryBase == 0 || forPrimary || !PrimaryBaseWasVirtual if (Bottom) {
|| Bottom)) {
extra = 0; extra = 0;
GenerateVBaseOffsets(offsets, RD, Offset); GenerateVBaseOffsets(offsets, RD, Offset);
if (ForVirtualBase) if (ForVirtualBase)
@ -1104,9 +1129,8 @@ public:
if (PrimaryBaseWasVirtual) if (PrimaryBaseWasVirtual)
IndirectPrimary.insert(PrimaryBase); IndirectPrimary.insert(PrimaryBase);
Top = false; Top = false;
GenerateVtableForBase(PrimaryBase, true, false, Primaries(PrimaryBase, true, PrimaryBaseWasVirtual|MorallyVirtual,
PrimaryBaseWasVirtual|MorallyVirtual, Offset, Offset, PrimaryBaseWasVirtual);
PrimaryBaseWasVirtual);
} }
// And add the virtuals for the class to the primary vtable. // And add the virtuals for the class to the primary vtable.