summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Anderson <thomasanderson@google.com>2019-01-29 23:19:45 +0000
committerThomas Anderson <thomasanderson@google.com>2019-01-29 23:19:45 +0000
commit7f50dfa6fce5a7cc4c74534ea37f6b153ba1d394 (patch)
tree481cd81022d7888d48519d65aa65e524ce7f9d9b
parentd8d193d5e2331da86a436ce39e7adedf4a700015 (diff)
downloadbcm5719-llvm-7f50dfa6fce5a7cc4c74534ea37f6b153ba1d394.tar.gz
bcm5719-llvm-7f50dfa6fce5a7cc4c74534ea37f6b153ba1d394.zip
[libc++] Fix Windows build error in <functional>
On my Windows system, __allocator is defined to nothing. This change fixes build errors of the below form: In file included from algorithm:644: functional(1492,31): error: expected member name or ';' after declaration specifiers const _Alloc& __allocator() const { return __f_.second(); } Differential Revision: https://reviews.llvm.org/D57355 llvm-svn: 352561
-rw-r--r--libcxx/include/functional11
-rw-r--r--libcxx/test/support/nasty_macros.hpp1
2 files changed, 7 insertions, 5 deletions
diff --git a/libcxx/include/functional b/libcxx/include/functional
index 086610e6190..def8a75f618 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -1488,8 +1488,9 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
_LIBCPP_INLINE_VISIBILITY
const _Target& __target() const { return __f_.first(); }
+ // WIN32 APIs may define __allocator, so use __get_allocator instead.
_LIBCPP_INLINE_VISIBILITY
- const _Alloc& __allocator() const { return __f_.second(); }
+ const _Alloc& __get_allocator() const { return __f_.second(); }
_LIBCPP_INLINE_VISIBILITY
explicit __alloc_func(_Target&& __f)
@@ -1611,7 +1612,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
{
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
- _Ap __a(__f_.__allocator());
+ _Ap __a(__f_.__get_allocator());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
::new ((void*)__hold.get()) __func(__f_.__target(), _Alloc(__a));
@@ -1622,7 +1623,7 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
{
- ::new (__p) __func(__f_.__target(), __f_.__allocator());
+ ::new (__p) __func(__f_.__target(), __f_.__get_allocator());
}
template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
@@ -1638,7 +1639,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
{
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
- _Ap __a(__f_.__allocator());
+ _Ap __a(__f_.__get_allocator());
__f_.destroy();
__a.deallocate(this, 1);
}
@@ -1924,7 +1925,7 @@ struct __policy
typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
_FunAlloc;
_Fun* __f = static_cast<_Fun*>(__s);
- _FunAlloc __a(__f->__allocator());
+ _FunAlloc __a(__f->__get_allocator());
__f->destroy();
__a.deallocate(__f, 1);
}
diff --git a/libcxx/test/support/nasty_macros.hpp b/libcxx/test/support/nasty_macros.hpp
index 7bc3f1e6a64..30d0ec003bb 100644
--- a/libcxx/test/support/nasty_macros.hpp
+++ b/libcxx/test/support/nasty_macros.hpp
@@ -54,6 +54,7 @@
// Test that libc++ doesn't use names reserved by WIN32 API Macros.
// NOTE: Obviously we can only define these on non-windows platforms.
#ifndef _WIN32
+#define __allocator NASTY_MACRO
#define __deallocate NASTY_MACRO
#define __out NASTY_MACRO
#endif
OpenPOWER on IntegriCloud