From 584e1dfaf6ab682cebe4fe51f55f0ae3215d303f Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Thu, 11 Mar 2010 03:39:12 +0000 Subject: [PATCH] More cleanup. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98230 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/RecordLayoutBuilder.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index eab4f11137..d9fa11d5a8 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -63,32 +63,29 @@ void ASTRecordLayoutBuilder::IdentifyPrimaryBases(const CXXRecordDecl *RD) { void ASTRecordLayoutBuilder::SelectPrimaryVBase(const CXXRecordDecl *RD) { - - for (CXXRecordDecl::base_class_const_iterator i = RD->bases_begin(), - e = RD->bases_end(); i != e; ++i) { - assert(!i->getType()->isDependentType() && + for (CXXRecordDecl::base_class_const_iterator I = RD->bases_begin(), + E = RD->bases_end(); I != E; ++I) { + assert(!I->getType()->isDependentType() && "Cannot layout class with dependent bases."); + const CXXRecordDecl *Base = - cast(i->getType()->getAs()->getDecl()); - if (!i->isVirtual()) { - SelectPrimaryVBase(Base); - if (PrimaryBase.getBase()) - return; - continue; - } - if (IsNearlyEmpty(Base)) { - // Is this the first nearly empty primary virtual base? - if (!FirstNearlyEmptyVBase) - FirstNearlyEmptyVBase = Base; + cast(I->getType()->getAs()->getDecl()); + // Check if this is a nearly empty virtual base. + if (I->isVirtual() && IsNearlyEmpty(Base)) { + // If it's not an indirect primary base, then we've found our primary + // base. if (!IndirectPrimaryBases.count(Base)) { PrimaryBase = ASTRecordLayout::PrimaryBaseInfo(Base, /*IsVirtual=*/true); return; } + + // Is this the first nearly empty virtual base? + if (!FirstNearlyEmptyVBase) + FirstNearlyEmptyVBase = Base; } - assert(i->isVirtual()); SelectPrimaryVBase(Base); if (PrimaryBase.getBase()) return; @@ -142,8 +139,8 @@ void ASTRecordLayoutBuilder::DeterminePrimaryBase(const CXXRecordDecl *RD) { // Otherwise, it is the first nearly empty virtual base that is not an // indirect primary virtual base class, if one exists. if (FirstNearlyEmptyVBase) { - PrimaryBase = - ASTRecordLayout::PrimaryBaseInfo(FirstNearlyEmptyVBase, /*IsVirtual=*/true); + PrimaryBase = ASTRecordLayout::PrimaryBaseInfo(FirstNearlyEmptyVBase, + /*IsVirtual=*/true); return; } -- 2.40.0