[cfe-commits] r120140 - /cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Anders Carlsson
andersca at mac.com
Wed Nov 24 17:59:35 PST 2010
Author: andersca
Date: Wed Nov 24 19:59:35 2010
New Revision: 120140
URL: http://llvm.org/viewvc/llvm-project?rev=120140&view=rev
Log:
Begin work on actually laying out virtual bases.
Modified:
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=120140&r1=120139&r2=120140&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Wed Nov 24 19:59:35 2010
@@ -107,6 +107,9 @@
/// Returns false if the operation failed because the struct is not packed.
bool LayoutFields(const RecordDecl *D);
+ /// LayoutVirtualBase - layout a single virtual base.
+ void LayoutVirtualBase(const CXXRecordDecl *BaseDecl, uint64_t BaseOffset);
+
/// LayoutNonVirtualBase - layout a single non-virtual base.
void LayoutNonVirtualBase(const CXXRecordDecl *BaseDecl,
uint64_t BaseOffset);
@@ -487,6 +490,29 @@
AppendPadding(Layout.getSize() / 8, Align);
}
+void
+CGRecordLayoutBuilder::LayoutVirtualBase(const CXXRecordDecl *BaseDecl,
+ uint64_t BaseOffset) {
+ // Ignore empty bases.
+ if (BaseDecl->isEmpty())
+ return;
+
+ CheckZeroInitializable(BaseDecl);
+
+ const ASTRecordLayout &Layout =
+ Types.getContext().getASTRecordLayout(BaseDecl);
+
+ uint64_t NonVirtualSize = Layout.getNonVirtualSize();
+
+ // FIXME: Actually use a better type than [sizeof(BaseDecl) x i8] when we can.
+ AppendPadding(BaseOffset / 8, 1);
+
+ // FIXME: Add the vbase field info.
+
+ AppendBytes(NonVirtualSize / 8);
+
+}
+
void CGRecordLayoutBuilder::LayoutNonVirtualBase(const CXXRecordDecl *BaseDecl,
uint64_t BaseOffset) {
// Ignore empty bases.
@@ -526,9 +552,10 @@
"VTable pointer must come first!");
AppendField(NextFieldOffsetInBytes, VTableTy->getPointerTo());
} else {
- // FIXME: Handle a virtual primary base.
if (!Layout.isPrimaryBaseVirtual())
LayoutNonVirtualBase(PrimaryBase, 0);
+ else
+ LayoutVirtualBase(PrimaryBase, 0);
}
}
@@ -608,6 +635,10 @@
if (RD)
ComputeNonVirtualBaseType(RD);
+ if (RD) {
+ RD->getIndirectPrimaryBases(IndirectPrimaryBases);
+ }
+
// FIXME: Lay out the virtual bases instead of just treating them as tail
// padding.
More information about the cfe-commits
mailing list