From 1c29652fbcd097aa6c21511c9f4f886bb3f3a8af Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 31 May 2011 20:46:46 +0000 Subject: [PATCH] List c++ class type as public type in dwarf debug info output. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132357 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 13 +++++++++++-- lib/CodeGen/CGDebugInfo.h | 2 ++ test/CodeGenCXX/debug-info-pubtypes.cpp | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 test/CodeGenCXX/debug-info-pubtypes.cpp diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 6c73865c3c..d1b4aad7fa 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1621,6 +1621,16 @@ llvm::DISubprogram CGDebugInfo::getFunctionDeclaration(const Decl *D) { return llvm::DISubprogram(); } +// getOrCreateFunctionType - Construct DIType. If it is a c++ method, include +// implicit parameter "this". +llvm::DIType CGDebugInfo::getOrCreateFunctionType(const Decl * D, QualType FnType, + llvm::DIFile F) { + if (const CXXMethodDecl *Method = dyn_cast(D)) + return getOrCreateMethodType(Method, F); + + return getOrCreateType(FnType, F); +} + /// EmitFunctionStart - Constructs the debug code for entering a function - /// "llvm.dbg.func.start.". void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, @@ -1685,11 +1695,10 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, unsigned LineNo = getLineNumber(CurLoc); if (D->isImplicit()) Flags |= llvm::DIDescriptor::FlagArtificial; - llvm::DIType SPTy = getOrCreateType(FnType, Unit); llvm::DISubprogram SPDecl = getFunctionDeclaration(D); llvm::DISubprogram SP = DBuilder.createFunction(FDContext, Name, LinkageName, Unit, - LineNo, SPTy, + LineNo, getOrCreateFunctionType(D, FnType, Unit), Fn->hasInternalLinkage(), true/*definition*/, Flags, CGM.getLangOptions().Optimize, Fn, TParamsArray, SPDecl); diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index 27d991bbee..6ec6b65f5e 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -98,6 +98,8 @@ class CGDebugInfo { llvm::DIType CreateEnumType(const EnumDecl *ED); llvm::DIType getOrCreateMethodType(const CXXMethodDecl *Method, llvm::DIFile F); + llvm::DIType getOrCreateFunctionType(const Decl *D, QualType FnType, + llvm::DIFile F); llvm::DIType getOrCreateVTablePtrType(llvm::DIFile F); llvm::DINameSpace getOrCreateNameSpace(const NamespaceDecl *N); llvm::DIType CreatePointeeType(QualType PointeeTy, llvm::DIFile F); diff --git a/test/CodeGenCXX/debug-info-pubtypes.cpp b/test/CodeGenCXX/debug-info-pubtypes.cpp new file mode 100644 index 0000000000..9029e6e62f --- /dev/null +++ b/test/CodeGenCXX/debug-info-pubtypes.cpp @@ -0,0 +1,14 @@ +// RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -S %s -o %t +// RUN: FileCheck %s < %t + +//CHECK: .asciz "G" +//CHECK-NEXT: .long 0 +//CHECK-NEXT: Lpubtypes_end1: + +class G { +public: + void foo(); +}; + +void G::foo() { +} -- 2.40.0