forked from OSchip/llvm-project
[libc++] Improve the detection of whether the blocks runtime is available
The runtime for Blocks may not be available even though the Blocks language extension _is_ available. Instead of potentially failing, this commit is much more conservative and assumes the runtime for Blocks is only provided on Apple platforms. Differential Revision: https://reviews.llvm.org/D78757
This commit is contained in:
parent
53dd72a87a
commit
f76c42416c
|
@ -474,6 +474,10 @@ typedef __char32_t char32_t;
|
|||
# define _LIBCPP_HAS_EXTENSION_BLOCKS
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
|
||||
# define _LIBCPP_HAS_BLOCKS_RUNTIME
|
||||
#endif
|
||||
|
||||
#if !(__has_feature(cxx_relaxed_constexpr))
|
||||
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
|
||||
#endif
|
||||
|
|
|
@ -508,7 +508,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
|
|||
|
||||
#include <__functional_base>
|
||||
|
||||
#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && !defined(_LIBCPP_HAS_OBJC_ARC) && __has_include(<Block.h>)
|
||||
#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
|
||||
#include <Block.h>
|
||||
#endif
|
||||
|
||||
|
@ -2255,7 +2255,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
|
|||
#endif // _LIBCPP_NO_RTTI
|
||||
};
|
||||
|
||||
#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && !defined(_LIBCPP_HAS_OBJC_ARC) && __has_include(<Block.h>)
|
||||
#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC)
|
||||
|
||||
template<class _Rp1, class ..._ArgTypes1, class _Alloc, class _Rp, class ..._ArgTypes>
|
||||
class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)>
|
||||
|
|
|
@ -9,14 +9,15 @@
|
|||
// std::function support for the "blocks" extension
|
||||
|
||||
// UNSUPPORTED: c++98, c++03
|
||||
// REQUIRES: has-fblocks
|
||||
|
||||
// This test requires the Blocks runtime, which is (only?) available
|
||||
// on Darwin out-of-the-box.
|
||||
// REQUIRES: has-fblocks && darwin
|
||||
|
||||
// FILE_DEPENDENCIES: %t.exe
|
||||
// RUN: %{build} -fblocks
|
||||
// RUN: %{run}
|
||||
|
||||
#if __has_include(<Block.h>)
|
||||
|
||||
#include <functional>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
@ -143,9 +144,3 @@ int main(int, char**)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main() { }
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue