[cfe-commits] r94712 - /cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Devang Patel
dpatel at apple.com
Wed Jan 27 16:54:21 PST 2010
Author: dpatel
Date: Wed Jan 27 18:54:21 2010
New Revision: 94712
URL: http://llvm.org/viewvc/llvm-project?rev=94712&view=rev
Log:
While emitting debugging infor for a C++ class, identify the holder of class's vtable, if any.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=94712&r1=94711&r2=94712&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jan 27 18:54:21 2010
@@ -738,9 +738,18 @@
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::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.
More information about the cfe-commits
mailing list