[libcxx-commits] [libcxx] 963495f - [libc++][format] Adds availability macros for std::format.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 26 08:54:39 PDT 2021
Author: Mark de Wever
Date: 2021-05-26T17:54:33+02:00
New Revision: 963495f0d4b5a0707f82b6c6454f42f3aa52da9b
URL: https://github.com/llvm/llvm-project/commit/963495f0d4b5a0707f82b6c6454f42f3aa52da9b
DIFF: https://github.com/llvm/llvm-project/commit/963495f0d4b5a0707f82b6c6454f42f3aa52da9b.diff
LOG: [libc++][format] Adds availability macros for std::format.
This prevents std::format to be available until there's an ABI stable
version. (This only impacts the Apple platform.)
Depends on D102703
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D102705
Added:
Modified:
libcxx/include/__availability
libcxx/include/__format/format_parse_context.h
libcxx/include/version
libcxx/utils/generate_feature_test_macro_components.py
Removed:
################################################################################
diff --git a/libcxx/include/__availability b/libcxx/include/__availability
index 59d92fffd2369..9d488f00ebb32 100644
--- a/libcxx/include/__availability
+++ b/libcxx/include/__availability
@@ -138,6 +138,13 @@
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch
// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore
+ // This controls the availability of the C++20 format library.
+ // The library is in development and not ABI stable yet. Currently
+ // P2216 is aiming to be retroactively accepted in C++20. This paper
+ // contains ABI breaking changes.
+# define _LIBCPP_AVAILABILITY_FORMAT
+// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
+
#elif defined(__APPLE__)
# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \
@@ -223,6 +230,13 @@
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch
# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore
+ // This controls the availability of the C++20 format library.
+ // The library is in development and not ABI stable yet. Currently
+ // P2216 is aiming to be retroactively accepted in C++20. This paper
+ // contains ABI breaking changes.
+# define _LIBCPP_AVAILABILITY_FORMAT \
+ __attribute__((unavailable))
+# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format
#else
// ...New vendors can add availability markup here...
diff --git a/libcxx/include/__format/format_parse_context.h b/libcxx/include/__format/format_parse_context.h
index 43c756bf004df..abe580db2d041 100644
--- a/libcxx/include/__format/format_parse_context.h
+++ b/libcxx/include/__format/format_parse_context.h
@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
!defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED)
template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS basic_format_parse_context {
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context {
public:
using char_type = _CharT;
using const_iterator = typename basic_string_view<_CharT>::const_iterator;
diff --git a/libcxx/include/version b/libcxx/include/version
index fb5eb6ec2586b..3d1554b5c4d77 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -319,7 +319,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_erase_if 202002L
# undef __cpp_lib_execution
// # define __cpp_lib_execution 201902L
-// # define __cpp_lib_format 201907L
+# if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format)
+// # define __cpp_lib_format 201907L
+# endif
# define __cpp_lib_generic_unordered_lookup 201811L
# define __cpp_lib_int_pow2 202002L
# if !defined(_LIBCPP_HAS_NO_CONCEPTS)
diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 36fe3b35dfaf1..76ac93ec10237 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -300,6 +300,8 @@ def add_version_header(tc):
"name": "__cpp_lib_format",
"values": { "c++20": 201907 },
"headers": ["format"],
+ "test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format)",
+ "libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format)",
"unimplemented": True,
}, {
"name": "__cpp_lib_gcd_lcm",
More information about the libcxx-commits
mailing list