Skip to content

Commit c720877

Browse files
committed
[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: #75976
1 parent 6f55c13 commit c720877

6 files changed

+66
-1
lines changed

libcxx/docs/ReleaseNotes/18.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ Deprecations and Removals
123123
overload of ``allocate``. However, this led to the library being non-conforming due to incorrect
124124
constexpr-ness.
125125

126+
- The macros ``_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES`` and
127+
``_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES`` have been deprecated and
128+
will be removed in LLVM 19. These macros used to enable all features
129+
removed in C++17 and C++20. Instead of using these macros, use the
130+
macros to enable the individual features.
131+
126132
Upcoming Deprecations and Removals
127133
----------------------------------
128134

@@ -149,6 +155,10 @@ LLVM 19
149155
- The ``_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS`` macro has been deprecated in LLVM 18 and will be removed
150156
entirely in LLVM 19.
151157

158+
- The ``_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES`` and
159+
``_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES`` macros have been deprecated
160+
in LLVM 18 and will be removed entirely in LLVM 19.
161+
152162
LLVM 20
153163
~~~~~~~
154164

libcxx/docs/UsingLibcxx.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ C++17 Specific Configuration Macros
275275
**_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:
276276
This macro is used to re-enable all the features removed in C++17. The effect
277277
is equivalent to manually defining each macro listed below.
278+
This macro is deprecated and will be removed in LLVM-19. Use the
279+
individual macros listed below.
278280

279281
**_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR**:
280282
This macro is used to re-enable `auto_ptr`.
@@ -303,6 +305,8 @@ C++20 Specific Configuration Macros
303305
**_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES**:
304306
This macro is used to re-enable all the features removed in C++20. The effect
305307
is equivalent to manually defining each macro listed below.
308+
This macro is deprecated and will be removed in LLVM-19. Use the
309+
individual macros listed below.
306310

307311
**_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS**:
308312
This macro is used to re-enable redundant members of `allocator<T>`,

libcxx/include/__config

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616
# pragma GCC system_header
1717
#endif
1818

19+
#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
20+
# pragma clang deprecated( \
21+
_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES, \
22+
"_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES is deprecated in LLVM 18 and will be removed in LLVM 19")
23+
#endif
24+
#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
25+
# pragma clang deprecated( \
26+
_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES, \
27+
"_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES is deprecated in LLVM 18 and will be removed in LLVM 19")
28+
#endif
29+
1930
#if defined(__apple_build_version__)
2031
// Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403)
2132
# define _LIBCPP_COMPILER_CLANG_BASED

libcxx/test/libcxx/depr/enable_removed_cpp17_features.compile.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Test that defining _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES correctly defines
1010
// _LIBCPP_ENABLE_CXX17_REMOVED_FOO for each individual component macro.
1111

12-
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
12+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES -Wno-deprecated-pragma
1313

1414
#include <__config>
1515

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// <__config>
10+
11+
// Ensure that defining _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES yields a
12+
// deprecation warning. We intend to issue a deprecation warning in LLVM 18
13+
// and remove the macro entirely in LLVM 19. As such, this test will be quite
14+
// short lived.
15+
16+
// UNSUPPORTED: clang-modules-build
17+
18+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
19+
20+
#include <__config> // expected-warning@* 1+ {{macro '_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES' has been marked as deprecated}}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// <__config>
10+
11+
// Ensure that defining _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES yields a
12+
// deprecation warning. We intend to issue a deprecation warning in LLVM 18
13+
// and remove the macro entirely in LLVM 19. As such, this test will be quite
14+
// short lived.
15+
16+
// UNSUPPORTED: clang-modules-build
17+
18+
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
19+
20+
#include <version> // expected-warning@* 1+ {{macro '_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES' has been marked as deprecated}}

0 commit comments

Comments
 (0)