1// RUN: %clang_cc1 -emit-llvm -fblocks -debug-info-kind=limited -triple x86_64-apple-darwin10 -fobjc-dispatch-method=mixed -x objective-c < %s -o - | FileCheck %s 2 3// Test that we generate the proper debug location for a captured self. 4// The second half of this test is in llvm/tests/DebugInfo/debug-info-blocks.ll 5 6// CHECK: define {{.*}}_block_invoke 7// CHECK: store ptr %.block_descriptor, ptr %[[ALLOCA:block.addr]], align 8// CHECK-NEXT: #dbg_declare(ptr %d, ![[D:[0-9]+]], !{{.*}}) 9// CHECK-NEXT: #dbg_declare(ptr %[[ALLOCA]], ![[SELF:[0-9]+]], !{{.*}}) 10 11// Test that we do emit scope info for the helper functions, and that the 12// parameters to these functions are marked as artificial (so the debugger 13// doesn't accidentally step into the function). 14// CHECK: define {{.*}} @__copy_helper_block_{{.*}}(ptr noundef %0, ptr noundef %1) 15// CHECK-NOT: ret 16// CHECK: #dbg_declare({{.+}}, ![[DBG_LINE:[0-9]+]] 17// CHECK-NOT: ret 18// CHECK: load {{.*}}, !dbg ![[DBG_LINE]] 19// CHECK: ret {{.*}}, !dbg ![[DBG_LINE]] 20// CHECK: define {{.*}} @__destroy_helper_block_{{.*}}(ptr 21// CHECK-NOT: ret 22// CHECK: load {{.*}}, !dbg ![[DESTROY_LINE:[0-9]+]] 23// CHECK: ret {{.*}}, !dbg ![[DESTROY_LINE]] 24 25// CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]]) 26// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(linkageName: "__copy_helper_block_ 27// CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]]) 28// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(linkageName: "__destroy_helper_block_ 29typedef unsigned int NSUInteger; 30 31@protocol NSObject 32@end 33 34@interface NSObject <NSObject> 35- (id)init; 36+ (id)alloc; 37@end 38 39@interface NSDictionary : NSObject 40- (NSUInteger)count; 41@end 42 43@interface NSMutableDictionary : NSDictionary 44@end 45 46@interface A : NSObject { 47@public 48 int ivar; 49} 50@end 51 52static void run(void (^block)(void)) 53{ 54 block(); 55} 56 57@implementation A 58 59- (id)init 60{ 61 if ((self = [super init])) { 62 // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[COPY_SP]], {{.*}}, flags: DIFlagArtificial) 63 // CHECK-DAG: !DILocalVariable(arg: 2, scope: ![[COPY_SP]], {{.*}}, flags: DIFlagArtificial) 64 // CHECK-DAG: !DILocalVariable(arg: 1, scope: ![[DESTROY_SP]], {{.*}}, flags: DIFlagArtificial) 65 run(^{ 66 // CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", scope:{{.*}}, line: [[@LINE+4]], 67 // CHECK-DAG: ![[D]] = !DILocalVariable(name: "d", scope:{{.*}}, line: [[@LINE+1]], 68 NSMutableDictionary *d = [[NSMutableDictionary alloc] init]; 69 ivar = 42 + (int)[d count]; 70 }); 71 } 72 return self; 73} 74 75@end 76 77int main(void) 78{ 79 A *a = [[A alloc] init]; 80 return 0; 81} 82