зеркало из https://github.com/microsoft/clang-1.git
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:
Родитель
8d5053c864
Коммит
d53cef178d
|
@ -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 =
|
||||
|
|
Загрузка…
Ссылка в новой задаче