]> granicus.if.org Git - clang/commitdiff
List c++ class type as public type in dwarf debug info output.
authorDevang Patel <dpatel@apple.com>
Tue, 31 May 2011 20:46:46 +0000 (20:46 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 31 May 2011 20:46:46 +0000 (20:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132357 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h
test/CodeGenCXX/debug-info-pubtypes.cpp [new file with mode: 0644]

index 6c73865c3ca3e434ab81922102db6a5052fb148e..d1b4aad7fa8960e2aae2d8515d5d15e32816739f 100644 (file)
@@ -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<CXXMethodDecl>(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);
index 27d991bbee420acb24c3ed0f3d212e81661a4d58..6ec6b65f5e01c63e12a1ba4644fdfbbeb10e20d0 100644 (file)
@@ -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 (file)
index 0000000..9029e6e
--- /dev/null
@@ -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() {
+}