From bdb4a9da62c585c4f5384a5976cdb36725a44f98 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 24 Nov 2010 23:04:03 +0000 Subject: [PATCH] Move code off the primary base info iterator. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120132 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGVTables.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 066b20c837..c40f437c6a 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -2240,6 +2240,19 @@ void VTableBuilder::dumpLayout(llvm::raw_ostream& Out) { } +static void +CollectPrimaryBases(const CXXRecordDecl *RD, ASTContext &Context, + VTableBuilder::PrimaryBasesSetVectorTy &PrimaryBases) { + while (RD) { + const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD); + const CXXRecordDecl *PrimaryBase = Layout.getPrimaryBase(); + if (PrimaryBase) + PrimaryBases.insert(PrimaryBase); + + RD = PrimaryBase; + } +} + void CodeGenVTables::ComputeMethodVTableIndices(const CXXRecordDecl *RD) { // Itanium C++ ABI 2.5.2: @@ -2268,10 +2281,7 @@ void CodeGenVTables::ComputeMethodVTableIndices(const CXXRecordDecl *RD) { // Collect all the primary bases, so we can check whether methods override // a method from the base. VTableBuilder::PrimaryBasesSetVectorTy PrimaryBases; - for (ASTRecordLayout::primary_base_info_iterator - I = Layout.primary_base_begin(), E = Layout.primary_base_end(); - I != E; ++I) - PrimaryBases.insert((*I).getBase()); + CollectPrimaryBases(RD, CGM.getContext(), PrimaryBases); const CXXDestructorDecl *ImplicitVirtualDtor = 0; -- 2.40.0