diff options
author | Devang Patel <dpatel@apple.com> | 2010-01-25 23:32:18 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-01-25 23:32:18 +0000 |
commit | a245c5b36a12e7a879abc038964d0b9821c7e901 (patch) | |
tree | 62ce4273541c736b6986c135acdb1a48f8c45c34 /lib/CodeGen/CGDebugInfo.cpp | |
parent | c002464ae56bbd069cb0c204ce2b766c7ae5063a (diff) |
First cut at emitting inheritance info.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94473 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 2b03d2c603..412552be1c 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -586,6 +586,40 @@ CollectCXXMemberFunctions(const CXXRecordDecl *Decl, } } +/// CollectCXXBases - A helper function to collect debug info for +/// C++ base classes. This is used while creating debug info entry for +/// a Record. +void CGDebugInfo:: +CollectCXXBases(const CXXRecordDecl *Decl, + llvm::DICompileUnit Unit, + llvm::SmallVectorImpl<llvm::DIDescriptor> &EltTys, + llvm::DICompositeType &RecordTy) { + + const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(Decl); + for (CXXRecordDecl::base_class_const_iterator BI = Decl->bases_begin(), + BE = Decl->bases_end(); BI != BE; ++BI) { + unsigned BFlags = 0; + if (BI->isVirtual()) + BFlags = llvm::DIType::FlagVirtual; + AccessSpecifier Access = BI->getAccessSpecifier(); + if (Access == clang::AS_private) + BFlags |= llvm::DIType::FlagPrivate; + else if (Access == clang::AS_protected) + BFlags |= llvm::DIType::FlagProtected; + + const CXXRecordDecl *Base = + cast<CXXRecordDecl>(BI->getType()->getAs<RecordType>()->getDecl()); + llvm::DIType DTy = + DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_inheritance, + RecordTy, llvm::StringRef(), + llvm::DICompileUnit(), 0, 0, 0, + RL.getBaseClassOffset(Base), BFlags, + getOrCreateType(BI->getType(), + Unit)); + EltTys.push_back(DTy); + } +} + /// CreateType - get structure or union type. llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, llvm::DICompileUnit Unit) { @@ -643,8 +677,10 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, llvm::SmallVector<llvm::DIDescriptor, 16> EltTys; CollectRecordFields(Decl, Unit, EltTys); - if (CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(Decl)) + if (CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(Decl)) { CollectCXXMemberFunctions(CXXDecl, Unit, EltTys, FwdDecl); + CollectCXXBases(CXXDecl, Unit, EltTys, FwdDecl); + } llvm::DIArray Elements = DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size()); |