r221326 - Debug info: Emit the correct type for the __FuncPtr field in a block
Adrian Prantl
aprantl at apple.com
Tue Nov 4 17:01:31 PST 2014
Author: adrian
Date: Tue Nov 4 19:01:30 2014
New Revision: 221326
URL: http://llvm.org/viewvc/llvm-project?rev=221326&view=rev
Log:
Debug info: Emit the correct type for the __FuncPtr field in a block
descriptor.
rdar://problem/15984431
Added:
cfe/trunk/test/CodeGenObjC/debug-info-block-type.m
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=221326&r1=221325&r2=221326&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Nov 4 19:01:30 2014
@@ -714,7 +714,7 @@ llvm::DIType CGDebugInfo::CreateType(con
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::EmitDeclareOfBlockLite
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(
Added: cfe/trunk/test/CodeGenObjC/debug-info-block-type.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-block-type.m?rev=221326&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info-block-type.m (added)
+++ cfe/trunk/test/CodeGenObjC/debug-info-block-type.m Tue Nov 4 19:01:30 2014
@@ -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);
+}
More information about the cfe-commits
mailing list