[libcxx-commits] [libcxx] e0f5844 - [libc++] Fix feature test macro for __cpp_lib_to_chars

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 19 11:26:46 PST 2021


Author: Louis Dionne
Date: 2021-11-19T14:26:34-05:00
New Revision: e0f58444e126e80a0d43eb5b88622799910195e6

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

LOG: [libc++] Fix feature test macro for __cpp_lib_to_chars

We would have been defining it in <utility> instead of <charconv>. For
the time being, this doesn't change anything since we don't implement
the feature test macro anyways.

Also, as a fly-by, this removes obsolete feature test macro tests. There
was a brief time back in the days when we wrote feature test macro tests
manually. In particular, we had test files for __cpp_lib_to_chars and
__cpp_lib_memory_resource. Since we now have a principled way of generating
these tests with scripts, this commit removes the obsolete (and empty)
tests for these two feature test macros.

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

Added: 
    libcxx/test/std/language.support/support.limits/support.limits.general/charconv.version.pass.cpp

Modified: 
    libcxx/include/version
    libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp
    libcxx/utils/generate_feature_test_macro_components.py

Removed: 
    libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp
    libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp


################################################################################
diff  --git a/libcxx/include/version b/libcxx/include/version
index d2286f5e8207e..7c16ac85e4302 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -149,7 +149,7 @@ __cpp_lib_syncbuf                                       201803L <syncstream>
 __cpp_lib_three_way_comparison                          201907L <compare>
 __cpp_lib_to_address                                    201711L <memory>
 __cpp_lib_to_array                                      201907L <array>
-__cpp_lib_to_chars                                      201611L <utility>
+__cpp_lib_to_chars                                      201611L <charconv>
 __cpp_lib_to_underlying                                 202102L <utility>
 __cpp_lib_transformation_trait_aliases                  201304L <type_traits>
 __cpp_lib_transparent_operators                         201510L <functional> <memory>

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp
deleted file mode 100644
index 2afe2e26ba553..0000000000000
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.pass.cpp
+++ /dev/null
@@ -1,33 +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
-//
-//===----------------------------------------------------------------------===//
-//
-// <charconv> feature macros
-
-/*  Constant                                    Value
-    __cpp_lib_to_chars                          201611L
-
-*/
-
-#include <charconv>
-#include <cassert>
-#include "test_macros.h"
-
-int main(int, char**)
-{
-//  ensure that the macros that are supposed to be defined in <utility> are defined.
-
-/*
-#if !defined(__cpp_lib_fooby)
-# error "__cpp_lib_fooby is not defined"
-#elif __cpp_lib_fooby < 201606L
-# error "__cpp_lib_fooby has an invalid value"
-#endif
-*/
-
-  return 0;
-}

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.version.pass.cpp
new file mode 100644
index 0000000000000..04818dbb5ca93
--- /dev/null
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/charconv.version.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// WARNING: This test was generated by generate_feature_test_macro_components.py
+// and should not be edited manually.
+//
+// clang-format off
+
+// <charconv>
+
+// Test the feature test macros defined by <charconv>
+
+/*  Constant              Value
+    __cpp_lib_to_chars    201611L [C++17]
+*/
+
+#include <charconv>
+#include "test_macros.h"
+
+#if TEST_STD_VER < 14
+
+# ifdef __cpp_lib_to_chars
+#   error "__cpp_lib_to_chars should not be defined before c++17"
+# endif
+
+#elif TEST_STD_VER == 14
+
+# ifdef __cpp_lib_to_chars
+#   error "__cpp_lib_to_chars should not be defined before c++17"
+# endif
+
+#elif TEST_STD_VER == 17
+
+# if !defined(_LIBCPP_VERSION)
+#   ifndef __cpp_lib_to_chars
+#     error "__cpp_lib_to_chars should be defined in c++17"
+#   endif
+#   if __cpp_lib_to_chars != 201611L
+#     error "__cpp_lib_to_chars should have the value 201611L in c++17"
+#   endif
+# else // _LIBCPP_VERSION
+#   ifdef __cpp_lib_to_chars
+#     error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!"
+#   endif
+# endif
+
+#elif TEST_STD_VER == 20
+
+# if !defined(_LIBCPP_VERSION)
+#   ifndef __cpp_lib_to_chars
+#     error "__cpp_lib_to_chars should be defined in c++20"
+#   endif
+#   if __cpp_lib_to_chars != 201611L
+#     error "__cpp_lib_to_chars should have the value 201611L in c++20"
+#   endif
+# else // _LIBCPP_VERSION
+#   ifdef __cpp_lib_to_chars
+#     error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!"
+#   endif
+# endif
+
+#elif TEST_STD_VER > 20
+
+# if !defined(_LIBCPP_VERSION)
+#   ifndef __cpp_lib_to_chars
+#     error "__cpp_lib_to_chars should be defined in c++2b"
+#   endif
+#   if __cpp_lib_to_chars != 201611L
+#     error "__cpp_lib_to_chars should have the value 201611L in c++2b"
+#   endif
+# else // _LIBCPP_VERSION
+#   ifdef __cpp_lib_to_chars
+#     error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!"
+#   endif
+# endif
+
+#endif // TEST_STD_VER > 20
+
+int main(int, char**) { return 0; }

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp
deleted file mode 100644
index d712a8bca8d1f..0000000000000
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.pass.cpp
+++ /dev/null
@@ -1,35 +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
-//
-//===----------------------------------------------------------------------===//
-//
-// <memory_resource> feature macros
-
-/*  Constant                                    Value
-    __cpp_lib_memory_resource                   201603L
-
-*/
-
-// XFAIL
-// #include <memory_resource>
-#include <cassert>
-#include "test_macros.h"
-
-int main(int, char**)
-{
-//  ensure that the macros that are supposed to be defined in <memory_resource> are defined.
-
-/*
-#if !defined(__cpp_lib_fooby)
-# error "__cpp_lib_fooby is not defined"
-#elif __cpp_lib_fooby < 201606L
-# error "__cpp_lib_fooby has an invalid value"
-#endif
-*/
-
-  return 0;
-}

diff  --git a/libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp
index b5662f751b029..0159371ab2501 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/utility.version.pass.cpp
@@ -21,7 +21,6 @@
     __cpp_lib_exchange_function               201304L [C++14]
     __cpp_lib_integer_comparison_functions    202002L [C++20]
     __cpp_lib_integer_sequence                201304L [C++14]
-    __cpp_lib_to_chars                        201611L [C++17]
     __cpp_lib_to_underlying                   202102L [C++2b]
     __cpp_lib_tuples_by_type                  201304L [C++14]
 */
@@ -51,10 +50,6 @@
 #   error "__cpp_lib_integer_sequence should not be defined before c++14"
 # endif
 
-# ifdef __cpp_lib_to_chars
-#   error "__cpp_lib_to_chars should not be defined before c++17"
-# endif
-
 # ifdef __cpp_lib_to_underlying
 #   error "__cpp_lib_to_underlying should not be defined before c++2b"
 # endif
@@ -91,10 +86,6 @@
 #   error "__cpp_lib_integer_sequence should have the value 201304L in c++14"
 # endif
 
-# ifdef __cpp_lib_to_chars
-#   error "__cpp_lib_to_chars should not be defined before c++17"
-# endif
-
 # ifdef __cpp_lib_to_underlying
 #   error "__cpp_lib_to_underlying should not be defined before c++2b"
 # endif
@@ -137,19 +128,6 @@
 #   error "__cpp_lib_integer_sequence should have the value 201304L in c++17"
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_to_chars
-#     error "__cpp_lib_to_chars should be defined in c++17"
-#   endif
-#   if __cpp_lib_to_chars != 201611L
-#     error "__cpp_lib_to_chars should have the value 201611L in c++17"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_to_chars
-#     error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!"
-#   endif
-# endif
-
 # ifdef __cpp_lib_to_underlying
 #   error "__cpp_lib_to_underlying should not be defined before c++2b"
 # endif
@@ -204,19 +182,6 @@
 #   error "__cpp_lib_integer_sequence should have the value 201304L in c++20"
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_to_chars
-#     error "__cpp_lib_to_chars should be defined in c++20"
-#   endif
-#   if __cpp_lib_to_chars != 201611L
-#     error "__cpp_lib_to_chars should have the value 201611L in c++20"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_to_chars
-#     error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!"
-#   endif
-# endif
-
 # ifdef __cpp_lib_to_underlying
 #   error "__cpp_lib_to_underlying should not be defined before c++2b"
 # endif
@@ -271,19 +236,6 @@
 #   error "__cpp_lib_integer_sequence should have the value 201304L in c++2b"
 # endif
 
-# if !defined(_LIBCPP_VERSION)
-#   ifndef __cpp_lib_to_chars
-#     error "__cpp_lib_to_chars should be defined in c++2b"
-#   endif
-#   if __cpp_lib_to_chars != 201611L
-#     error "__cpp_lib_to_chars should have the value 201611L in c++2b"
-#   endif
-# else // _LIBCPP_VERSION
-#   ifdef __cpp_lib_to_chars
-#     error "__cpp_lib_to_chars should not be defined because it is unimplemented in libc++!"
-#   endif
-# endif
-
 # ifndef __cpp_lib_to_underlying
 #   error "__cpp_lib_to_underlying should be defined in c++2b"
 # endif

diff  --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 2e858935b4af8..1a78acee6292c 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -596,7 +596,7 @@ def add_version_header(tc):
   }, {
     "name": "__cpp_lib_to_chars",
     "values": { "c++17": 201611 },
-    "headers": ["utility"],
+    "headers": ["charconv"],
     "unimplemented": True,
   }, {
     "name": "__cpp_lib_to_underlying",


        


More information about the libcxx-commits mailing list