Prep for vbase layout refinements. WIP.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78882 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mike Stump 2009-08-13 02:02:14 +00:00
Родитель 8d5053c864
Коммит d53cef178d
3 изменённых файлов: 16 добавлений и 7 удалений

Просмотреть файл

@ -167,13 +167,14 @@ void ASTRecordLayoutBuilder::LayoutVirtualBase(const CXXRecordDecl *RD) {
LayoutBaseNonVirtually(RD);
}
void ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD) {
// FIXME: audit indirect virtual bases
void ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD,
llvm::SmallSet<const CXXRecordDecl*, 32> &IndirectPrimary) {
// FIXME: Though complete, this is the wrong order
for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(),
e = RD->vbases_end(); i != e; ++i) {
const CXXRecordDecl *Base =
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
if (!PrimaryBaseWasVirtual || Base != PrimaryBase)
if (!IndirectPrimary.count(Base))
LayoutVirtualBase(Base);
}
}
@ -215,13 +216,20 @@ void ASTRecordLayoutBuilder::Layout(const RecordDecl *D) {
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
UpdateAlignment(AA->getAlignment());
// FIXME: Calculate this completely.
llvm::SmallSet<const CXXRecordDecl*, 32> IndirectPrimary;
// If this is a C++ class, lay out the nonvirtual bases.
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D);
if (RD) {
LayoutVtable(RD);
// PrimaryBase goes first.
if (PrimaryBase)
if (PrimaryBase) {
// FIXME: We need all the primaries.
if (PrimaryBaseWasVirtual)
IndirectPrimary.insert(PrimaryBase);
LayoutBaseNonVirtually(PrimaryBase);
}
LayoutNonVirtualBases(RD);
}
@ -231,7 +239,7 @@ void ASTRecordLayoutBuilder::Layout(const RecordDecl *D) {
NonVirtualAlignment = Alignment;
if (RD)
LayoutVirtualBases(RD);
LayoutVirtualBases(RD, IndirectPrimary);
// Finally, round the size of the total struct up to the alignment of the
// struct itself.

Просмотреть файл

@ -68,7 +68,8 @@ class ASTRecordLayoutBuilder {
void LayoutNonVirtualBases(const CXXRecordDecl *RD);
void LayoutBaseNonVirtually(const CXXRecordDecl *RD);
void LayoutVirtualBase(const CXXRecordDecl *RD);
void LayoutVirtualBases(const CXXRecordDecl *RD);
void LayoutVirtualBases(const CXXRecordDecl *RD,
llvm::SmallSet<const CXXRecordDecl*, 32> &IndirectPrimary);
/// FinishLayout - Finalize record layout. Adjust record size based on the
/// alignment.

Просмотреть файл

@ -765,7 +765,7 @@ llvm::Value *CodeGenFunction::GenerateVtable(const CXXRecordDecl *RD) {
}
// FIXME: finish layout for virtual bases
// FIXME: audit indirect virtual bases
// FIXME: Though complete, this is the wrong order
for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(),
e = RD->vbases_end(); i != e; ++i) {
const CXXRecordDecl *Base =