]> granicus.if.org Git - clang/commitdiff
Debug info: pass in the correct size for a pointer to a member function.
authorAdrian Prantl <aprantl@apple.com>
Wed, 7 Jan 2015 17:49:30 +0000 (17:49 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 7 Jan 2015 17:49:30 +0000 (17:49 +0000)
This corrects a bug I introduced in r224781.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225359 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info-ptr-to-member-function.cpp [new file with mode: 0644]

index 6a911c5e69c9338eb51692f8c0489d6f50f29b15..978e1bb5b81fc36d7bdea015e293d556e656e988 100644 (file)
@@ -1883,7 +1883,7 @@ llvm::DIType CGDebugInfo::CreateType(const MemberPointerType *Ty,
   if (!Ty->getPointeeType()->isFunctionType())
     return DBuilder.createMemberPointerType(
       getOrCreateType(Ty->getPointeeType(), U), ClassType,
-      CGM.PointerWidthInBits);
+      CGM.getContext().getTypeSize(Ty));
 
   const FunctionProtoType *FPT =
       Ty->getPointeeType()->getAs<FunctionProtoType>();
@@ -1891,7 +1891,7 @@ llvm::DIType CGDebugInfo::CreateType(const MemberPointerType *Ty,
       getOrCreateInstanceMethodType(CGM.getContext().getPointerType(QualType(
                                         Ty->getClass(), FPT->getTypeQuals())),
                                     FPT, U),
-      ClassType, CGM.PointerWidthInBits);
+      ClassType, CGM.getContext().getTypeSize(Ty));
 }
 
 llvm::DIType CGDebugInfo::CreateType(const AtomicType *Ty, llvm::DIFile U) {
diff --git a/test/CodeGenCXX/debug-info-ptr-to-member-function.cpp b/test/CodeGenCXX/debug-info-ptr-to-member-function.cpp
new file mode 100644 (file)
index 0000000..656e6f4
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin -g -emit-llvm -o - | FileCheck %s
+
+struct T {
+  int method();
+};
+
+void foo(int (T::*method)()) {}
+
+// A pointer to a member function is a pair of function- and this-pointer.
+// CHECK: [ DW_TAG_ptr_to_member_type ] {{.*}} size 128