brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 712158f Raw
56 lines · c
1// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s2// RUN: %clang_cc1 -DDEAD_CODE -fblocks -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s3 4typedef void (^BlockTy)(void);5void escapeFunc(BlockTy);6typedef void (^BlockTy)(void);7void noEscapeFunc(__attribute__((noescape)) BlockTy);8 9// Verify that the desired DIExpression are generated for escaping (i.e, not10// 'noescape') blocks.11void test_escape_func(void) {12// CHECK-LABEL: void @test_escape_func13// CHECK: #dbg_declare({{.*}}![[ESCAPE_VAR:[0-9]+]], !DIExpression(DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}){{.*}})14  __block int escape_var;15// Blocks in dead code branches still capture __block variables.16#ifdef DEAD_CODE17  if (0)18#endif19  escapeFunc(^{ (void)escape_var; });20}21 22// Verify that the desired DIExpression are generated for noescape blocks.23void test_noescape_func(void) {24// CHECK-LABEL: void @test_noescape_func25// CHECK: #dbg_declare({{.*}}![[NOESCAPE_VAR:[0-9]+]], !DIExpression(),26  __block int noescape_var;27  noEscapeFunc(^{ (void)noescape_var; });28}29 30// Verify that the desired DIExpression are generated for blocks.31void test_local_block(void) {32// CHECK-LABEL: void @test_local_block33// CHECK: #dbg_declare({{.*}}![[BLOCK_VAR:[0-9]+]], !DIExpression(DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}){{.*}})34  __block int block_var;35 36// CHECK-LABEL: @__test_local_block_block_invoke37// CHECK: #dbg_declare({{.*}}!DIExpression(DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}){{.*}})38  ^ { block_var = 1; }();39}40 41// Verify that the desired DIExpression are generated for __block vars not used42// in any block.43void test_unused(void) {44// CHECK-LABEL: void @test_unused45// CHECK: #dbg_declare({{.*}}![[UNUSED_VAR:[0-9]+]], !DIExpression(),46  __block int unused_var;47// Use i (not inside a block).48  ++unused_var;49}50 51// CHECK: ![[ESCAPE_VAR]] = !DILocalVariable(name: "escape_var"52// CHECK: ![[NOESCAPE_VAR]] = !DILocalVariable(name: "noescape_var"53// CHECK: ![[BLOCK_VAR]] = !DILocalVariable(name: "block_var"54// CHECK: ![[UNUSED_VAR]] = !DILocalVariable(name: "unused_var"55 56