1// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s 2 3// CHECK: @_ZGVN3foo22___Z3foov_block_invoke5valueE = internal global i64 0 4 5int f(); 6 7void foo() { 8 // CHECK: define internal i32 @___Z3foov_block_invoke 9 // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo22___Z3foov_block_invoke5valueE 10 (void)^(int x) { 11 static int value = f(); 12 return x + value; 13 }; 14} 15 16// CHECK: define internal i32 @i_block_invoke 17int i = ^(int x) { return x;}(i); 18 19@interface A 20- (void)method; 21@end 22 23@implementation A 24- (void)method { 25 // CHECK: define internal signext i8 @"__11-[A method]_block_invoke" 26 (void)^(int x) { 27 // CHECK: @"_ZN11-[A method]28__11-[A method]_block_invoke4nameE" 28 static const char *name = "hello"; 29 return name[x]; 30 }; 31} 32@end 33 34void foo(int) { 35 (void)^(int x) { 36 static const char *name = "hello"; 37 return name[x]; 38 }; 39} 40 41namespace N { 42 // CHECK: define internal signext i8 @___Z3fooi_block_invoke 43 void bar() { 44 (void)^(int x) { 45 // CHECK: @_ZN1N3bar26___ZN1N3barEv_block_invoke4nameE 46 static const char *name = "hello"; 47 return name[x]; 48 }; 49 } 50} 51