Revert "[libc++] Remove _LIBCPP_CONSTEVAL"
authorHans Wennborg <hans@chromium.org>
Mon, 13 Feb 2023 15:17:02 +0000 (16:17 +0100)
committerHans Wennborg <hans@chromium.org>
Mon, 13 Feb 2023 15:29:57 +0000 (16:29 +0100)
It causes mysterious memory leaks when comparing std::string, see GitHub
Issue #60709 and the code review.

> All supported compilers support `consteval`, so there is no more need for the macro.
>
> Reviewed By: ldionne, Mordante, #libc
>
> Spies: libcxx-commits
>
> Differential Revision: https://reviews.llvm.org/D143489

This reverts commit aaef3b82f4f0dd3924a3491b381d5015ff472b86.

libcxx/.clang-format
libcxx/include/__compare/ordering.h
libcxx/include/__config

index 980f881eac5ded131b4548b47b2bece7e0cf796a..77ffa23435cc06419f47013e4e7d011f59f2a25f 100644 (file)
@@ -37,6 +37,7 @@ AttributeMacros: ['_LIBCPP_HIDE_FROM_ABI',
                   '_LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION',
                   '_LIBCPP_HIDE_FROM_ABI_AFTER_V1',
                   '_LIBCPP_INLINE_VISIBILITY',
+                  '_LIBCPP_CONSTEVAL',
                   '_LIBCPP_NOALIAS',
                   '_LIBCPP_USING_IF_EXISTS',
                   '_LIBCPP_DEPRECATED',
index 572a15cf3485e6d325f451b853368ef74a920ce7..ff148abf234fb9ab4ba45d2c68616acbd1106280 100644 (file)
@@ -40,7 +40,7 @@ template<class _Tp, class... _Args>
 inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...);
 
 struct _CmpUnspecifiedParam {
-  _LIBCPP_HIDE_FROM_ABI consteval
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEVAL
   _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
 
   template<class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>>
index f9c8158280b01540e5939c4851dbd90198446990..be15ce2457ac97d1b5fc8c4a08e8f809df29c5fd 100644 (file)
@@ -686,6 +686,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
 #    define _LIBCPP_HAS_NO_INT128
 #  endif
 
+#  ifndef __cpp_consteval
+#    define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR
+#  else
+#    define _LIBCPP_CONSTEVAL consteval
+#  endif
+
 #  if __has_attribute(__malloc__)
 #    define _LIBCPP_NOALIAS __attribute__((__malloc__))
 #  else