From: Adrian Prantl Date: Wed, 7 Jan 2015 17:49:30 +0000 (+0000) Subject: Debug info: pass in the correct size for a pointer to a member function. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad72e6e6443e5c47c27d13ff0af7434772d49056;p=clang Debug info: pass in the correct size for a pointer to a member function. 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 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 6a911c5e69..978e1bb5b8 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -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(); @@ -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 index 0000000000..656e6f4958 --- /dev/null +++ b/test/CodeGenCXX/debug-info-ptr-to-member-function.cpp @@ -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