[cfe-commits] r98229 - in /cfe/trunk/lib/AST: RecordLayoutBuilder.cpp RecordLayoutBuilder.h
Anders Carlsson
andersca at mac.com
Wed Mar 10 18:41:30 PST 2010
Author: andersca
Date: Wed Mar 10 20:41:30 2010
New Revision: 98229
URL: http://llvm.org/viewvc/llvm-project?rev=98229&view=rev
Log:
More record layout builder cleanup.
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=98229&r1=98228&r2=98229&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Wed Mar 10 20:41:30 2010
@@ -221,8 +221,7 @@
void ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *Class,
const CXXRecordDecl *RD,
const CXXRecordDecl *PB,
- uint64_t Offset,
- llvm::SmallSet<const CXXRecordDecl*, 32> &mark) {
+ uint64_t Offset) {
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
assert(!i->getType()->isDependentType() &&
@@ -233,10 +232,10 @@
if (i->isVirtual()) {
if (Base == PB) {
// Only lay things out once.
- if (mark.count(Base))
+ if (VisitedVirtualBases.count(Base))
continue;
// Mark it so we don't lay it out twice.
- mark.insert(Base);
+ VisitedVirtualBases.insert(Base);
assert (IndirectPrimaryBases.count(Base) && "IndirectPrimary was wrong");
VBases.push_back(std::make_pair(Base, Offset));
} else if (IndirectPrimaryBases.count(Base)) {
@@ -244,10 +243,10 @@
;
} else {
// Only lay things out once.
- if (mark.count(Base))
+ if (VisitedVirtualBases.count(Base))
continue;
// Mark it so we don't lay it out twice.
- mark.insert(Base);
+ VisitedVirtualBases.insert(Base);
LayoutVirtualBase(Base);
BaseOffset = VBases.back().second;
}
@@ -263,7 +262,7 @@
if (Base->getNumVBases()) {
const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(Base);
const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBaseInfo().getBase();
- LayoutVirtualBases(Class, Base, PrimaryBase, BaseOffset, mark);
+ LayoutVirtualBases(Class, Base, PrimaryBase, BaseOffset);
}
}
}
@@ -486,8 +485,7 @@
NonVirtualAlignment = Alignment;
if (RD) {
- llvm::SmallSet<const CXXRecordDecl*, 32> mark;
- LayoutVirtualBases(RD, RD, PrimaryBase.getBase(), 0, mark);
+ LayoutVirtualBases(RD, RD, PrimaryBase.getBase(), 0);
}
// Finally, round the size of the total struct up to the alignment of the
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.h?rev=98229&r1=98228&r2=98229&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.h (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.h Wed Mar 10 20:41:30 2010
@@ -77,6 +77,10 @@
/// inheritance graph order. Used for determining the primary base class.
const CXXRecordDecl *FirstNearlyEmptyVBase;
+ /// VisitedVirtualBases - A set of all the visited virtual bases, used to
+ /// avoid visiting virtual bases more than once.
+ llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedVirtualBases;
+
/// EmptyClassOffsets - A map from offsets to empty record decls.
typedef std::multimap<uint64_t, const CXXRecordDecl *> EmptyClassOffsetsTy;
EmptyClassOffsetsTy EmptyClassOffsets;
@@ -113,8 +117,7 @@
/// LayoutVirtualBases - Lays out all the virtual bases.
void LayoutVirtualBases(const CXXRecordDecl *Class, const CXXRecordDecl *RD,
- const CXXRecordDecl *PB, uint64_t Offset,
- llvm::SmallSet<const CXXRecordDecl*, 32> &mark);
+ const CXXRecordDecl *PB, uint64_t Offset);
/// LayoutVirtualBase - Lays out a single virtual base.
void LayoutVirtualBase(const CXXRecordDecl *RD);
More information about the cfe-commits
mailing list