rsmith updated this revision to Diff 222944.
rsmith added a comment.

Undo adding too many files to this change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68364/new/

https://reviews.llvm.org/D68364

Files:
  libcxx/include/__config
  libcxx/include/memory
  libcxx/include/new
  libcxx/include/version

Index: libcxx/include/version
===================================================================
--- libcxx/include/version
+++ libcxx/include/version
@@ -218,6 +218,9 @@
 #   define __cpp_lib_char8_t                            201811L
 # endif
 // # define __cpp_lib_concepts                             201806L
+# if !defined(_LIBCPP_HAS_NO_CONSTEXPR_DYNAMIC_ALLOC)
+#  define __cpp_lib_constexpr_dynamic_alloc                201907L
+# endif
 // # define __cpp_lib_constexpr_misc                       201811L
 // # define __cpp_lib_constexpr_swap_algorithms            201806L
 # if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
Index: libcxx/include/new
===================================================================
--- libcxx/include/new
+++ libcxx/include/new
@@ -234,7 +234,8 @@
 #endif
 }
 
-inline _LIBCPP_INLINE_VISIBILITY void *__libcpp_allocate(size_t __size, size_t __align) {
+_LIBCPP_CONSTEXPR_DYNAMIC_ALLOC inline _LIBCPP_INLINE_VISIBILITY
+void *__libcpp_allocate(size_t __size, size_t __align) {
 #ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
   if (__is_overaligned_for_new(__align)) {
     const align_val_t __align_val = static_cast<align_val_t>(__align);
@@ -255,7 +256,7 @@
 }
 
 struct _DeallocateCaller {
-  static inline _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC static inline _LIBCPP_INLINE_VISIBILITY
   void __do_deallocate_handle_size_align(void *__ptr, size_t __size, size_t __align) {
 #if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
     ((void)__align);
@@ -270,7 +271,7 @@
 #endif
   }
 
-  static inline _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC static inline _LIBCPP_INLINE_VISIBILITY
   void __do_deallocate_handle_align(void *__ptr, size_t __align) {
 #if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
     ((void)__align);
@@ -286,7 +287,7 @@
   }
 
  private:
-  static inline void __do_deallocate_handle_size(void *__ptr, size_t __size) {
+  _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC static inline void __do_deallocate_handle_size(void *__ptr, size_t __size) {
 #ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
     ((void)__size);
     return __do_call(__ptr);
@@ -296,7 +297,7 @@
   }
 
 #ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
-  static inline void __do_deallocate_handle_size(void *__ptr, size_t __size, align_val_t __align) {
+  _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC static inline void __do_deallocate_handle_size(void *__ptr, size_t __size, align_val_t __align) {
 #ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
     ((void)__size);
     return __do_call(__ptr, __align);
@@ -308,7 +309,7 @@
 
 private:
   template <class _A1, class _A2>
-  static inline void __do_call(void *__ptr, _A1 __a1, _A2 __a2) {
+  _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC static inline void __do_call(void *__ptr, _A1 __a1, _A2 __a2) {
 #if defined(_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE) || \
     defined(_LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE)
     return ::operator delete(__ptr, __a1, __a2);
@@ -318,7 +319,7 @@
   }
 
   template <class _A1>
-  static inline void __do_call(void *__ptr, _A1 __a1) {
+  _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC static inline void __do_call(void *__ptr, _A1 __a1) {
 #if defined(_LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE) || \
     defined(_LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE)
     return ::operator delete(__ptr, __a1);
@@ -327,7 +328,7 @@
 #endif
   }
 
-  static inline void __do_call(void *__ptr) {
+  _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC static inline void __do_call(void *__ptr) {
 #ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE
     return ::operator delete(__ptr);
 #else
@@ -336,11 +337,13 @@
   }
 };
 
-inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
+_LIBCPP_CONSTEXPR_DYNAMIC_ALLOC inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
   _DeallocateCaller::__do_deallocate_handle_size_align(__ptr, __size, __align);
 }
 
-inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
+_LIBCPP_CONSTEXPR_DYNAMIC_ALLOC inline _LIBCPP_INLINE_VISIBILITY
+void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
   _DeallocateCaller::__do_deallocate_handle_align(__ptr, __align);
 }
 
Index: libcxx/include/memory
===================================================================
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -1565,47 +1565,47 @@
         {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;};
 #endif  // _LIBCPP_CXX03_LANG
 
-    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static pointer allocate(allocator_type& __a, size_type __n)
         {return __a.allocate(__n);}
-    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
         {return __allocate(__a, __n, __hint,
             __has_allocate_hint<allocator_type, size_type, const_void_pointer>());}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static void deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT
         {__a.deallocate(__p, __n);}
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS
     template <class _Tp, class... _Args>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args)
             {__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
                          __a, __p, _VSTD::forward<_Args>(__args)...);}
 #else  // _LIBCPP_HAS_NO_VARIADICS
     template <class _Tp>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void construct(allocator_type&, _Tp* __p)
             {
                 ::new ((void*)__p) _Tp();
             }
     template <class _Tp, class _A0>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0)
             {
                 __construct(__has_construct<allocator_type, _Tp*, const _A0&>(),
                             __a, __p, __a0);
             }
     template <class _Tp, class _A0, class _A1>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void construct(allocator_type&, _Tp* __p, const _A0& __a0,
                               const _A1& __a1)
             {
                 ::new ((void*)__p) _Tp(__a0, __a1);
             }
     template <class _Tp, class _A0, class _A1, class _A2>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void construct(allocator_type&, _Tp* __p, const _A0& __a0,
                               const _A1& __a1, const _A2& __a2)
             {
@@ -1614,15 +1614,15 @@
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
     template <class _Tp>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void destroy(allocator_type& __a, _Tp* __p)
             {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static size_type max_size(const allocator_type& __a) _NOEXCEPT
         {return __max_size(__has_max_size<const allocator_type>(), __a);}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static allocator_type
         select_on_container_copy_construction(const allocator_type& __a)
             {return __select_on_container_copy_construction(
@@ -1630,7 +1630,7 @@
                 __a);}
 
     template <class _Ptr>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static
         void
         __construct_forward_with_exception_guarantees(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2)
@@ -1648,7 +1648,7 @@
         }
 
     template <class _Tp>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static
         typename enable_if
         <
@@ -1657,18 +1657,32 @@
              is_trivially_move_constructible<_Tp>::value,
             void
         >::type
-        __construct_forward_with_exception_guarantees(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
+        __construct_forward_with_exception_guarantees(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
         {
             ptrdiff_t _Np = __end1 - __begin1;
             if (_Np > 0)
             {
-                _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
-                __begin2 += _Np;
+#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
+                if (__builtin_is_constant_evaluated())
+                    for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
+                      construct(__a, _VSTD::__to_raw_pointer(__begin2),
+#ifdef _LIBCPP_NO_EXCEPTIONS
+                                _VSTD::move(*__begin1)
+#else
+                                _VSTD::move_if_noexcept(*__begin1)
+#endif
+                                );
+                else
+#endif
+                {
+                    _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
+                    __begin2 += _Np;
+                }
             }
         }
 
     template <class _Iter, class _Ptr>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static
         void
         __construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2)
@@ -1680,7 +1694,7 @@
     template <class _SourceTp, class _DestTp,
               class _RawSourceTp = typename remove_const<_SourceTp>::type,
               class _RawDestTp = typename remove_const<_DestTp>::type>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static
         typename enable_if
         <
@@ -1690,18 +1704,26 @@
              !__has_construct<allocator_type, _DestTp*, _SourceTp&>::value),
             void
         >::type
-        __construct_range_forward(allocator_type&, _SourceTp* __begin1, _SourceTp* __end1, _DestTp*& __begin2)
+        __construct_range_forward(allocator_type& __a, _SourceTp* __begin1, _SourceTp* __end1, _DestTp*& __begin2)
         {
             ptrdiff_t _Np = __end1 - __begin1;
             if (_Np > 0)
             {
-                _VSTD::memcpy(const_cast<_RawDestTp*>(__begin2), __begin1, _Np * sizeof(_DestTp));
-                __begin2 += _Np;
+#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
+                if (__builtin_is_constant_evaluated())
+                    for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
+                        construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1);
+                else
+#endif
+                {
+                    _VSTD::memcpy(const_cast<_RawDestTp*>(__begin2), __begin1, _Np * sizeof(_DestTp));
+                    __begin2 += _Np;
+                }
             }
         }
 
     template <class _Ptr>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static
         void
         __construct_backward_with_exception_guarantees(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2)
@@ -1722,7 +1744,7 @@
         }
 
     template <class _Tp>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static
         typename enable_if
         <
@@ -1731,44 +1753,65 @@
              is_trivially_move_constructible<_Tp>::value,
             void
         >::type
-        __construct_backward_with_exception_guarantees(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
+        __construct_backward_with_exception_guarantees(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __end2)
         {
             ptrdiff_t _Np = __end1 - __begin1;
-            __end2 -= _Np;
             if (_Np > 0)
-                _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
+            {
+#ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
+                if (__builtin_is_constant_evaluated())
+                {
+                    while (__end1 != __begin1)
+                    {
+                        construct(__a, _VSTD::__to_raw_pointer(__end2 - 1),
+#ifdef _LIBCPP_NO_EXCEPTIONS
+                                  _VSTD::move(*--__end1)
+#else
+                                  _VSTD::move_if_noexcept(*--__end1)
+#endif
+                                  );
+                        --__end2;
+                    }
+                }
+                else
+#endif
+                {
+                    __end2 -= _Np;
+                    _VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
+                }
+            }
         }
 
 private:
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static pointer __allocate(allocator_type& __a, size_type __n,
         const_void_pointer __hint, true_type)
         {return __a.allocate(__n, __hint);}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static pointer __allocate(allocator_type& __a, size_type __n,
         const_void_pointer, false_type)
         {return __a.allocate(__n);}
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS
     template <class _Tp, class... _Args>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void __construct(true_type, allocator_type& __a, _Tp* __p, _Args&&... __args)
             {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
     template <class _Tp, class... _Args>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void __construct(false_type, allocator_type&, _Tp* __p, _Args&&... __args)
             {
                 ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
             }
 #else  // _LIBCPP_HAS_NO_VARIADICS
     template <class _Tp, class _A0>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void __construct(true_type, allocator_type& __a, _Tp* __p,
                                 const _A0& __a0)
             {__a.construct(__p, __a0);}
     template <class _Tp, class _A0>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void __construct(false_type, allocator_type&, _Tp* __p,
                                 const _A0& __a0)
             {
@@ -1777,28 +1820,28 @@
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
     template <class _Tp>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void __destroy(true_type, allocator_type& __a, _Tp* __p)
             {__a.destroy(__p);}
     template <class _Tp>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         static void __destroy(false_type, allocator_type&, _Tp* __p)
             {
                 __p->~_Tp();
             }
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT
             {return __a.max_size();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT
             {return numeric_limits<size_type>::max() / sizeof(value_type);}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static allocator_type
         __select_on_container_copy_construction(true_type, const allocator_type& __a)
             {return __a.select_on_container_copy_construction();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     static allocator_type
         __select_on_container_copy_construction(false_type, const allocator_type& __a)
             {return __a;}
@@ -1844,7 +1887,7 @@
         {return _VSTD::addressof(__x);}
     _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
         {return _VSTD::addressof(__x);}
-    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
     pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
         {
         if (__n > max_size())
@@ -1852,13 +1895,14 @@
                                  " 'n' exceeds maximum supported size");
         return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
         }
-    _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) _NOEXCEPT
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
+    void deallocate(pointer __p, size_type __n) _NOEXCEPT
         {_VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}
-    _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
         {return size_type(~0) / sizeof(_Tp);}
 #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
     template <class _Up, class... _Args>
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
         void
         construct(_Up* __p, _Args&&... __args)
         {
@@ -1917,7 +1961,8 @@
             ::new((void*)__p) _Tp(__a0, __a1);
         }
 #endif  // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
-    _LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC _LIBCPP_INLINE_VISIBILITY
+    void destroy(pointer __p) {__p->~_Tp();}
 };
 
 template <class _Tp>
@@ -1946,6 +1991,7 @@
 
     _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
         {return _VSTD::addressof(__x);}
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC
     _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
     {
         if (__n > max_size())
@@ -1953,6 +1999,7 @@
                                  " 'n' exceeds maximum supported size");
         return static_cast<pointer>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
     }
+    _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC
     _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type __n) _NOEXCEPT
         {_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));}
     _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
@@ -2022,11 +2069,11 @@
 };
 
 template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC
 bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
 
 template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC
 bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;}
 
 template <class _OutputIterator, class _Tp>
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -575,6 +575,10 @@
 
 #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
 
+#ifndef __cpp_constexpr_dynamic_alloc
+#define _LIBCPP_HAS_NO_CONSTEXPR_DYNAMIC_ALLOC
+#endif
+
 #if defined(_LIBCPP_OBJECT_FORMAT_COFF)
 
 #ifdef _DLL
@@ -987,6 +991,12 @@
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX17
 #endif
 
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONSTEXPR_DYNAMIC_ALLOC)
+#  define _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC constexpr
+#else
+#  define _LIBCPP_CONSTEXPR_DYNAMIC_ALLOC
+#endif
+
 // The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other
 // NODISCARD macros to the correct attribute.
 #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D68364: P... Richard Smith - zygoloid via Phabricator via cfe-commits

Reply via email to