From: Adrian Prantl Date: Wed, 5 Nov 2014 01:01:30 +0000 (+0000) Subject: Debug info: Emit the correct type for the __FuncPtr field in a block X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f65002072fe308f93a0ef04054b56218b00c2a34;p=clang Debug info: Emit the correct type for the __FuncPtr field in a block descriptor. rdar://problem/15984431 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221326 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 05df170305..ea8002ab96 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -714,7 +714,7 @@ llvm::DIType CGDebugInfo::CreateType(const BlockPointerType *Ty, FType = CGM.getContext().IntTy; EltTys.push_back(CreateMemberType(Unit, FType, "__flags", &FieldOffset)); EltTys.push_back(CreateMemberType(Unit, FType, "__reserved", &FieldOffset)); - FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); + FType = CGM.getContext().getPointerType(Ty->getPointeeType()); EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr", &FieldOffset)); FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); @@ -2953,7 +2953,9 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, fields.push_back(createFieldType("__reserved", C.IntTy, 0, loc, AS_public, blockLayout->getElementOffsetInBits(2), tunit, tunit)); - fields.push_back(createFieldType("__FuncPtr", C.VoidPtrTy, 0, loc, AS_public, + auto *FnTy = block.getBlockExpr()->getFunctionType(); + auto FnPtrType = CGM.getContext().getPointerType(FnTy->desugar()); + fields.push_back(createFieldType("__FuncPtr", FnPtrType, 0, loc, AS_public, blockLayout->getElementOffsetInBits(3), tunit, tunit)); fields.push_back(createFieldType( diff --git a/test/CodeGenObjC/debug-info-block-type.m b/test/CodeGenObjC/debug-info-block-type.m new file mode 100644 index 0000000000..e50163e626 --- /dev/null +++ b/test/CodeGenObjC/debug-info-block-type.m @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin14 -x objective-c < %s -o - | FileCheck %s +#define nil ((void*) 0) +typedef signed char BOOL; +// CHECK: ![[BOOL:[0-9]+]] = {{.*}} [ DW_TAG_typedef ] [BOOL] [line [[@LINE-1]] +// CHECK: ![[ID:[0-9]+]] = {{.*}} [ DW_TAG_typedef ] [id] + +typedef BOOL (^SomeKindOfPredicate)(id obj); +// CHECK: metadata ![[PTR:[0-9]+]]} ; [ DW_TAG_member ] [__FuncPtr] +// CHECK: ![[PTR]] = {{.*}}, metadata ![[FNTYPE:[0-9]+]]} ; [ DW_TAG_pointer_type ] +// CHECK: ![[FNTYPE]] = {{.*}} metadata ![[ARGS:[0-9]+]]{{.*}} ; [ DW_TAG_subroutine_type ] +// CHECK: ![[ARGS]] = metadata !{metadata ![[BOOL]], metadata ![[ID]]} + +int main() +{ + SomeKindOfPredicate p = ^BOOL(id obj) { return obj != nil; }; + // CHECK: metadata ![[PTR]]} ; [ DW_TAG_member ] [__FuncPtr] [line [[@LINE-1]], size 64, align 64, offset 128] + return p(nil); +}