Skip to content

Commit 59ef85e

Browse files
author
git apple-llvm automerger
committed
Merge commit '7b1d4344c6fc' from apple/stable/20200714 into swift/master-rebranch
2 parents afd662f + 7b1d434 commit 59ef85e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

libcxx/include/functional

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,10 +508,6 @@ POLICY: For non-variadic implementations, the number of arguments is limited
508508

509509
#include <__functional_base>
510510

511-
#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
512-
#include <Block.h>
513-
#endif
514-
515511
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
516512
#pragma GCC system_header
517513
#endif
@@ -2257,6 +2253,9 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
22572253

22582254
#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
22592255

2256+
extern "C" void *_Block_copy(const void *);
2257+
extern "C" void _Block_release(const void *);
2258+
22602259
template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes>
22612260
class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
22622261
: public __base<_Rp(_ArgTypes...)>
@@ -2267,14 +2266,14 @@ class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
22672266
public:
22682267
_LIBCPP_INLINE_VISIBILITY
22692268
explicit __func(__block_type const& __f)
2270-
: __f_(__f ? Block_copy(__f) : (__block_type)0)
2269+
: __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
22712270
{ }
22722271

22732272
// [TODO] add && to save on a retain
22742273

22752274
_LIBCPP_INLINE_VISIBILITY
22762275
explicit __func(__block_type __f, const _Alloc& /* unused */)
2277-
: __f_(__f ? Block_copy(__f) : (__block_type)0)
2276+
: __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
22782277
{ }
22792278

22802279
virtual __base<_Rp(_ArgTypes...)>* __clone() const {
@@ -2291,7 +2290,7 @@ public:
22912290

22922291
virtual void destroy() _NOEXCEPT {
22932292
if (__f_)
2294-
Block_release(__f_);
2293+
_Block_release(__f_);
22952294
__f_ = 0;
22962295
}
22972296

libcxx/test/libcxx/utilities/function.objects/func.blocks.sh.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <cstdlib>
2222
#include <cassert>
2323

24+
#include <Block.h>
25+
2426
#include "test_macros.h"
2527
#include "count_new.h"
2628

0 commit comments

Comments
 (0)