1 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin10 -fobjc-arc -fblocks -std=c++1y -emit-pch %s -o %t
2 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin10 -fobjc-arc -fblocks -std=c++1y -include-pch %t -fobjc-avoid-heapify-local-blocks -emit-llvm -o - %s | FileCheck %s
4 #ifndef HEADER_INCLUDED
5 #define HEADER_INCLUDED
7 namespace test_block_retain {
8 typedef void (^BlockTy)();
11 inline void initialization(id a) {
12 // Call to @llvm.objc.retainBlock isn't needed.
13 BlockTy b0 = ^{ foo1(a); };
17 inline void assignmentConditional(id a, bool c) {
20 // @llvm.objc.retainBlock is called since 'b0' is declared in the outer scope.
28 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
30 namespace test_block_retain {
31 // CHECK-LABEL: define linkonce_odr void @_ZN17test_block_retain14initializationEP11objc_object(
32 // CHECK-NOT: call i8* @llvm.objc.retainBlock(
34 void test_initialization(id a) {
38 // CHECK-LABEL: define{{.*}} void @_ZN17test_block_retain26test_assignmentConditionalEP11objc_objectb(
39 // CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, align 8
40 // CHECK: %[[V4:.*]] = bitcast <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]] to void ()*
41 // CHECK: %[[V5:.*]] = bitcast void ()* %[[V4]] to i8*
42 // CHECK: call i8* @llvm.objc.retainBlock(i8* %[[V5]])
44 void test_assignmentConditional(id a, bool c) {
45 assignmentConditional(a, c);