diff options
author | Anders Carlsson <andersca@mac.com> | 2010-02-27 20:39:05 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-02-27 20:39:05 +0000 |
commit | d03a3260a27d1d5168e5eb1dbb736747c477dcbb (patch) | |
tree | 60c2a00e3b195072f6af980839782b1e29e27c49 /lib/CodeGen/CGVtable.cpp | |
parent | 327568ec139958def07e30f37a1bafac38819676 (diff) |
Start fleshing out construction vtable support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97342 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVtable.cpp')
-rw-r--r-- | lib/CodeGen/CGVtable.cpp | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp index af1db88221..457bfa559c 100644 --- a/lib/CodeGen/CGVtable.cpp +++ b/lib/CodeGen/CGVtable.cpp @@ -1058,6 +1058,15 @@ private: /// vtable. const CXXRecordDecl *MostDerivedClass; + /// MostDerivedClassOffset - If we're building a construction vtable, this + /// holds the offset from the layout class to the most derived class. + const uint64_t MostDerivedClassOffset; + + /// LayoutClass - The class we're using for layout information. Will be + /// different than the most derived class if we're building a construction + /// vtable. + const CXXRecordDecl *LayoutClass; + /// Context - The ASTContext which we will use for layout information. ASTContext &Context; @@ -1215,9 +1224,12 @@ private: VisitedVirtualBasesSetTy &VBases); public: - VtableBuilder(CGVtableInfo &VtableInfo, const CXXRecordDecl *MostDerivedClass) - : VtableInfo(VtableInfo), MostDerivedClass(MostDerivedClass), - Context(MostDerivedClass->getASTContext()), Overriders(MostDerivedClass) { + VtableBuilder(CGVtableInfo &VtableInfo, const CXXRecordDecl *MostDerivedClass, + uint64_t MostDerivedClassOffset, + const CXXRecordDecl *LayoutClass) + : VtableInfo(VtableInfo), MostDerivedClass(MostDerivedClass), + MostDerivedClassOffset(MostDerivedClassOffset), LayoutClass(LayoutClass), + Context(MostDerivedClass->getASTContext()), Overriders(MostDerivedClass) { LayoutVtable(); } @@ -1808,8 +1820,17 @@ VtableBuilder::LayoutVtablesForVirtualBases(const CXXRecordDecl *RD, /// dumpLayout - Dump the vtable layout. void VtableBuilder::dumpLayout(llvm::raw_ostream& Out) { - - Out << "Vtable for '" << MostDerivedClass->getQualifiedNameAsString(); + + if (MostDerivedClass == LayoutClass) { + Out << "Vtable for '"; + Out << MostDerivedClass->getQualifiedNameAsString(); + } else { + Out << "Construction vtable for ('"; + Out << MostDerivedClass->getQualifiedNameAsString() << "', "; + // FIXME: Don't use / 8 . + Out << MostDerivedClassOffset / 8 << ") in '"; + Out << LayoutClass->getQualifiedNameAsString(); + } Out << "' (" << Components.size() << " entries).\n"; // Iterate through the address points and insert them into a new map where @@ -1983,7 +2004,8 @@ void VtableBuilder::dumpLayout(llvm::raw_ostream& Out) { Out << '\n'; } - + + Out << '\n'; } } @@ -3272,11 +3294,17 @@ CGVtableInfo::GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage, const CXXRecordDecl *LayoutClass, const CXXRecordDecl *RD, uint64_t Offset, AddressPointsMapTy& AddressPoints) { - if (GenerateDefinition && LayoutClass == RD) { - VtableBuilder Builder(*this, RD); - - if (CGM.getLangOptions().DumpVtableLayouts) + if (GenerateDefinition) { + if (LayoutClass == RD) { + VtableBuilder Builder(*this, RD, Offset, LayoutClass); + + if (CGM.getLangOptions().DumpVtableLayouts) + Builder.dumpLayout(llvm::errs()); + } else if (CGM.getLangOptions().DumpVtableLayouts) { + // We only build construction vtables when dumping vtable layouts for now. + VtableBuilder Builder(*this, RD, Offset, LayoutClass); Builder.dumpLayout(llvm::errs()); + } } llvm::SmallString<256> OutName; |