[cfe-commits] r78882 - in /cfe/trunk/lib: AST/RecordLayoutBuilder.cpp AST/RecordLayoutBuilder.h CodeGen/CGCXX.cpp
Mike Stump
mrs at apple.com
Wed Aug 12 19:02:15 PDT 2009
Author: mrs
Date: Wed Aug 12 21:02:14 2009
New Revision: 78882
URL: http://llvm.org/viewvc/llvm-project?rev=78882&view=rev
Log:
Prep for vbase layout refinements. WIP.
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.h
cfe/trunk/lib/CodeGen/CGCXX.cpp
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=78882&r1=78881&r2=78882&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Wed Aug 12 21:02:14 2009
@@ -167,13 +167,14 @@
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 @@
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 @@
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.
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.h?rev=78882&r1=78881&r2=78882&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.h (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.h Wed Aug 12 21:02:14 2009
@@ -68,7 +68,8 @@
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.
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=78882&r1=78881&r2=78882&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Wed Aug 12 21:02:14 2009
@@ -765,7 +765,7 @@
}
// 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 =
More information about the cfe-commits
mailing list