Skip to content

Commit 6e1f0b6

Browse files
frederick-vs-jaldionne
authored andcommitted
[libc++] Deprecate and remove meaningless <cxxx> headers (llvm#111615)
This PR deprecates `<ccomplex>`, `<cstdbool>`, `<ctgmath>`, and `<ciso646>` in C++17 and "removes" them in C++20 by special deprecation warnings. `<cstdalign>` is previously missing. This PR also tries to add them, and then deprecates and "removes" `<cstdalign>`. Papers: - https://wg21.link/P0063R3 - https://wg21.link/P0619R4 Closes llvm#99985. --------- Co-authored-by: Louis Dionne <[email protected]>
1 parent d5b1d5c commit 6e1f0b6

38 files changed

+394
-44
lines changed

libcxx/docs/ReleaseNotes/20.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ What's New in Libc++ 20.0.0?
3838
Implemented Papers
3939
------------------
4040

41+
- P0619R4: Reviewing Deprecated Facilities of C++17 for C++20 (`Github <https://github.com/llvm/llvm-project/issues/99985>`__)
4142
- P2747R2: ``constexpr`` placement new (`Github <https://github.com/llvm/llvm-project/issues/105427>`__)
4243
- P2609R3: Relaxing Ranges Just A Smidge (`Github <https://github.com/llvm/llvm-project/issues/105253>`__)
4344
- P2985R0: A type trait for detecting virtual base classes (`Github <https://github.com/llvm/llvm-project/issues/105432>`__)
@@ -95,6 +96,11 @@ Deprecations and Removals
9596
the ``_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT`` macro can be defined to make the function non-``noexcept``. That macro
9697
will be removed in LLVM 21.
9798

99+
- ``<ccomplex>``, ``<cstdalign>`` (previously missing), ``<cstdbool>``, and ``<ctgmath>`` are deprecated since C++17 as
100+
specified by the standard. They, together with ``<ciso646>``, are removed in C++20, but libc++ still provides these
101+
headers as an extension and only deprecates them. The ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS`` macro can be defined to
102+
suppress deprecation for these headers.
103+
98104
Upcoming Deprecations and Removals
99105
----------------------------------
100106

libcxx/docs/Status/Cxx20Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"`P0528R3 <https://wg21.link/P0528R3>`__","The Curious Case of Padding Bits, Featuring Atomic Compare-and-Exchange","2018-06 (Rapperswil)","","",""
3535
"`P0542R5 <https://wg21.link/P0542R5>`__","Support for contract based programming in C++","2018-06 (Rapperswil)","|Nothing To Do|","n/a","Pulled at the 2019-07 meeting in Cologne"
3636
"`P0556R3 <https://wg21.link/P0556R3>`__","Integral power-of-2 operations","2018-06 (Rapperswil)","|Complete|","9.0",""
37-
"`P0619R4 <https://wg21.link/P0619R4>`__","Reviewing Deprecated Facilities of C++17 for C++20","2018-06 (Rapperswil)","|Partial|","","Only sections D.7, D.8, D.9, D.10, D.11, D.12, and D.13 are implemented. Section D.4 remains undone."
37+
"`P0619R4 <https://wg21.link/P0619R4>`__","Reviewing Deprecated Facilities of C++17 for C++20","2018-06 (Rapperswil)","|Complete|","20.0","Removed headers are still provided as an extension, but with deprecation warnings"
3838
"`P0646R1 <https://wg21.link/P0646R1>`__","Improving the Return Value of Erase-Like Algorithms","2018-06 (Rapperswil)","|Complete|","10.0",""
3939
"`P0722R3 <https://wg21.link/P0722R3>`__","Efficient sized delete for variable sized classes","2018-06 (Rapperswil)","|Complete|","9.0",""
4040
"`P0758R1 <https://wg21.link/P0758R1>`__","Implicit conversion traits and utility functions","2018-06 (Rapperswil)","|Complete|","",""

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ set(files
923923
coroutine
924924
csetjmp
925925
csignal
926+
cstdalign
926927
cstdarg
927928
cstdbool
928929
cstddef

libcxx/include/ccomplex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,16 @@
2323
# pragma GCC system_header
2424
#endif
2525

26+
#if _LIBCPP_STD_VER >= 20
27+
28+
using __standard_header_ccomplex _LIBCPP_DEPRECATED_("removed in C++20. Include <complex> instead.") = void;
29+
using __use_standard_header_ccomplex = __standard_header_ccomplex;
30+
31+
#elif _LIBCPP_STD_VER >= 17
32+
33+
using __standard_header_ccomplex _LIBCPP_DEPRECATED_("Include <complex> instead.") = void;
34+
using __use_standard_header_ccomplex = __standard_header_ccomplex;
35+
36+
#endif
37+
2638
#endif // _LIBCPP_CCOMPLEX

libcxx/include/ciso646

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,11 @@
2121
# pragma GCC system_header
2222
#endif
2323

24+
#if _LIBCPP_STD_VER >= 20
25+
26+
using __standard_header_ciso646 _LIBCPP_DEPRECATED_("removed in C++20. Include <version> instead.") = void;
27+
using __use_standard_header_ciso646 = __standard_header_ciso646;
28+
29+
#endif
30+
2431
#endif // _LIBCPP_CISO646

libcxx/include/complex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#endif
2525

2626
#ifdef __cplusplus
27-
# include <ccomplex>
27+
# include <complex>
2828
#elif __has_include_next(<complex.h>)
2929
# include_next <complex.h>
3030
#endif

libcxx/include/cstdalign

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP_CSTDALIGN
11+
#define _LIBCPP_CSTDALIGN
12+
13+
/*
14+
cstdalign synopsis
15+
16+
Macros:
17+
18+
__alignas_is_defined
19+
__alignof_is_defined
20+
21+
*/
22+
23+
#include <__config>
24+
25+
// <stdalign.h> is not provided by libc++
26+
#if __has_include(<stdalign.h>)
27+
# include <stdalign.h>
28+
# ifdef _LIBCPP_STDALIGN_H
29+
# error "If libc++ starts defining <stdalign.h>, the __has_include check should move to libc++'s <stdalign.h>"
30+
# endif
31+
#endif
32+
33+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
34+
# pragma GCC system_header
35+
#endif
36+
37+
#undef __alignas_is_defined
38+
#define __alignas_is_defined 1
39+
40+
#undef __alignof_is_defined
41+
#define __alignof_is_defined 1
42+
43+
#if _LIBCPP_STD_VER >= 20
44+
45+
using __standard_header_cstdalign _LIBCPP_DEPRECATED_("removed in C++20.") = void;
46+
using __use_standard_header_cstdalign = __standard_header_cstdalign;
47+
48+
#elif _LIBCPP_STD_VER >= 17
49+
50+
using __standard_header_cstdalign _LIBCPP_DEPRECATED = void;
51+
using __use_standard_header_cstdalign = __standard_header_cstdalign;
52+
53+
#endif
54+
55+
#endif // _LIBCPP_CSTDALIGN

libcxx/include/cstdbool

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,16 @@ Macros:
2828
#undef __bool_true_false_are_defined
2929
#define __bool_true_false_are_defined 1
3030

31+
#if _LIBCPP_STD_VER >= 20
32+
33+
using __standard_header_cstdbool _LIBCPP_DEPRECATED_("removed in C++20.") = void;
34+
using __use_standard_header_cstdbool = __standard_header_cstdbool;
35+
36+
#elif _LIBCPP_STD_VER >= 17
37+
38+
using __standard_header_cstdbool _LIBCPP_DEPRECATED = void;
39+
using __use_standard_header_cstdbool = __standard_header_cstdbool;
40+
41+
#endif
42+
3143
#endif // _LIBCPP_CSTDBOOL

libcxx/include/ctgmath

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,23 @@
1818
1919
*/
2020

21-
#include <ccomplex>
2221
#include <cmath>
22+
#include <complex>
2323

2424
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2525
# pragma GCC system_header
2626
#endif
2727

28+
#if _LIBCPP_STD_VER >= 20
29+
30+
using __standard_header_ctgmath _LIBCPP_DEPRECATED_("removed in C++20. Include <cmath> and <complex> instead.") = void;
31+
using __use_standard_header_ctgmath = __standard_header_ctgmath;
32+
33+
#elif _LIBCPP_STD_VER >= 17
34+
35+
using __standard_header_ctgmath _LIBCPP_DEPRECATED_("Include <cmath> and <complex> instead.") = void;
36+
using __use_standard_header_ctgmath = __standard_header_ctgmath;
37+
38+
#endif
39+
2840
#endif // _LIBCPP_CTGMATH

libcxx/include/module.modulemap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,11 @@ module std [system] {
11091109
export *
11101110
}
11111111

1112+
module cstdalign {
1113+
header "cstdalign"
1114+
export *
1115+
}
1116+
11121117
module cstdarg {
11131118
header "cstdarg"
11141119
export *

0 commit comments

Comments
 (0)