diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-22 18:59:50 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-22 18:59:50 +0000 |
commit | 540d2a8bf1f622cb7ee8d16e19fb113c15523794 (patch) | |
tree | 7e386f51b72ff5e4d07612d225ae99d3baa01639 /contrib/libc++/include/experimental | |
parent | 289fa303d6df65b9db955e478263677f8bc7e62a (diff) | |
parent | 1c3313bd0215c89fb38710a1ea0762ccf32e859c (diff) |
Merge libc++ trunk r300890, and update build glue.
Notes
Notes:
svn path=/projects/clang500-import/; revision=317287
Diffstat (limited to 'contrib/libc++/include/experimental')
-rw-r--r-- | contrib/libc++/include/experimental/filesystem | 52 | ||||
-rw-r--r-- | contrib/libc++/include/experimental/memory_resource | 12 | ||||
-rw-r--r-- | contrib/libc++/include/experimental/numeric | 31 |
3 files changed, 56 insertions, 39 deletions
diff --git a/contrib/libc++/include/experimental/filesystem b/contrib/libc++/include/experimental/filesystem index 739918bb2cbe..42157ba309bc 100644 --- a/contrib/libc++/include/experimental/filesystem +++ b/contrib/libc++/include/experimental/filesystem @@ -408,8 +408,10 @@ class _LIBCPP_TYPE_VIS file_status public: // constructors _LIBCPP_INLINE_VISIBILITY - explicit file_status(file_type __ft = file_type::none, - perms __prms = perms::unknown) _NOEXCEPT + file_status() _NOEXCEPT : file_status(file_type::none) {} + _LIBCPP_INLINE_VISIBILITY + explicit file_status(file_type __ft, + perms __prms = perms::unknown) _NOEXCEPT : __ft_(__ft), __prms_(__prms) {} @@ -720,6 +722,7 @@ public: return *this; } + template <class = void> _LIBCPP_INLINE_VISIBILITY path& operator=(string_type&& __s) _NOEXCEPT { __pn_ = _VSTD::move(__s); @@ -941,15 +944,15 @@ public: std::u32string generic_u32string() const { return string<char32_t>(); } private: - _LIBCPP_FUNC_VIS int __compare(__string_view) const; - _LIBCPP_FUNC_VIS __string_view __root_name() const; - _LIBCPP_FUNC_VIS __string_view __root_directory() const; - _LIBCPP_FUNC_VIS __string_view __root_path_raw() const; - _LIBCPP_FUNC_VIS __string_view __relative_path() const; - _LIBCPP_FUNC_VIS __string_view __parent_path() const; - _LIBCPP_FUNC_VIS __string_view __filename() const; - _LIBCPP_FUNC_VIS __string_view __stem() const; - _LIBCPP_FUNC_VIS __string_view __extension() const; + int __compare(__string_view) const; + __string_view __root_name() const; + __string_view __root_directory() const; + __string_view __root_path_raw() const; + __string_view __relative_path() const; + __string_view __parent_path() const; + __string_view __filename() const; + __string_view __stem() const; + __string_view __extension() const; public: // compare @@ -987,8 +990,8 @@ public: class _LIBCPP_TYPE_VIS iterator; typedef iterator const_iterator; - _LIBCPP_FUNC_VIS iterator begin() const; - _LIBCPP_FUNC_VIS iterator end() const; + iterator begin() const; + iterator end() const; private: inline _LIBCPP_INLINE_VISIBILITY @@ -1088,10 +1091,13 @@ class _LIBCPP_TYPE_VIS path::iterator { public: typedef bidirectional_iterator_tag iterator_category; + typedef path value_type; typedef std::ptrdiff_t difference_type; typedef const path* pointer; typedef const path& reference; + + typedef void __stashing_iterator_tag; // See reverse_iterator and __is_stashing_iterator public: _LIBCPP_INLINE_VISIBILITY iterator() : __stashed_elem_(), __path_ptr_(nullptr), @@ -1153,8 +1159,8 @@ private: inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const iterator&, const iterator&); - _LIBCPP_FUNC_VIS iterator& __increment(); - _LIBCPP_FUNC_VIS iterator& __decrement(); + iterator& __increment(); + iterator& __decrement(); path __stashed_elem_; const path* __path_ptr_; @@ -1205,7 +1211,6 @@ public: return __paths_->second; } - _LIBCPP_FUNC_VIS ~filesystem_error() override; // key function // TODO(ericwf): Create a custom error message. @@ -1923,7 +1928,7 @@ public: const directory_entry& operator*() const { _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced"); - return __deref(); + return __dereference(); } const directory_entry* operator->() const @@ -1948,11 +1953,14 @@ private: // construct the dir_stream _LIBCPP_FUNC_VIS - directory_iterator(const path&, error_code *, directory_options = directory_options::none); + directory_iterator(const path&, error_code *, + directory_options = directory_options::none); + _LIBCPP_FUNC_VIS directory_iterator& __increment(error_code * __ec = nullptr); + _LIBCPP_FUNC_VIS - const directory_entry& __deref() const; + const directory_entry& __dereference() const; private: shared_ptr<__dir_stream> __imp_; @@ -2035,11 +2043,11 @@ public: _LIBCPP_INLINE_VISIBILITY const directory_entry& operator*() const - { return __deref(); } + { return __dereference(); } _LIBCPP_INLINE_VISIBILITY const directory_entry* operator->() const - { return &__deref(); } + { return &__dereference(); } recursive_directory_iterator& operator++() { return __increment(); } @@ -2078,7 +2086,7 @@ private: error_code *__ec); _LIBCPP_FUNC_VIS - const directory_entry& __deref() const; + const directory_entry& __dereference() const; _LIBCPP_FUNC_VIS bool __try_recursion(error_code* __ec); diff --git a/contrib/libc++/include/experimental/memory_resource b/contrib/libc++/include/experimental/memory_resource index b3d9ca881989..743f9cbe639c 100644 --- a/contrib/libc++/include/experimental/memory_resource +++ b/contrib/libc++/include/experimental/memory_resource @@ -181,7 +181,7 @@ public: // 8.6.3, memory.polymorphic.allocator.mem _LIBCPP_INLINE_VISIBILITY _ValueType* allocate(size_t __n) { - if (__n > max_size()) { + if (__n > __max_size()) { __throw_length_error( "std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)" " 'n' exceeds maximum supported size"); @@ -193,7 +193,7 @@ public: _LIBCPP_INLINE_VISIBILITY void deallocate(_ValueType * __p, size_t __n) _NOEXCEPT { - _LIBCPP_ASSERT(__n <= max_size(), + _LIBCPP_ASSERT(__n <= __max_size(), "deallocate called for size which exceeds max_size()"); __res_->deallocate(__p, __n * sizeof(_ValueType), alignof(_ValueType)); } @@ -266,10 +266,6 @@ public: { __p->~_Tp(); } _LIBCPP_INLINE_VISIBILITY - size_t max_size() const _NOEXCEPT - { return numeric_limits<size_t>::max() / sizeof(value_type); } - - _LIBCPP_INLINE_VISIBILITY polymorphic_allocator select_on_container_copy_construction() const _NOEXCEPT { return polymorphic_allocator(); } @@ -309,6 +305,10 @@ private: return _Tup(_VSTD::get<_Idx>(_VSTD::move(__t))..., resource()); } + _LIBCPP_INLINE_VISIBILITY + size_t __max_size() const _NOEXCEPT + { return numeric_limits<size_t>::max() / sizeof(value_type); } + memory_resource * __res_; }; diff --git a/contrib/libc++/include/experimental/numeric b/contrib/libc++/include/experimental/numeric index 32b19a466358..d1209dbec15b 100644 --- a/contrib/libc++/include/experimental/numeric +++ b/contrib/libc++/include/experimental/numeric @@ -45,18 +45,23 @@ inline namespace fundamentals_v2 { _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 -template <typename _Tp, bool _IsSigned = is_signed<_Tp>::value> struct __abs; +template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __abs; -template <typename _Tp> -struct __abs<_Tp, true> { +template <typename _Result, typename _Source> +struct __abs<_Result, _Source, true> { _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY - _Tp operator()(_Tp __t) const noexcept { return __t >= 0 ? __t : -__t; } + _Result operator()(_Source __t) const noexcept + { + if (__t >= 0) return __t; + if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t); + return -__t; + } }; -template <typename _Tp> -struct __abs<_Tp, false> { +template <typename _Result, typename _Source> +struct __abs<_Result, _Source, false> { _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY - _Tp operator()(_Tp __t) const noexcept { return __t; } + _Result operator()(_Source __t) const noexcept { return __t; } }; @@ -75,10 +80,12 @@ common_type_t<_Tp,_Up> gcd(_Tp __m, _Up __n) { static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types"); + static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" ); + static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" ); using _Rp = common_type_t<_Tp,_Up>; using _Wp = make_unsigned_t<_Rp>; - return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Tp>()(__m)), - static_cast<_Wp>(__abs<_Up>()(__n)))); + return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)), + static_cast<_Wp>(__abs<_Rp, _Up>()(__n)))); } template<class _Tp, class _Up> @@ -87,12 +94,14 @@ common_type_t<_Tp,_Up> lcm(_Tp __m, _Up __n) { static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types"); + static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" ); + static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" ); if (__m == 0 || __n == 0) return 0; using _Rp = common_type_t<_Tp,_Up>; - _Rp __val1 = __abs<_Tp>()(__m) / gcd(__m,__n); - _Up __val2 = __abs<_Up>()(__n); + _Rp __val1 = __abs<_Rp, _Tp>()(__m) / gcd(__m, __n); + _Rp __val2 = __abs<_Rp, _Up>()(__n); _LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm"); return __val1 * __val2; } |