[libcxx-commits] [libcxx] [libc++] Deprecate removed features macros. (PR #77879)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 11 22:54:44 PST 2024
https://github.com/mordante created https://github.com/llvm/llvm-project/pull/77879
We discussed the the removal of these enable-all macros in the libc++ monthly meeting and we agreed that we should deprecate these macros in LLVM 18, and then remove it in LLVM 19 since they can silently enable deprecated features that are implemented after the first release of the macro.
This patch does the first part of this -- it deprecates the macro.
Note the file
test/libcxx/depr/enable_removed_cpp20_features.compile.pass.cpp
does not exist so this file is not adapted. Since the feature is deprecated and slated for removal soon the missing test is not implemented.
Partly addresses: https://github.com/llvm/llvm-project/issues/75976
>From e56f4bab91f043a6ddb6ee0f48b8575f88a01b7d Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Thu, 11 Jan 2024 20:56:44 +0100
Subject: [PATCH] [libc++] Deprecate removed features macros.
We discussed the the removal of these enable-all macros in the libc++
monthly meeting and we agreed that we should deprecate these macros in
LLVM 18, and then remove it in LLVM 19 since they can silently enable
deprecated features that are implemented after the first release of the
macro.
This patch does the first part of this -- it deprecates the macro.
Note the file
test/libcxx/depr/enable_removed_cpp20_features.compile.pass.cpp
does not exist so this file is not adapted. Since the feature is
deprecated and slated for removal soon the missing test is not
implemented.
Partly addresses: https://github.com/llvm/llvm-project/issues/75976
---
libcxx/docs/ReleaseNotes/18.rst | 10 ++++++++++
libcxx/docs/UsingLibcxx.rst | 4 ++++
libcxx/include/__config | 11 +++++++++++
...ble_removed_cpp17_features.compile.pass.cpp | 2 +-
...emoved_cpp17_features.deprecated.verify.cpp | 18 ++++++++++++++++++
...emoved_cpp20_features.deprecated.verify.cpp | 18 ++++++++++++++++++
6 files changed, 62 insertions(+), 1 deletion(-)
create mode 100644 libcxx/test/libcxx/depr/enable_removed_cpp17_features.deprecated.verify.cpp
create mode 100644 libcxx/test/libcxx/depr/enable_removed_cpp20_features.deprecated.verify.cpp
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index 478e87f8888332..eecf0991b5c95a 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -117,6 +117,12 @@ Deprecations and Removals
and ``<experimental/vector>`` have been removed in LLVM 18, as all their contents will have been
implemented in namespace ``std`` for at least two releases.
+- The macros ``_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES`` and
+ ``_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES`` have been deprecated and
+ will be removed in LLVM 19. These macros used to enable all features
+ removed in C++17 and C++20. Instead of using these macros, use the
+ macros to enable the individual features.
+
Upcoming Deprecations and Removals
----------------------------------
@@ -140,6 +146,10 @@ LLVM 19
- The ``_LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT`` macro that changed the behavior for narrowing conversions
in ``std::variant`` will be removed in LLVM 19.
+- The ``_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES`` and
+ ``_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES`` macros have been deprecated
+ in LLVM 18 and will be removed entirely in LLVM 19.
+
LLVM 20
~~~~~~~
diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst
index e1bbf39b9634a3..85e4fc33a27db9 100644
--- a/libcxx/docs/UsingLibcxx.rst
+++ b/libcxx/docs/UsingLibcxx.rst
@@ -275,6 +275,8 @@ C++17 Specific Configuration Macros
**_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:
This macro is used to re-enable all the features removed in C++17. The effect
is equivalent to manually defining each macro listed below.
+ This macro is deprecated and will be removed in LLVM-19. Use the
+ individual macros listed below.
**_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR**:
This macro is used to re-enable `auto_ptr`.
@@ -303,6 +305,8 @@ C++20 Specific Configuration Macros
**_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES**:
This macro is used to re-enable all the features removed in C++20. The effect
is equivalent to manually defining each macro listed below.
+ This macro is deprecated and will be removed in LLVM-19. Use the
+ individual macros listed below.
**_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS**:
This macro is used to re-enable redundant members of `allocator<T>`,
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 1958d5c50ca911..ee272a62711af5 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -16,6 +16,17 @@
# pragma GCC system_header
#endif
+#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# pragma clang deprecated( \
+ _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES, \
+ "_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES is deprecated in LLVM 18 and will be removed in LLVM 19")
+#endif
+#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# pragma clang deprecated( \
+ _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES, \
+ "_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES is deprecated in LLVM 18 and will be removed in LLVM 19")
+#endif
+
#if defined(__apple_build_version__)
// Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403)
# define _LIBCPP_COMPILER_CLANG_BASED
diff --git a/libcxx/test/libcxx/depr/enable_removed_cpp17_features.compile.pass.cpp b/libcxx/test/libcxx/depr/enable_removed_cpp17_features.compile.pass.cpp
index 2ee6010b3fc218..1b7acad3cfa464 100644
--- a/libcxx/test/libcxx/depr/enable_removed_cpp17_features.compile.pass.cpp
+++ b/libcxx/test/libcxx/depr/enable_removed_cpp17_features.compile.pass.cpp
@@ -9,7 +9,7 @@
// Test that defining _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES correctly defines
// _LIBCPP_ENABLE_CXX17_REMOVED_FOO for each individual component macro.
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES -Wno-deprecated-pragma
#include <__config>
diff --git a/libcxx/test/libcxx/depr/enable_removed_cpp17_features.deprecated.verify.cpp b/libcxx/test/libcxx/depr/enable_removed_cpp17_features.deprecated.verify.cpp
new file mode 100644
index 00000000000000..91b039a559a3b2
--- /dev/null
+++ b/libcxx/test/libcxx/depr/enable_removed_cpp17_features.deprecated.verify.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <__config>
+
+// Ensure that defining _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES yields a
+// deprecation warning. We intend to issue a deprecation warning in LLVM 18
+// and remove the macro entirely in LLVM 19. As such, this test will be quite
+// short lived.
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
+
+#include <__config> // expected-warning@* 1+ {{macro '_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES' has been marked as deprecated}}
diff --git a/libcxx/test/libcxx/depr/enable_removed_cpp20_features.deprecated.verify.cpp b/libcxx/test/libcxx/depr/enable_removed_cpp20_features.deprecated.verify.cpp
new file mode 100644
index 00000000000000..b66c1250a24309
--- /dev/null
+++ b/libcxx/test/libcxx/depr/enable_removed_cpp20_features.deprecated.verify.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <__config>
+
+// Ensure that defining _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES yields a
+// deprecation warning. We intend to issue a deprecation warning in LLVM 18
+// and remove the macro entirely in LLVM 19. As such, this test will be quite
+// short lived.
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
+
+#include <version> // expected-warning@* 1+ {{macro '_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES' has been marked as deprecated}}
More information about the libcxx-commits
mailing list