From 115b4756b5c7940c997d571a6db85eaa7ec732ad Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 10 Mar 2010 19:39:11 +0000 Subject: We were mistakenly marking morally virtual bases as being uninteresting. Fix this. llvm-svn: 98180 --- clang/lib/CodeGen/CGVtable.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp index caf1e1f93e4..37dd23c0b51 100644 --- a/clang/lib/CodeGen/CGVtable.cpp +++ b/clang/lib/CodeGen/CGVtable.cpp @@ -1235,7 +1235,11 @@ private: /// LayoutSecondaryVtables - Layout the secondary vtables for the given base /// subobject. - void LayoutSecondaryVtables(BaseSubobject Base, uint64_t OffsetInLayoutClass); + /// + /// \param BaseIsMorallyVirtual whether the base subobject is a virtual base + /// or a direct or indirect base of a virtual base. + void LayoutSecondaryVtables(BaseSubobject Base, bool BaseIsMorallyVirtual, + uint64_t OffsetInLayoutClass); /// DeterminePrimaryVirtualBases - Determine the primary virtual bases in this /// class hierarchy. @@ -1772,11 +1776,16 @@ VtableBuilder::LayoutPrimaryAndSecondaryVtables(BaseSubobject Base, AddressPoints.insert(std::make_pair(PrimaryBase, AddressPoint)); } + bool BaseIsMorallyVirtual = BaseIsVirtual; + if (isBuildingConstructorVtable() && Base.getBase() == MostDerivedClass) + BaseIsMorallyVirtual = false; + // Layout secondary vtables. - LayoutSecondaryVtables(Base, OffsetInLayoutClass); + LayoutSecondaryVtables(Base, BaseIsMorallyVirtual, OffsetInLayoutClass); } void VtableBuilder::LayoutSecondaryVtables(BaseSubobject Base, + bool BaseIsMorallyVirtual, uint64_t OffsetInLayoutClass) { // Itanium C++ ABI 2.5.2: // Following the primary virtual table of a derived class are secondary @@ -1806,9 +1815,8 @@ void VtableBuilder::LayoutSecondaryVtables(BaseSubobject Base, // tables, which will therefore not be present in the construction // virtual table group, even though the subobject virtual tables are // present in the main virtual table group for the complete object. - if (!BaseDecl->getNumVBases()) { + if (!BaseIsMorallyVirtual && !BaseDecl->getNumVBases()) continue; - } } // Get the base offset of this base. @@ -1821,7 +1829,7 @@ void VtableBuilder::LayoutSecondaryVtables(BaseSubobject Base, // to emit secondary vtables for other bases of this base. if (BaseDecl == PrimaryBase) { LayoutSecondaryVtables(BaseSubobject(BaseDecl, BaseOffset), - BaseOffsetInLayoutClass); + BaseIsMorallyVirtual, BaseOffsetInLayoutClass); continue; } -- cgit v1.2.3