aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2010-01-28 00:54:21 +0000
committerDevang Patel <dpatel@apple.com>2010-01-28 00:54:21 +0000
commit0ac8f31af4a8f669700ab8fcad4ae1afc3517373 (patch)
tree1b062db98aa9a1e5120be41c27c5e8f9de8d16bf /lib/CodeGen/CGDebugInfo.cpp
parenta6da192bbb3cb2b99200f60726b78e2d3d1f1598 (diff)
While emitting debugging infor for a C++ class, identify the holder of class's vtable, if any.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94712 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 812f552fed..d55ddb7c2d 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -738,9 +738,18 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
llvm::SmallVector<llvm::DIDescriptor, 16> EltTys;
CollectRecordFields(Decl, Unit, EltTys);
+ llvm::MDNode *ContainingType = NULL;
if (CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(Decl)) {
CollectCXXMemberFunctions(CXXDecl, Unit, EltTys, FwdDecl);
CollectCXXBases(CXXDecl, Unit, EltTys, FwdDecl);
+
+ // A class's primary base or the class itself contains the vtable.
+ const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(Decl);
+ if (const CXXRecordDecl *PBase = RL.getPrimaryBase())
+ ContainingType =
+ getOrCreateType(QualType(PBase->getTypeForDecl(), 0), Unit).getNode();
+ else if (CXXDecl->isDynamicClass())
+ ContainingType = FwdDecl.getNode();
}
llvm::DIArray Elements =
@@ -753,7 +762,8 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
llvm::DICompositeType RealDecl =
DebugFactory.CreateCompositeType(Tag, Unit, Decl->getName(),
DefUnit, Line, Size, Align, 0, 0,
- llvm::DIType(), Elements);
+ llvm::DIType(), Elements,
+ 0, ContainingType);
// Now that we have a real decl for the struct, replace anything using the
// old decl with the new one. This will recursively update the debug info.