Clang Project

clang_source_code/test/CodeGen/global-blocks-lines.c
1// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
2// Make sure we do not generate line info for debugging-related frame setup.
3// CHECK: define {{.*}}block_invoke
4// CHECK-NOT: store {{.*}}%struct.__block_descriptor*{{.*}}dbg
5// CHECK: store {{.*}}%struct.__block_descriptor*{{.*}}, align
6// CHECK: ret
7// CHECK: define {{.*}}block_invoke
8// CHECK-NOT: store {{.*}}%struct.__block_descriptor*{{.*}}dbg
9// CHECK: store {{.*}}%struct.__block_descriptor*{{.*}}, align
10// CHECK: ret
11// CHECK: define {{.*}}block_invoke
12// CHECK-NOT: store {{.*}}%struct.__block_descriptor*{{.*}}dbg
13// CHECK: store {{.*}}%struct.__block_descriptor*{{.*}}, align
14// CHECK: ret
15int printf(const char*, ...);
16
17static void* _NSConcreteGlobalBlock;
18
19
20typedef void (^ HelloBlock_t)(const char * name);
21
22  /* Breakpoint for first Block function.  */
23HelloBlock_t helloBlock = ^(const char * name) {
24  printf("Hello there, %s!\n", name);
25};
26
27  /* Breakpoint for second Block function.  */
28static HelloBlock_t s_helloBlock = ^(const char * name) {
29  printf("Hello there, %s!\n", name);
30};
31
32/* Breakpoint for third Block function.  */
33int X = 1234;
34int (^CP)(void) = ^{ X = X+1;  return X; };
35
36int
37main(int argc, char * argv[])
38{
39  helloBlock("world");
40  s_helloBlock("world");
41
42  CP();
43  printf ("X = %d\n", X);
44  return X - 1235;
45}
46