• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 -std=c++11 | FileCheck %s
2 
bar()3 void bar() {
4   // CHECK-DAG: @__FUNCTION__.___Z3barv_block_invoke = private unnamed_addr constant [17 x i8] c"bar_block_invoke\00", align 1
5   const char * (^block1)() = ^() {
6     return __FUNCTION__;
7   };
8   // CHECK-DAG: @__FUNCTION__.___Z3barv_block_invoke_2 = private unnamed_addr constant [19 x i8] c"bar_block_invoke_2\00", align 1
9   const char * (^block2)() = ^() {
10     return __FUNCTION__;
11   };
12 }
13 
baz()14 void baz() {
15   // CHECK-DAG: @__PRETTY_FUNCTION__.___Z3bazv_block_invoke = private unnamed_addr constant [24 x i8] c"void baz()_block_invoke\00", align 1
16   const char * (^block1)() = ^() {
17     return __PRETTY_FUNCTION__;
18   };
19   // CHECK-DAG: @__PRETTY_FUNCTION__.___Z3bazv_block_invoke_2 = private unnamed_addr constant [26 x i8] c"void baz()_block_invoke_2\00", align 1
20   const char * (^block2)() = ^() {
21     return __PRETTY_FUNCTION__;
22   };
23 }
24 
25 namespace foonamespace {
26 class Foo {
27 public:
Foo()28   Foo() {
29     // CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3FooC2Ev_block_invoke = private unnamed_addr constant [38 x i8] c"foonamespace::Foo::Foo()_block_invoke\00", align 1
30     const char * (^block1)() = ^() {
31       return __PRETTY_FUNCTION__;
32     };
33     // CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3FooC2Ev_block_invoke_2 = private unnamed_addr constant [40 x i8] c"foonamespace::Foo::Foo()_block_invoke_2\00", align 1
34     const char * (^block2)() = ^() {
35       return __PRETTY_FUNCTION__;
36     };
37     // CHECK-DAG: @__func__.___ZN12foonamespace3FooC2Ev_block_invoke_3 = private unnamed_addr constant [19 x i8] c"Foo_block_invoke_3\00", align 1
38     const char * (^block3)() = ^() {
39       return __func__;
40     };
41     bar();
42     inside_lambda();
43   }
~Foo()44   ~Foo() {
45     // CHECK-DAG: @__func__.___ZN12foonamespace3FooD2Ev_block_invoke = private unnamed_addr constant [18 x i8] c"~Foo_block_invoke\00", align 1
46     const char * (^block1)() = ^() {
47       return __func__;
48     };
49     // CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3FooD2Ev_block_invoke_2 = private unnamed_addr constant [41 x i8] c"foonamespace::Foo::~Foo()_block_invoke_2\00", align 1
50     const char * (^block2)() = ^() {
51       return __PRETTY_FUNCTION__;
52     };
53   }
bar()54   void bar() {
55     // CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3Foo3barEv_block_invoke = private unnamed_addr constant [43 x i8] c"void foonamespace::Foo::bar()_block_invoke\00", align 1
56     const char * (^block1)() = ^() {
57       return __PRETTY_FUNCTION__;
58     };
59     // CHECK-DAG: @__PRETTY_FUNCTION__.___ZN12foonamespace3Foo3barEv_block_invoke_2 = private unnamed_addr constant [45 x i8] c"void foonamespace::Foo::bar()_block_invoke_2\00", align 1
60     const char * (^block2)() = ^() {
61       return __PRETTY_FUNCTION__;
62     };
63     // CHECK-DAG: @__func__.___ZN12foonamespace3Foo3barEv_block_invoke_3 = private unnamed_addr constant [19 x i8] c"bar_block_invoke_3\00", align 1
64     const char * (^block3)() = ^() {
65       return __func__;
66     };
67   }
inside_lambda()68   void inside_lambda() {
69     auto lambda = []() {
70       // CHECK-DAG: @__PRETTY_FUNCTION__.___ZZN12foonamespace3Foo13inside_lambdaEvENKUlvE_clEv_block_invoke = private unnamed_addr constant [92 x i8] c"auto foonamespace::Foo::inside_lambda()::(anonymous class)::operator()() const_block_invoke\00", align 1
71       const char * (^block1)() = ^() {
72         return __PRETTY_FUNCTION__;
73       };
74       // CHECK-DAG: 	  @__PRETTY_FUNCTION__.___ZZN12foonamespace3Foo13inside_lambdaEvENKUlvE_clEv_block_invoke_2 = private unnamed_addr constant [94 x i8] c"auto foonamespace::Foo::inside_lambda()::(anonymous class)::operator()() const_block_invoke_2\00", align 1
75       const char * (^block2)() = ^() {
76         return __PRETTY_FUNCTION__;
77       };
78       // CHECK-DAG: @__func__.___ZZN12foonamespace3Foo13inside_lambdaEvENKUlvE_clEv_block_invoke_3 = private unnamed_addr constant [26 x i8] c"operator()_block_invoke_3\00", align 1
79       const char * (^block3)() = ^() {
80         return __func__;
81       };
82     };
83     lambda();
84   }
85 };
86 Foo f;
87 }
88