Skip to content

[libc++] Deprecate removed features macros. #77879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

mordante
Copy link
Member

@mordante mordante commented Jan 12, 2024

We discussed 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 them 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 that 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: #75976

@mordante mordante requested a review from a team as a code owner January 12, 2024 06:54
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jan 12, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 12, 2024

@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)

Changes

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: #75976


Full diff: https://github.com/llvm/llvm-project/pull/77879.diff

6 Files Affected:

  • (modified) libcxx/docs/ReleaseNotes/18.rst (+10)
  • (modified) libcxx/docs/UsingLibcxx.rst (+4)
  • (modified) libcxx/include/__config (+11)
  • (modified) libcxx/test/libcxx/depr/enable_removed_cpp17_features.compile.pass.cpp (+1-1)
  • (added) libcxx/test/libcxx/depr/enable_removed_cpp17_features.deprecated.verify.cpp (+18)
  • (added) libcxx/test/libcxx/depr/enable_removed_cpp20_features.deprecated.verify.cpp (+18)
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}}

@mordante
Copy link
Member Author

@nico heads up, this change might affect Chromium.

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: llvm#75976
@ldionne
Copy link
Member

ldionne commented Jan 16, 2024

CC @llvm/libcxx-vendors more generally

@mordante mordante merged commit e044362 into llvm:main Jan 16, 2024
@mordante mordante deleted the deprecate_removed_features_macros branch January 16, 2024 18:13
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
We discussed 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 them 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 that 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: llvm#75976

---------

Co-authored-by: Louis Dionne <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants