1// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -emit-llvm -disable-llvm-passes -O3 -fblocks -fobjc-arc -fobjc-runtime-has-weak -std=c++11 -o - %s | FileCheck %s
2
3void test0(id x) {
4  extern void test0_helper(id (^)(void));
5  test0_helper([=]() { return x; });
6  // CHECK-LABEL: define internal i8* @___Z5test0P11objc_object_block_invoke
7  // CHECK: [[T0:%.*]] = call i8* @"_ZZ5test0P11objc_objectENK3$_0clEv"
8  // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
9  // CHECK-NEXT: [[T2:%.*]] = tail call i8* @objc_autoreleaseReturnValue(i8* [[T1]])
10  // CHECK-NEXT: ret i8* [[T2]]
11}
12
13id test1_rv;
14
15void test1() {
16  extern void test1_helper(id (*)(void));
17  test1_helper([](){ return test1_rv; });
18  // CHECK-LABEL: define internal i8* @"_ZZ5test1vEN3$_18__invokeEv"
19  // CHECK: [[T0:%.*]] = call i8* @"_ZZ5test1vENK3$_1clEv"
20  // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
21  // CHECK-NEXT: [[T2:%.*]] = tail call i8* @objc_autoreleaseReturnValue(i8* [[T1]])
22  // CHECK-NEXT: ret i8* [[T2]]
23}
24