[cfe-commits] r94519 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h test/CodeGenCXX/PR4890-debug-info-dtor.cpp test/CodeGenCXX/debug-info.cpp
Anders Carlsson
andersca at mac.com
Mon Jan 25 21:19:53 PST 2010
Author: andersca
Date: Mon Jan 25 23:19:50 2010
New Revision: 94519
URL: http://llvm.org/viewvc/llvm-project?rev=94519&view=rev
Log:
Fix the test I broke, and also fix a crash when declaring a virtual destructor. Add debug info support for pure virtual member functions.
Removed:
cfe/trunk/test/CodeGenCXX/PR4890-debug-info-dtor.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenCXX/debug-info.cpp
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=94519&r1=94518&r2=94519&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jan 25 23:19:50 2010
@@ -521,27 +521,21 @@
/// CreateCXXMemberFunction - A helper function to create a DISubprogram for
/// a single member function GlobalDecl.
llvm::DISubprogram
-CGDebugInfo::CreateCXXMemberFunction(GlobalDecl GD,
+CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method,
llvm::DICompileUnit Unit,
llvm::DICompositeType &RecordTy) {
- const CXXMethodDecl *Method = cast<CXXMethodDecl>(GD.getDecl());
-
- llvm::StringRef MethodName;
+ bool IsCtorOrDtor =
+ isa<CXXConstructorDecl>(Method) || isa<CXXDestructorDecl>(Method);
+
+ llvm::StringRef MethodName = getFunctionName(Method);
llvm::StringRef MethodLinkageName;
llvm::DIType MethodTy = getOrCreateType(Method->getType(), Unit);
- if (const CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(Method)) {
- (void)CDecl;
- MethodName = Method->getName();
- // FIXME : Find linkage name.
- } else if (const CXXDestructorDecl *DDecl = dyn_cast<CXXDestructorDecl>(Method)) {
- (void)DDecl;
- MethodName = getFunctionName(Method);
- // FIXME : Find linkage name.
- } else {
- // regular method
- MethodName = getFunctionName(Method);
+
+ // Since a single ctor/dtor corresponds to multiple functions, it doesn't
+ // make sense to give a single ctor/dtor a linkage name.
+ if (!IsCtorOrDtor)
MethodLinkageName = CGM.getMangledName(Method);
- }
+
SourceManager &SM = CGM.getContext().getSourceManager();
// Get the location for the method.
@@ -559,10 +553,17 @@
llvm::DIType ContainingType;
unsigned Virtuality = 0;
unsigned VIndex = 0;
+
if (Method->isVirtual()) {
- // FIXME: Identify pure virtual functions.
- Virtuality = llvm::dwarf::DW_VIRTUALITY_virtual;
- VIndex = CGM.getVtableInfo().getMethodVtableIndex(Method);
+ if (Method->isPure())
+ Virtuality = llvm::dwarf::DW_VIRTUALITY_pure_virtual;
+ else
+ Virtuality = llvm::dwarf::DW_VIRTUALITY_virtual;
+
+ // It doesn't make sense to give a virtual destructor a vtable index,
+ // since a single destructor has two entries in the vtable.
+ if (!isa<CXXDestructorDecl>(Method))
+ VIndex = CGM.getVtableInfo().getMethodVtableIndex(Method);
ContainingType = RecordTy;
}
@@ -573,8 +574,11 @@
MethodTy, /*isLocalToUnit=*/false,
Method->isThisDeclarationADefinition(),
Virtuality, VIndex, ContainingType);
- if (Method->isThisDeclarationADefinition())
- SPCache[cast<FunctionDecl>(Method)] = llvm::WeakVH(SP.getNode());
+
+ // Don't cache ctors or dtors since we have to emit multiple functions for
+ // a single ctor or dtor.
+ if (!IsCtorOrDtor && Method->isThisDeclarationADefinition())
+ SPCache[Method] = llvm::WeakVH(SP.getNode());
return SP;
}
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=94519&r1=94518&r2=94519&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Jan 25 23:19:50 2010
@@ -88,7 +88,7 @@
const Type *Ty, QualType PointeeTy,
llvm::DICompileUnit U);
- llvm::DISubprogram CreateCXXMemberFunction(GlobalDecl GD,
+ llvm::DISubprogram CreateCXXMemberFunction(const CXXMethodDecl *Method,
llvm::DICompileUnit Unit,
llvm::DICompositeType &RecordTy);
Removed: cfe/trunk/test/CodeGenCXX/PR4890-debug-info-dtor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR4890-debug-info-dtor.cpp?rev=94518&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/PR4890-debug-info-dtor.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/PR4890-debug-info-dtor.cpp (removed)
@@ -1,6 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm-only -g %s
-struct X {
- ~X();
-};
-
-X::~X() { }
Modified: cfe/trunk/test/CodeGenCXX/debug-info.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info.cpp?rev=94519&r1=94518&r2=94519&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info.cpp Mon Jan 25 23:19:50 2010
@@ -24,3 +24,20 @@
typedef struct { A x; } B;
B x;
}
+
+// PR4890
+namespace PR4890 {
+ struct X {
+ ~X();
+ };
+
+ X::~X() { }
+}
+
+namespace VirtualDtor {
+ struct Y {
+ virtual ~Y();
+ };
+
+ Y::~Y() { }
+}
More information about the cfe-commits
mailing list