forked from OSchip/llvm-project
parent
fcd6361ad1
commit
1300754fdd
clang/lib
|
@ -167,13 +167,14 @@ void ASTRecordLayoutBuilder::LayoutVirtualBase(const CXXRecordDecl *RD) {
|
||||||
LayoutBaseNonVirtually(RD);
|
LayoutBaseNonVirtually(RD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD) {
|
void ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD,
|
||||||
// FIXME: audit indirect virtual bases
|
llvm::SmallSet<const CXXRecordDecl*, 32> &IndirectPrimary) {
|
||||||
|
// FIXME: Though complete, this is the wrong order
|
||||||
for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(),
|
for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(),
|
||||||
e = RD->vbases_end(); i != e; ++i) {
|
e = RD->vbases_end(); i != e; ++i) {
|
||||||
const CXXRecordDecl *Base =
|
const CXXRecordDecl *Base =
|
||||||
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
|
cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
|
||||||
if (!PrimaryBaseWasVirtual || Base != PrimaryBase)
|
if (!IndirectPrimary.count(Base))
|
||||||
LayoutVirtualBase(Base);
|
LayoutVirtualBase(Base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,13 +216,20 @@ void ASTRecordLayoutBuilder::Layout(const RecordDecl *D) {
|
||||||
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
|
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
|
||||||
UpdateAlignment(AA->getAlignment());
|
UpdateAlignment(AA->getAlignment());
|
||||||
|
|
||||||
|
// FIXME: Calculate this completely.
|
||||||
|
llvm::SmallSet<const CXXRecordDecl*, 32> IndirectPrimary;
|
||||||
|
|
||||||
// If this is a C++ class, lay out the nonvirtual bases.
|
// If this is a C++ class, lay out the nonvirtual bases.
|
||||||
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D);
|
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D);
|
||||||
if (RD) {
|
if (RD) {
|
||||||
LayoutVtable(RD);
|
LayoutVtable(RD);
|
||||||
// PrimaryBase goes first.
|
// PrimaryBase goes first.
|
||||||
if (PrimaryBase)
|
if (PrimaryBase) {
|
||||||
|
// FIXME: We need all the primaries.
|
||||||
|
if (PrimaryBaseWasVirtual)
|
||||||
|
IndirectPrimary.insert(PrimaryBase);
|
||||||
LayoutBaseNonVirtually(PrimaryBase);
|
LayoutBaseNonVirtually(PrimaryBase);
|
||||||
|
}
|
||||||
LayoutNonVirtualBases(RD);
|
LayoutNonVirtualBases(RD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +239,7 @@ void ASTRecordLayoutBuilder::Layout(const RecordDecl *D) {
|
||||||
NonVirtualAlignment = Alignment;
|
NonVirtualAlignment = Alignment;
|
||||||
|
|
||||||
if (RD)
|
if (RD)
|
||||||
LayoutVirtualBases(RD);
|
LayoutVirtualBases(RD, IndirectPrimary);
|
||||||
|
|
||||||
// Finally, round the size of the total struct up to the alignment of the
|
// Finally, round the size of the total struct up to the alignment of the
|
||||||
// struct itself.
|
// struct itself.
|
||||||
|
|
|
@ -68,7 +68,8 @@ class ASTRecordLayoutBuilder {
|
||||||
void LayoutNonVirtualBases(const CXXRecordDecl *RD);
|
void LayoutNonVirtualBases(const CXXRecordDecl *RD);
|
||||||
void LayoutBaseNonVirtually(const CXXRecordDecl *RD);
|
void LayoutBaseNonVirtually(const CXXRecordDecl *RD);
|
||||||
void LayoutVirtualBase(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
|
/// FinishLayout - Finalize record layout. Adjust record size based on the
|
||||||
/// alignment.
|
/// alignment.
|
||||||
|
|
|
@ -765,7 +765,7 @@ llvm::Value *CodeGenFunction::GenerateVtable(const CXXRecordDecl *RD) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: finish layout for virtual bases
|
// 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(),
|
for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(),
|
||||||
e = RD->vbases_end(); i != e; ++i) {
|
e = RD->vbases_end(); i != e; ++i) {
|
||||||
const CXXRecordDecl *Base =
|
const CXXRecordDecl *Base =
|
||||||
|
|
Loading…
Reference in New Issue