> On Jan 7, 2015, at 10:01 AM, David Blaikie <[email protected]> wrote:
> 
> 
> 
> On Wed, Jan 7, 2015 at 9:49 AM, Adrian Prantl <[email protected] 
> <mailto:[email protected]>> wrote:
> Author: adrian
> Date: Wed Jan  7 11:49:30 2015
> New Revision: 225359
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=225359&view=rev 
> <http://llvm.org/viewvc/llvm-project?rev=225359&view=rev>
> Log:
> Debug info: pass in the correct size for a pointer to a member function.
> This corrects a bug I introduced in r224781.
> 
> Added:
>     cfe/trunk/test/CodeGenCXX/debug-info-ptr-to-member-function.cpp
> Modified:
>     cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=225359&r1=225358&r2=225359&view=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=225359&r1=225358&r2=225359&view=diff>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jan  7 11:49:30 2015
> @@ -1883,7 +1883,7 @@ llvm::DIType CGDebugInfo::CreateType(con
>    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(con
>        getOrCreateInstanceMethodType(CGM.getContext().getPointerType(QualType(
>                                          Ty->getClass(), 
> FPT->getTypeQuals())),
>                                      FPT, U),
> -      ClassType, CGM.PointerWidthInBits);
> +      ClassType, CGM.getContext().getTypeSize(Ty));
> 
> Why two separate code changes? Does the test exercise both?

The test only tests the member function pointer type. The other change (for 
data members) is NFC, but determining the size from the type is more elegant 
than hardcoding it to the target pointer size.

-- adrian

>  
>  }
> 
>  llvm::DIType CGDebugInfo::CreateType(const AtomicType *Ty, llvm::DIFile U) {
> 
> Added: cfe/trunk/test/CodeGenCXX/debug-info-ptr-to-member-function.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-ptr-to-member-function.cpp?rev=225359&view=auto
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-ptr-to-member-function.cpp?rev=225359&view=auto>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/debug-info-ptr-to-member-function.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-ptr-to-member-function.cpp Wed Jan  
> 7 11:49:30 2015
> @@ -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
> 
> 
> _______________________________________________
> cfe-commits mailing list
> [email protected] <mailto:[email protected]>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits 
> <http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits>
> 

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to