[cfe-commits] r78954 - /cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Mike Stump
mrs at apple.com
Thu Aug 13 16:26:06 PDT 2009
Author: mrs
Date: Thu Aug 13 18:26:06 2009
New Revision: 78954
URL: http://llvm.org/viewvc/llvm-project?rev=78954&view=rev
Log:
We can't avoid doing the work to find all the indirect primary virtual
base classes as we'll need that to layout the virtual bases...
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=78954&r1=78953&r2=78954&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Thu Aug 13 18:26:06 2009
@@ -116,9 +116,19 @@
}
/// SelectPrimaryBase - Selects the primary base for the given class and
-/// record that with setPrimaryBase.
+/// record that with setPrimaryBase. We also calculate the IndirectPrimaries.
void ASTRecordLayoutBuilder::SelectPrimaryBase(const CXXRecordDecl *RD,
llvm::SmallSet<const CXXRecordDecl*, 32> &IndirectPrimary) {
+ // We compute all the primary virtual bases for all of our direct and
+ // indirect bases, and record all their primary virtual base classes.
+ const CXXRecordDecl *FirstPrimary = 0;
+ for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
+ e = RD->bases_end(); i != e; ++i) {
+ const CXXRecordDecl *Base =
+ cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
+ SelectPrimaryForBase(Base, IndirectPrimary);
+ }
+
// The primary base is the first non-virtual indirect or direct base class,
// if one exists.
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
@@ -140,19 +150,8 @@
// If we have no virtual bases at this point, bail out as the searching below
// is expensive.
- if (RD->getNumVBases() == 0) {
+ if (RD->getNumVBases() == 0)
return;
- }
-
- // First, we compute all the primary virtual bases for all of our direct and
- // indirect bases, and record all their primary virtual base classes.
- const CXXRecordDecl *FirstPrimary = 0;
- for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
- e = RD->bases_end(); i != e; ++i) {
- const CXXRecordDecl *Base =
- cast<CXXRecordDecl>(i->getType()->getAs<RecordType>()->getDecl());
- SelectPrimaryForBase(Base, IndirectPrimary);
- }
// Then we can search for the first nearly empty virtual base itself.
SelectPrimaryVBase(RD, FirstPrimary, IndirectPrimary);
@@ -169,8 +168,6 @@
void ASTRecordLayoutBuilder::LayoutVirtualBases(const CXXRecordDecl *RD,
llvm::SmallSet<const CXXRecordDecl*, 32> &IndirectPrimary) {
- // FIXME: Calculate IndirectPrimary when !PrimaryBaseWasVirtual
- // assert(PrimaryBaseWasVirtual && "FIXME: calculate IndirectPrimary");
for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(),
e = RD->bases_end(); i != e; ++i) {
const CXXRecordDecl *Base =
@@ -230,7 +227,6 @@
LayoutVtable(RD, IndirectPrimary);
// PrimaryBase goes first.
if (PrimaryBase) {
- // FIXME: We need all the primaries.
if (PrimaryBaseWasVirtual)
IndirectPrimary.insert(PrimaryBase);
LayoutBaseNonVirtually(PrimaryBase);
More information about the cfe-commits
mailing list