diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
commit | b35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch) | |
tree | cdff4a5d1a715d4ad622fd8f190128b54bebe440 /test/PCH/arc-blocks.mm | |
parent | 3748d41833787fcbf59cc5624e8d2b042a8991bc (diff) | |
parent | 741e05796da92b46d4f7bcbee00702ff37df6489 (diff) |
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103upstream/google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH/arc-blocks.mm')
-rw-r--r-- | test/PCH/arc-blocks.mm | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/PCH/arc-blocks.mm b/test/PCH/arc-blocks.mm new file mode 100644 index 0000000000..2e17a570f8 --- /dev/null +++ b/test/PCH/arc-blocks.mm @@ -0,0 +1,49 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -fblocks -std=c++1y -emit-pch %s -o %t +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -fblocks -std=c++1y -include-pch %t -emit-llvm -o - %s | FileCheck %s + +#ifndef HEADER_INCLUDED +#define HEADER_INCLUDED + +namespace test_block_retain { + typedef void (^BlockTy)(); + void foo1(id); + + inline void initialization(id a) { + // Call to @llvm.objc.retainBlock isn't needed. + BlockTy b0 = ^{ foo1(a); }; + b0(); + } + + inline void assignmentConditional(id a, bool c) { + BlockTy b0; + if (c) + // @llvm.objc.retainBlock is called since 'b0' is declared in the outer scope. + b0 = ^{ foo1(a); }; + b0(); + } +} + +#else + +// CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 } + +namespace test_block_retain { +// CHECK-LABEL: define linkonce_odr void @_ZN17test_block_retain14initializationEP11objc_object( +// CHECK-NOT: call i8* @llvm.objc.retainBlock( + + void test_initialization(id a) { + initialization(a); + } + +// CHECK-LABEL: define void @_ZN17test_block_retain26test_assignmentConditionalEP11objc_objectb( +// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>, align 8 +// CHECK: %[[V4:.*]] = bitcast <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8* }>* %[[BLOCK]] to void ()* +// CHECK: %[[V5:.*]] = bitcast void ()* %[[V4]] to i8* +// CHECK: call i8* @llvm.objc.retainBlock(i8* %[[V5]]) + + void test_assignmentConditional(id a, bool c) { + assignmentConditional(a, c); + } +} + +#endif |