110 lines · plain
1; RUN: llc -mtriple x86_64-apple-darwin -filetype=obj -o %t.o < %s2; RUN: llvm-dwarfdump %t.o | FileCheck %s3;4; Test that DW_AT_location is generated for a captured "self" inside a5; block.6;7; This test is split into two parts, the frontend part can be found at8; llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m9;10; CHECK: {{.*}}DW_AT_name{{.*}}_block_invoke{{.*}}11; CHECK: DW_TAG_variable12; CHECK-NOT: DW_TAG13; CHECK: DW_AT_location14; CHECK-NOT: DW_TAG15; CHECK: DW_AT_name{{.*}}"self"{{.*}}16;17; CHECK: {{.*}}DW_AT_name{{.*}}_block_invoke{{.*}}18; CHECK: DW_TAG_variable19; CHECK-NOT: DW_TAG20; CHECK: DW_AT_location21; CHECK-NOT: DW_TAG22; CHECK: DW_AT_name{{.*}}"self"{{.*}}23;24; Generated (and then reduced) from25; ----------------------------------------------------------------------26;27; @class T;28; @interface S29; @end30; @interface Mode31; -(int) count;32; @end33; @interface Context34; @end35; @interface ViewController36; @property (nonatomic, readwrite, strong) Context *context;37; @end38; typedef enum {39; Unknown = 0,40; } State;41; @interface Main : ViewController42; {43; T * t1;44; T * t2;45; }46; @property(readwrite, nonatomic) State state;47; @end48; @implementation Main49; - (id) initWithContext:(Context *) context50; {51; t1 = [self.context withBlock:^(id obj){52; id *mode1;53; t2 = [mode1 withBlock:^(id object){54; Mode *mode2 = object;55; if ([mode2 count] != 0) {56; self.state = 0;57; }58; }];59; }];60; }61; @end62; ----------------------------------------------------------------------63; ModuleID = 'llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m'64%0 = type opaque65%struct.__block_descriptor = type { i64, i64 }66declare void @llvm.dbg.declare(metadata, metadata, metadata) #167define internal void @"__24-[Main initWithContext:]_block_invoke"(ptr %.block_descriptor, ptr %obj) #0 !dbg !38 {68 %block.captured-self = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, ptr }>, ptr %.block_descriptor, i32 0, i32 5, !dbg !8469 call void @llvm.dbg.declare(metadata ptr %.block_descriptor, metadata !86, metadata !110), !dbg !8770 ret void, !dbg !8771}72 73define internal void @"__24-[Main initWithContext:]_block_invoke_2"(ptr %.block_descriptor, ptr %object) #0 !dbg !42 {74 %block.captured-self = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, ptr }>, ptr %.block_descriptor, i32 0, i32 5, !dbg !10375 call void @llvm.dbg.declare(metadata ptr %.block_descriptor, metadata !105, metadata !109), !dbg !10676 ret void, !dbg !10677}78 79!llvm.dbg.cu = !{!0}80!llvm.module.flags = !{!108}81!0 = distinct !DICompileUnit(language: DW_LANG_ObjC, producer: "clang version 3.3 ", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, file: !107, enums: !2, retainedTypes: !4, globals: !15, imports: !15)82!1 = !DIFile(filename: "llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m", directory: "")83!2 = !{!3}84!3 = !DICompositeType(tag: DW_TAG_enumeration_type, line: 20, size: 32, align: 32, file: !107, elements: !4)85!4 = !{}86!15 = !{}87!27 = !DIDerivedType(tag: DW_TAG_typedef, name: "id", line: 31, file: !107, baseType: !28)88!28 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !29)89!29 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_object", file: !107, elements: !30)90!30 = !{!31}91!31 = !DIDerivedType(tag: DW_TAG_member, name: "isa", size: 64, file: !107, scope: !29, baseType: !32)92!32 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !33)93!33 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_class", flags: DIFlagFwdDecl, file: !107)94!34 = !DICompositeType(tag: DW_TAG_structure_type, name: "Main", line: 23, flags: DIFlagArtificial | DIFlagObjectPointer, runtimeLang: DW_LANG_ObjC, file: !107)95!38 = distinct !DISubprogram(name: "__24-[Main initWithContext:]_block_invoke", line: 33, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 33, file: !1, scope: !1, type: !39, retainedNodes: !15)96!39 = !DISubroutineType(types: !40)97!40 = !{null, !41, !27}98!41 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: null)99!42 = distinct !DISubprogram(name: "__24-[Main initWithContext:]_block_invoke_2", line: 35, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 35, file: !1, scope: !1, type: !39, retainedNodes: !15)100!84 = !DILocation(line: 33, scope: !38)101!86 = !DILocalVariable(name: "self", line: 41, scope: !38, file: !1, type: !34)102!87 = !DILocation(line: 41, scope: !38)103!103 = !DILocation(line: 35, scope: !42)104!105 = !DILocalVariable(name: "self", line: 40, scope: !42, file: !1, type: !34)105!106 = !DILocation(line: 40, scope: !42)106!107 = !DIFile(filename: "llvm/tools/clang/test/CodeGenObjC/debug-info-block-captured-self.m", directory: "")107!108 = !{i32 1, !"Debug Info Version", i32 3}108!109 = !DIExpression(DW_OP_plus_uconst, 32, DW_OP_deref)109!110 = !DIExpression(DW_OP_plus_uconst, 32, DW_OP_deref)110