[libcxx-commits] [libcxx] b968c34 - [libc++] Removes _LIBCPP_AVAILABILITY_TO_CHARS.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 7 09:59:23 PDT 2022


Author: Mark de Wever
Date: 2022-06-07T18:59:19+02:00
New Revision: b968c3452b6a6ccef2545d860c4694dc95dcebc1

URL: https://github.com/llvm/llvm-project/commit/b968c3452b6a6ccef2545d860c4694dc95dcebc1
DIFF: https://github.com/llvm/llvm-project/commit/b968c3452b6a6ccef2545d860c4694dc95dcebc1.diff

LOG: [libc++] Removes _LIBCPP_AVAILABILITY_TO_CHARS.

After moving the std::to_chars base 10 implementation from the dylib to
the header the integral overloads of std::to_chars are available on all
platforms.

Remove the _LIBCPP_AVAILABILITY_TO_CHARS availability macro and update
the tests.

Depends on D125704

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D125745

Added: 
    

Modified: 
    libcxx/docs/ReleaseNotes.rst
    libcxx/include/__availability
    libcxx/include/charconv
    libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp
    libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp

Removed: 
    libcxx/test/libcxx/utilities/charconv/charconv.to.chars/availability.fail.cpp


################################################################################
diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index c2a43a6873ecb..c21d1f9e29f77 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -69,6 +69,10 @@ New Features
   should include assertions or not by default. For details, see
   :ref:`the documentation <assertions-mode>` about this new feature.
 
+- The implementation of the function ``std::to_chars`` for integral types has
+  moved from the dylib to the header. This means the function no longer has a
+  minimum deployment target.
+
 API Changes
 -----------
 

diff  --git a/libcxx/include/__availability b/libcxx/include/__availability
index 789e26679f31e..f9d824509f3d1 100644
--- a/libcxx/include/__availability
+++ b/libcxx/include/__availability
@@ -135,9 +135,6 @@
 #   define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
 // #   define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
 
-    // This controls the availability of std::to_chars for integral arguments.
-#   define _LIBCPP_AVAILABILITY_TO_CHARS
-
     // This controls the availability of floating-point std::to_chars functions.
     // These overloads were added later than the integer overloads.
 #   define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT
@@ -253,9 +250,6 @@
 #       define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem
 #   endif
 
-#   define _LIBCPP_AVAILABILITY_TO_CHARS                                        \
-        _LIBCPP_AVAILABILITY_FILESYSTEM
-
 #   define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT                         \
         __attribute__((unavailable))
 

diff  --git a/libcxx/include/charconv b/libcxx/include/charconv
index 96440e10c2c15..ce2897cf7c281 100644
--- a/libcxx/include/charconv
+++ b/libcxx/include/charconv
@@ -125,7 +125,6 @@ struct _LIBCPP_HIDDEN __traits_base
         return __t - (__v < __table<>::__pow10_64[__t]) + 1;
     }
 
-    _LIBCPP_AVAILABILITY_TO_CHARS
     static _LIBCPP_HIDE_FROM_ABI char* __convert(_Tp __v, char* __p)
     {
         return __itoa::__base_10_u64(__v, __p);
@@ -146,7 +145,6 @@ struct _LIBCPP_HIDDEN
         return __t - (__v < __table<>::__pow10_32[__t]) + 1;
     }
 
-    _LIBCPP_AVAILABILITY_TO_CHARS
     static _LIBCPP_HIDE_FROM_ABI char* __convert(_Tp __v, char* __p)
     {
         return __itoa::__base_10_u32(__v, __p);
@@ -243,7 +241,6 @@ __complement(_Tp __x)
 }
 
 template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS
 inline _LIBCPP_HIDE_FROM_ABI to_chars_result
 __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
 {
@@ -258,7 +255,6 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type)
 }
 
 template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS
 inline _LIBCPP_HIDE_FROM_ABI to_chars_result
 __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
 {
@@ -272,7 +268,6 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
 }
 
 template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS
 inline _LIBCPP_HIDE_FROM_ABI to_chars_result
 __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
                     true_type)
@@ -430,7 +425,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value) {
 }
 
 template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_HIDE_FROM_ABI int
+_LIBCPP_HIDE_FROM_ABI int
 __to_chars_integral_width(_Tp __value, unsigned __base) {
   _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value.");
 
@@ -457,7 +452,6 @@ __to_chars_integral_width(_Tp __value, unsigned __base) {
 }
 
 template <typename _Tp>
-_LIBCPP_AVAILABILITY_TO_CHARS
 inline _LIBCPP_HIDE_FROM_ABI to_chars_result
 __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
                     false_type)
@@ -490,7 +484,6 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
 }
 
 template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
-_LIBCPP_AVAILABILITY_TO_CHARS
 inline _LIBCPP_HIDE_FROM_ABI to_chars_result
 to_chars(char* __first, char* __last, _Tp __value)
 {
@@ -498,7 +491,6 @@ to_chars(char* __first, char* __last, _Tp __value)
 }
 
 template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
-_LIBCPP_AVAILABILITY_TO_CHARS
 inline _LIBCPP_HIDE_FROM_ABI to_chars_result
 to_chars(char* __first, char* __last, _Tp __value, int __base)
 {

diff  --git a/libcxx/test/libcxx/utilities/charconv/charconv.to.chars/availability.fail.cpp b/libcxx/test/libcxx/utilities/charconv/charconv.to.chars/availability.fail.cpp
deleted file mode 100644
index e1ca28a20b67c..0000000000000
--- a/libcxx/test/libcxx/utilities/charconv/charconv.to.chars/availability.fail.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03
-// REQUIRES: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
-
-// Test the availability markup on std::to_chars.
-
-#include <charconv>
-
-int main(int, char**)
-{
-    char buf[100];
-    int int_value = 33;
-    long long_value = 33;
-    int base = 2;
-    std::to_chars(buf, buf + 100, int_value); // expected-error{{is unavailable: introduced in}}
-    std::to_chars(buf, buf + 100, int_value, base); // expected-error{{is unavailable: introduced in}}
-
-    std::to_chars(buf, buf + 100, long_value); // expected-error{{is unavailable: introduced in}}
-    std::to_chars(buf, buf + 100, long_value, base); // expected-error{{is unavailable: introduced in}}
-}

diff  --git a/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp b/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp
index 6aa49534d243d..cd90faef34aee 100644
--- a/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp
+++ b/libcxx/test/std/utilities/charconv/charconv.from.chars/integral.roundtrip.pass.cpp
@@ -10,11 +10,6 @@
 // UNSUPPORTED: !stdlib=libc++ && c++11
 // UNSUPPORTED: !stdlib=libc++ && c++14
 
-// The roundtrip test uses to_chars, which requires functions in the dylib
-// that were introduced in Mac OS 10.15.
-//
-// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
-
 // <charconv>
 
 // from_chars_result from_chars(const char* first, const char* last,

diff  --git a/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp b/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
index d137461ea3bc2..70f85a537568a 100644
--- a/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
+++ b/libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
@@ -10,10 +10,6 @@
 // UNSUPPORTED: !stdlib=libc++ && c++11
 // UNSUPPORTED: !stdlib=libc++ && c++14
 
-// to_chars requires functions in the dylib that were introduced in Mac OS 10.15.
-//
-// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13|14}}
-
 // <charconv>
 
 // to_chars_result to_chars(char* first, char* last, Integral value,


        


More information about the libcxx-commits mailing list