[libcxx-commits] [PATCH] D105318: [libc++] Support Apple Clang 10, which lacks constexpr dtor support.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 1 14:58:46 PDT 2021


Quuxplusone created this revision.
Quuxplusone added reviewers: ldionne, libc++.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

  Merely building libc++.a shouldn't require a bleeding-edge compiler;
  but in order to build libc++.a you need to compile src/optional.cpp,
  which requires being able to parse include/optional (and for some reason
  to do this in full C++2a mode). Apple Clang 10 (my current Xcode version)
  doesn't do constexpr destructors (wg21.link/p0784), so it can't build
  libc++.a for this solitary reason. Let's just fix this one thing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105318

Files:
  libcxx/include/__config
  libcxx/include/optional


Index: libcxx/include/optional
===================================================================
--- libcxx/include/optional
+++ libcxx/include/optional
@@ -221,7 +221,7 @@
     bool __engaged_;
 
     _LIBCPP_INLINE_VISIBILITY
-    _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__optional_destruct_base()
+    _LIBCPP_CONSTEXPR_DESTRUCTOR ~__optional_destruct_base()
     {
         if (__engaged_)
             __val_.~value_type();
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1055,6 +1055,12 @@
 #  define _LIBCPP_CONSTEXPR_AFTER_CXX17
 #endif
 
+#if _LIBCPP_STD_VER > 17 && defined(__cpp_constexpr_dynamic_alloc) && (__cpp_constexpr_dynamic_alloc >= 201907L)
+#  define _LIBCPP_CONSTEXPR_DESTRUCTOR constexpr
+#else
+#  define _LIBCPP_CONSTEXPR_DESTRUCTOR
+#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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105318.356023.patch
Type: text/x-patch
Size: 1061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210701/70732651/attachment.bin>


More information about the libcxx-commits mailing list