diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2019-12-11 22:51:18 -0800 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2019-12-13 13:10:07 -0800 |
commit | a0a670614a36f1686c5086033bef85800128cf66 (patch) | |
tree | 2cb48ba8b13971558a1c3aef8fba2e802f51943a /clang/test/CodeGenObjC | |
parent | 5623bd52acd34db2e9cfc11d1510407610a14db0 (diff) | |
download | bcm5719-llvm-a0a670614a36f1686c5086033bef85800128cf66.tar.gz bcm5719-llvm-a0a670614a36f1686c5086033bef85800128cf66.zip |
Call objc_retainBlock before passing a block as a variadic argument
Copy the block to the heap before passing it to the callee in case the
block escapes in the callee.
rdar://problem/55683462
Differential Revision: https://reviews.llvm.org/D71431
Diffstat (limited to 'clang/test/CodeGenObjC')
-rw-r--r-- | clang/test/CodeGenObjC/arc-blocks.m | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjC/arc-blocks.m b/clang/test/CodeGenObjC/arc-blocks.m index cabe552ba85..85c22a1b956 100644 --- a/clang/test/CodeGenObjC/arc-blocks.m +++ b/clang/test/CodeGenObjC/arc-blocks.m @@ -730,5 +730,15 @@ void test20(const id x) { test20_callee(^{ (void)x; }); } +// CHECK-LABEL: define void @test21( +// CHECK: %[[V6:.*]] = call i8* @llvm.objc.retainBlock( +// CHECK: %[[V7:.*]] = bitcast i8* %[[V6]] to void ()* +// CHECK: call void (i32, ...) @test21_callee(i32 1, void ()* %[[V7]]), + +void test21_callee(int n, ...); +void test21(id x) { + test21_callee(1, ^{ (void)x; }); +} + // CHECK: attributes [[NUW]] = { nounwind } // CHECK-UNOPT: attributes [[NUW]] = { nounwind } |