[cfe-commits] r98233 - in /cfe/trunk/lib/AST: RecordLayoutBuilder.cpp RecordLayoutBuilder.h
Anders Carlsson
andersca at mac.com
Wed Mar 10 20:33:54 PST 2010
Author: andersca
Date: Wed Mar 10 22:33:54 2010
New Revision: 98233
URL: http://llvm.org/viewvc/llvm-project?rev=98233&view=rev
Log:
Get rid of the PrimaryBase parameter from LayoutVirtualBases.
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.h
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=98233&r1=98232&r2=98233&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Wed Mar 10 22:33:54 2010
@@ -217,11 +217,18 @@
}
void
-ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *Class,
- const CXXRecordDecl *RD,
- const CXXRecordDecl *PB,
- uint64_t Offset) {
-
+ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD,
+ uint64_t Offset,
+ const CXXRecordDecl *MostDerivedClass) {
+ const CXXRecordDecl *PrimaryBase;
+
+ if (MostDerivedClass == RD)
+ PrimaryBase = this->PrimaryBase.getBase();
+ else {
+ const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(RD);
+ PrimaryBase = Layout.getPrimaryBase();
+ }
+
for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(),
E = RD->bases_end(); I != E; ++I) {
assert(!I->getType()->isDependentType() &&
@@ -231,7 +238,7 @@
cast<CXXRecordDecl>(I->getType()->getAs<RecordType>()->getDecl());
if (I->isVirtual()) {
- if (Base == PB) {
+ if (Base == PrimaryBase) {
// Only lay things out once.
if (VisitedVirtualBases.count(Base))
continue;
@@ -268,7 +275,7 @@
// We want the vbase offset from the class we're currently laying out.
assert(VBases.count(Base) && "Did not find virtual base!");
BaseOffset = VBases[Base];
- } else if (RD == Class) {
+ } else if (RD == MostDerivedClass) {
// We want the base offset from the class we're currently laying out.
assert(Bases.count(Base) && "Did not find base!");
BaseOffset = Bases[Base];
@@ -277,9 +284,7 @@
BaseOffset = Offset + Layout.getBaseClassOffset(Base);
}
- const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(Base);
- const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBaseInfo().getBase();
- LayoutVirtualBases(Class, Base, PrimaryBase, BaseOffset);
+ LayoutVirtualBases(Base, BaseOffset, MostDerivedClass);
}
}
@@ -501,9 +506,9 @@
NonVirtualSize = Size;
NonVirtualAlignment = Alignment;
- if (RD) {
- LayoutVirtualBases(RD, RD, PrimaryBase.getBase(), 0);
- }
+ // If this is a C++ clas, lay out its virtual bases.
+ if (RD)
+ LayoutVirtualBases(RD, 0, RD);
// 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=98233&r1=98232&r2=98233&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.h (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.h Wed Mar 10 22:33:54 2010
@@ -113,8 +113,8 @@
void LayoutNonVirtualBase(const CXXRecordDecl *RD);
/// LayoutVirtualBases - Lays out all the virtual bases.
- void LayoutVirtualBases(const CXXRecordDecl *Class, const CXXRecordDecl *RD,
- const CXXRecordDecl *PB, uint64_t Offset);
+ void LayoutVirtualBases(const CXXRecordDecl *RD, uint64_t Offset,
+ const CXXRecordDecl *MostDerivedClass);
/// LayoutVirtualBase - Lays out a single virtual base.
void LayoutVirtualBase(const CXXRecordDecl *RD);
More information about the cfe-commits
mailing list