[cfe-commits] r172911 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGenCXX/debug-info-method.cpp

David Blaikie dblaikie at gmail.com
Sat Jan 19 11:20:57 PST 2013


Author: dblaikie
Date: Sat Jan 19 13:20:56 2013
New Revision: 172911

URL: http://llvm.org/viewvc/llvm-project?rev=172911&view=rev
Log:
Emit the function type of member function pointer types the same as member functions.

Adding the pseudo first parameter to a member function pointer's function type
and mark it as artificial.

Combined with a fix to GDB ( http://sourceware.org/bugzilla/show_bug.cgi?id=14998 )
this fixes gdb.cp/member-ptr.exp with Clang.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-method.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=172911&r1=172910&r2=172911&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sat Jan 19 13:20:56 2013
@@ -1623,8 +1623,15 @@
 
 llvm::DIType CGDebugInfo::CreateType(const MemberPointerType *Ty, 
                                      llvm::DIFile U) {
-  return DBuilder.createMemberPointerType(CreatePointeeType(Ty->getPointeeType(), U),
-                                    getOrCreateType(QualType(Ty->getClass(), 0), U));
+  llvm::DIType ClassType = getOrCreateType(QualType(Ty->getClass(), 0), U);
+  if (!Ty->getPointeeType()->isFunctionType())
+    return DBuilder.createMemberPointerType(
+        CreatePointeeType(Ty->getPointeeType(), U), ClassType);
+  return DBuilder.createMemberPointerType(getOrCreateInstanceMethodType(
+      CGM.getContext().getPointerType(
+          QualType(Ty->getClass(), Ty->getPointeeType().getCVRQualifiers())),
+      Ty->getPointeeType()->getAs<FunctionProtoType>(), U),
+                                          ClassType);
 }
 
 llvm::DIType CGDebugInfo::CreateType(const AtomicType *Ty, 

Modified: cfe/trunk/test/CodeGenCXX/debug-info-method.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-method.cpp?rev=172911&r1=172910&r2=172911&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-method.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-method.cpp Sat Jan 19 13:20:56 2013
@@ -1,7 +1,10 @@
 // RUN: %clang_cc1 -emit-llvm -std=c++11 -g %s -o - | FileCheck %s
+// CHECK: ![[THISTYPE:[0-9]+]] = {{.*}} ; [ DW_TAG_pointer_type ] {{.*}} [artificial] [from A]
 // CHECK: metadata !"_ZN1A3fooEiS_3$_0", {{.*}} [protected]
 // CHECK: DW_TAG_ptr_to_member_type
-// CHECK: DW_TAG_ptr_to_member_type
+// CHECK: {{.*}}metadata ![[MEMFUNTYPE:[0-9]+]], metadata !{{.*}}} ; [ DW_TAG_ptr_to_member_type ] {{.*}} [from ]
+// CHECK: ![[MEMFUNTYPE]] = {{.*}}metadata ![[MEMFUNARGS:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_subroutine_type ] {{.*}} [from ]
+// CHECK: ![[MEMFUNARGS]] = {{.*}}, metadata ![[THISTYPE]],
 // CHECK: ""{{.*}}DW_TAG_arg_variable
 // CHECK: ""{{.*}}DW_TAG_arg_variable
 // CHECK: ""{{.*}}DW_TAG_arg_variable





More information about the cfe-commits mailing list