[libcxx] [llvm] [libc++] Deprecate and remove meaningless `<cxxx>` headers (PR #111615)
A. Jiang via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 23 10:46:56 PDT 2024
https://github.com/frederick-vs-ja updated https://github.com/llvm/llvm-project/pull/111615
>From cd7e179a34a3696cc8b6f0c1db940b842a9ce3d1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Wed, 9 Oct 2024 09:52:29 +0800
Subject: [PATCH 01/22] [libc++] Deprecate and remove meaningless `<cxxx>`
headers
`<ccomplex>`, `<cstdbool>`, `<ctgmath>`, and `<ciso646>` are deprecated
and "removed" by special deprecation warnings. `<cstdalign>` is
currently missing.
---
libcxx/docs/ReleaseNotes/20.rst | 7 ++++++-
libcxx/docs/Status/Cxx17Papers.csv | 2 +-
libcxx/docs/Status/Cxx20Papers.csv | 2 +-
libcxx/include/ccomplex | 13 ++++++++++++
libcxx/include/ciso646 | 5 +++++
libcxx/include/cstdbool | 13 ++++++++++++
libcxx/include/ctgmath | 13 ++++++++++++
.../depr.c.headers/ciso646.compile.pass.cpp | 4 +++-
.../depr/depr.cpp.headers/ccomplex.verify.cpp | 21 +++++++++++++++++++
.../depr/depr.cpp.headers/ciso646.verify.cpp | 17 +++++++++++++++
.../depr/depr.cpp.headers/cstdbool.verify.cpp | 21 +++++++++++++++++++
.../depr/depr.cpp.headers/ctgmath.verify.cpp | 21 +++++++++++++++++++
.../support.runtime/cstdbool.pass.cpp | 4 +++-
.../test/std/numerics/c.math/ctgmath.pass.cpp | 4 +++-
.../complex.number/ccmplx/ccomplex.pass.cpp | 4 +++-
15 files changed, 144 insertions(+), 7 deletions(-)
create mode 100644 libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
create mode 100644 libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
create mode 100644 libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
create mode 100644 libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index 82c8286b69e23c..22f98bb1a2089a 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -38,8 +38,9 @@ What's New in Libc++ 20.0.0?
Implemented Papers
------------------
-- P2747R2: ``constexpr`` placement new (`Github <https://github.com/llvm/llvm-project/issues/105427>`__)
+- P0619R4: Reviewing Deprecated Facilities of C++17 for C++20 (`Github <https://github.com/llvm/llvm-project/issues/99985>`__)
- P2609R3: Relaxing Ranges Just A Smidge (`Github <https://github.com/llvm/llvm-project/issues/105253>`__)
+- P2747R2: ``constexpr`` placement new (`Github <https://github.com/llvm/llvm-project/issues/105427>`__)
- P2985R0: A type trait for detecting virtual base classes (`Github <https://github.com/llvm/llvm-project/issues/105432>`__)
- ``std::jthread`` and ``<stop_token>`` are not guarded behind ``-fexperimental-library`` anymore
@@ -77,6 +78,10 @@ Deprecations and Removals
supported as an extension anymore, please migrate any code that uses e.g. ``std::vector<const T>`` to be
standards conforming.
+- ``<ccomplex>``, ``<cstdbool>``, and ``<ctgmath>`` are deprecated since C++17 as specified by the standard. They,
+ together with ``<ciso646>``, are removed in C++20, but libc++ still provides these headers as an extension and only
+ deprecates them.
+
Upcoming Deprecations and Removals
----------------------------------
diff --git a/libcxx/docs/Status/Cxx17Papers.csv b/libcxx/docs/Status/Cxx17Papers.csv
index 3b56807312d556..feb2c68f60cb46 100644
--- a/libcxx/docs/Status/Cxx17Papers.csv
+++ b/libcxx/docs/Status/Cxx17Papers.csv
@@ -43,7 +43,7 @@
"","","","","",""
"`P0032R3 <https://wg21.link/P0032R3>`__","Homogeneous interface for variant, any and optional","2016-06 (Oulu)","|Complete|","4.0",""
"`P0040R3 <https://wg21.link/P0040R3>`__","Extending memory management tools","2016-06 (Oulu)","|Complete|","4.0",""
-"`P0063R3 <https://wg21.link/P0063R3>`__","C++17 should refer to C11 instead of C99","2016-06 (Oulu)","|Complete|","7.0",""
+"`P0063R3 <https://wg21.link/P0063R3>`__","C++17 should refer to C11 instead of C99","2016-06 (Oulu)","|Complete|","7.0","``<ccomplex>``, ``<cstdbool>``, and ``<ctgmath>`` are deprecated since LLVM 20."
"`P0067R3 <https://wg21.link/P0067R3>`__","Elementary string conversions","2016-06 (Oulu)","|Nothing To Do|","n/a","Resolved by `P0067R5 <https://wg21.link/P0067R5>`__"
"`P0083R3 <https://wg21.link/P0083R3>`__","Splicing Maps and Sets","2016-06 (Oulu)","|Complete|","8.0",""
"`P0084R2 <https://wg21.link/P0084R2>`__","Emplace Return Type","2016-06 (Oulu)","|Complete|","4.0",""
diff --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv
index cc75d28f14aac2..daa611ccd6fded 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -34,7 +34,7 @@
"`P0528R3 <https://wg21.link/P0528R3>`__","The Curious Case of Padding Bits, Featuring Atomic Compare-and-Exchange","2018-06 (Rapperswil)","","",""
"`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"
"`P0556R3 <https://wg21.link/P0556R3>`__","Integral power-of-2 operations","2018-06 (Rapperswil)","|Complete|","9.0",""
-"`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."
+"`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"
"`P0646R1 <https://wg21.link/P0646R1>`__","Improving the Return Value of Erase-Like Algorithms","2018-06 (Rapperswil)","|Complete|","10.0",""
"`P0722R3 <https://wg21.link/P0722R3>`__","Efficient sized delete for variable sized classes","2018-06 (Rapperswil)","|Complete|","9.0",""
"`P0758R1 <https://wg21.link/P0758R1>`__","Implicit conversion traits and utility functions","2018-06 (Rapperswil)","|Complete|","",""
diff --git a/libcxx/include/ccomplex b/libcxx/include/ccomplex
index 94d2c8d7d003d4..e498e06cad20a0 100644
--- a/libcxx/include/ccomplex
+++ b/libcxx/include/ccomplex
@@ -23,4 +23,17 @@
# pragma GCC system_header
#endif
+#if _LIBCPP_STD_VER >= 17
+# if _LIBCPP_STD_VER >= 20
+# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED_("removed in C++20")
+# else
+# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED
+# endif
+
+using __standard_header_ccomplex _DEPRECATION_ANNOTATION = void;
+using __use_standard_header_ccomplex = __standard_header_ccomplex;
+
+# undef _DEPRECATION_ANNOTATION
+#endif
+
#endif // _LIBCPP_CCOMPLEX
diff --git a/libcxx/include/ciso646 b/libcxx/include/ciso646
index 1d859f08fac572..4fd409ae9c6666 100644
--- a/libcxx/include/ciso646
+++ b/libcxx/include/ciso646
@@ -21,4 +21,9 @@
# pragma GCC system_header
#endif
+#if _LIBCPP_STD_VER >= 20
+using __standard_header_ciso646 _LIBCPP_DEPRECATED_("removed in C++20") = void;
+using __use_standard_header_ciso646 = __standard_header_ciso646;
+#endif
+
#endif // _LIBCPP_CISO646
diff --git a/libcxx/include/cstdbool b/libcxx/include/cstdbool
index ef731c021a4ab8..decd9ee6e9cece 100644
--- a/libcxx/include/cstdbool
+++ b/libcxx/include/cstdbool
@@ -28,4 +28,17 @@ Macros:
#undef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
+#if _LIBCPP_STD_VER >= 17
+# if _LIBCPP_STD_VER >= 20
+# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED_("removed in C++20")
+# else
+# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED
+# endif
+
+using __standard_header_cstdbool _DEPRECATION_ANNOTATION = void;
+using __use_standard_header_cstdbool = __standard_header_cstdbool;
+
+# undef _DEPRECATION_ANNOTATION
+#endif
+
#endif // _LIBCPP_CSTDBOOL
diff --git a/libcxx/include/ctgmath b/libcxx/include/ctgmath
index 6237979be4906c..370470576bd3d7 100644
--- a/libcxx/include/ctgmath
+++ b/libcxx/include/ctgmath
@@ -25,4 +25,17 @@
# pragma GCC system_header
#endif
+#if _LIBCPP_STD_VER >= 17
+# if _LIBCPP_STD_VER >= 20
+# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED_("removed in C++20")
+# else
+# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED
+# endif
+
+using __standard_header_ctgmath _DEPRECATION_ANNOTATION = void;
+using __use_standard_header_ctgmath = __standard_header_ctgmath;
+
+# undef _DEPRECATION_ANNOTATION
+#endif
+
#endif // _LIBCPP_CTGMATH
diff --git a/libcxx/test/std/depr/depr.c.headers/ciso646.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/ciso646.compile.pass.cpp
index 4dff57f84f202c..764f4d02f44f44 100644
--- a/libcxx/test/std/depr/depr.c.headers/ciso646.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/ciso646.compile.pass.cpp
@@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//
-// <ciso646>
+// <ciso646> // removed in C++20, but still provided by libc++ as an extension
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
#include <ciso646>
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
new file mode 100644
index 00000000000000..e012b5fd5d28ba
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <ccomplex>
+
+// check that <ccomplex> is deprecated in C++17 and removed in C++20
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 20
+# include <ccomplex> // expected-warning {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
+#else
+# include <ccomplex> // expected-warning {{'__standard_header_ccomplex' is deprecated}}
+#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
new file mode 100644
index 00000000000000..2f84fd13b96698
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <ciso646>
+
+// check that <ciso646> is removed in C++20
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+#include "test_macros.h"
+
+#include <ciso646> // expected-warning {{'__standard_header_ciso646' is deprecated: removed in C++20}}
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
new file mode 100644
index 00000000000000..99073ce0c9d091
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdbool>
+
+// check that <cstdbool> is deprecated in C++17 and removed in C++20
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 20
+# include <cstdbool> // expected-warning {{'__standard_header_cstdbool' is deprecated: removed in C++20}}
+#else
+# include <cstdbool> // expected-warning {{'__standard_header_cstdbool' is deprecated}}
+#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
new file mode 100644
index 00000000000000..f2b77f2b0c7905
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <ctgmath>
+
+// check that <ctgmath> is deprecated in C++17 and removed in C++20
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 20
+# include <ctgmath> // expected-warning {{'__standard_header_ctgmath' is deprecated: removed in C++20}}
+#else
+# include <ctgmath> // expected-warning {{'__standard_header_ctgmath' is deprecated}}
+#endif
diff --git a/libcxx/test/std/language.support/support.runtime/cstdbool.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdbool.pass.cpp
index 1d0e9b06a43d2e..9a35eea507c40a 100644
--- a/libcxx/test/std/language.support/support.runtime/cstdbool.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/cstdbool.pass.cpp
@@ -6,7 +6,9 @@
//
//===----------------------------------------------------------------------===//
-// test <cstdbool>
+// test <cstdbool> // deprecated in C++17, removed in C++20, but still provided by libc++ as an extension
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
#include <cstdbool>
diff --git a/libcxx/test/std/numerics/c.math/ctgmath.pass.cpp b/libcxx/test/std/numerics/c.math/ctgmath.pass.cpp
index 2c8d054fbc527d..2e4679980577a9 100644
--- a/libcxx/test/std/numerics/c.math/ctgmath.pass.cpp
+++ b/libcxx/test/std/numerics/c.math/ctgmath.pass.cpp
@@ -6,7 +6,9 @@
//
//===----------------------------------------------------------------------===//
-// <ctgmath>
+// <ctgmath> // deprecated in C++17, removed in C++20, but still provided by libc++ as an extension
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
#include <ctgmath>
diff --git a/libcxx/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp b/libcxx/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp
index cc3f8cd6a9beb9..0ed116c6410639 100644
--- a/libcxx/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp
+++ b/libcxx/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp
@@ -6,7 +6,9 @@
//
//===----------------------------------------------------------------------===//
-// <ccomplex>
+// <ccomplex> // deprecated in C++17, removed in C++20, but still provided by libc++ as an extension
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
#include <ccomplex>
>From a7fdda0b0ff2c9012e14163f5f55dff8ba1dab86 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Wed, 9 Oct 2024 09:52:54 +0800
Subject: [PATCH 02/22] [libc++] Add missed `<cstdalign>` and `<stdalign.h>`
headers
---
libcxx/include/CMakeLists.txt | 2 +
libcxx/include/cstdalign | 35 ++++++++++++++++
libcxx/include/module.modulemap | 9 ++++
libcxx/include/stdalign.h | 42 +++++++++++++++++++
libcxx/test/libcxx/include_as_c.sh.cpp | 1 +
.../stdalign_h.compile.pass.cpp | 27 ++++++++++++
.../support.runtime/cstdalign.pass.cpp | 29 +++++++++++++
libcxx/utils/libcxx/header_information.py | 2 +-
.../gn/secondary/libcxx/include/BUILD.gn | 2 +
9 files changed, 148 insertions(+), 1 deletion(-)
create mode 100644 libcxx/include/cstdalign
create mode 100644 libcxx/include/stdalign.h
create mode 100644 libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
create mode 100644 libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 9bd1b41b8bfac4..118a5bd82fbe90 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -909,6 +909,7 @@ set(files
coroutine
csetjmp
csignal
+ cstdalign
cstdarg
cstdbool
cstddef
@@ -992,6 +993,7 @@ set(files
span
sstream
stack
+ stdalign.h
stdatomic.h
stdbool.h
stddef.h
diff --git a/libcxx/include/cstdalign b/libcxx/include/cstdalign
new file mode 100644
index 00000000000000..4ab973374130ce
--- /dev/null
+++ b/libcxx/include/cstdalign
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_CSTDALIGN
+#define _LIBCPP_CSTDALIGN
+
+/*
+ cstdalign synopsis
+
+Macros:
+
+ __alignas_is_defined
+ __alignof_is_defined
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#undef __alignas_is_defined
+#define __alignas_is_defined 1
+
+#undef __alignof_is_defined
+#define __alignof_is_defined 1
+
+#endif // _LIBCPP_CSTDALIGN
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index dee9b0b88b7948..f472335160bd84 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1103,6 +1103,11 @@ module std [system] {
export *
}
+ module cstdalign {
+ header "cstdalign"
+ export *
+ }
+
module cstdarg {
header "cstdarg"
export *
@@ -2187,6 +2192,10 @@ module std_math_h [system] {
header "math.h"
export *
}
+module std_stdalign_h [system] {
+ // <stdalign.h>'s __alignas_is_defined and __alignof_is_defined macros require textual inclusion.
+ textual header "stdalign.h"
+}
module std_stdatomic_h [system] {
header "stdatomic.h"
export *
diff --git a/libcxx/include/stdalign.h b/libcxx/include/stdalign.h
new file mode 100644
index 00000000000000..eb03f665151bd7
--- /dev/null
+++ b/libcxx/include/stdalign.h
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_STDALIGN_H
+#define _LIBCPP_STDALIGN_H
+
+/*
+ stdalign.h synopsis
+
+Macros:
+
+ __alignas_is_defined
+ __alignof_is_defined
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if __has_include_next(<stdalign.h>)
+# include_next <stdalign.h>
+#endif
+
+#ifdef __cplusplus
+# undef alignas
+# undef alignof
+# undef __alignas_is_defined
+# undef __alignof_is_defined
+# define __alignas_is_defined 1
+# define __alignof_is_defined 1
+#endif
+
+#endif // _LIBCPP_STDALIGN_H
diff --git a/libcxx/test/libcxx/include_as_c.sh.cpp b/libcxx/test/libcxx/include_as_c.sh.cpp
index c9f8dfd9a5a922..204b830462cf94 100644
--- a/libcxx/test/libcxx/include_as_c.sh.cpp
+++ b/libcxx/test/libcxx/include_as_c.sh.cpp
@@ -34,6 +34,7 @@
#endif
#include <math.h>
#include <setjmp.h>
+#include <stdalign.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
diff --git a/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
new file mode 100644
index 00000000000000..0f1cf487d60f6d
--- /dev/null
+++ b/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// test <stdalign.h>
+
+#include <stdalign.h>
+
+#ifndef __alignas_is_defined
+# error __alignas_is_defined not defined
+#endif
+
+#ifndef __alignof_is_defined
+# error __alignof_is_defined not defined
+#endif
+
+#ifdef alignas
+# error alignas should not be defined
+#endif
+
+#ifdef alignof
+# error alignof should not be defined
+#endif
diff --git a/libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp
new file mode 100644
index 00000000000000..6b64fa575de2a9
--- /dev/null
+++ b/libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// test <cstdalign>
+
+#include <cstdalign>
+
+#ifndef __alignas_is_defined
+# error __alignas_is_defined not defined
+#endif
+
+#ifndef __alignof_is_defined
+# error __alignof_is_defined not defined
+#endif
+
+#ifdef alignas
+# error alignas should not be defined
+#endif
+
+#ifdef alignof
+# error alignof should not be defined
+#endif
+
+int main(int, char**) { return 0; }
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index fd48b35a88b558..1431ef2bfdc5ca 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -202,7 +202,7 @@ def is_modulemap_header(header):
for header in toplevel_headers
if not header.endswith(".h") and is_public_header(header)
# These headers have been removed in C++20 so are never part of a module.
- and not header in ["ccomplex", "ciso646", "cstdbool", "ctgmath"]
+ and not header in ["ccomplex", "ciso646", "cstdalign", "cstdbool", "ctgmath"]
]
# The C headers used in the std and std.compat modules.
diff --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index d850a7f20952d9..12945c91fff9d0 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -981,6 +981,7 @@ if (current_toolchain == default_toolchain) {
"coroutine",
"csetjmp",
"csignal",
+ "cstdalign",
"cstdarg",
"cstdbool",
"cstddef",
@@ -1064,6 +1065,7 @@ if (current_toolchain == default_toolchain) {
"span",
"sstream",
"stack",
+ "stdalign.h",
"stdatomic.h",
"stdbool.h",
"stddef.h",
>From fdf253d82e5bb05d06676606795a827b06ab8745 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Wed, 9 Oct 2024 09:54:06 +0800
Subject: [PATCH 03/22] [libc++] Deprecate and remove `<cstdalign>`
---
libcxx/docs/ReleaseNotes/20.rst | 6 +++---
libcxx/docs/Status/Cxx17Papers.csv | 2 +-
libcxx/include/cstdalign | 13 ++++++++++++
.../depr.cpp.headers/cstdalign.verify.cpp | 21 +++++++++++++++++++
.../support.runtime/cstdalign.pass.cpp | 4 +++-
5 files changed, 41 insertions(+), 5 deletions(-)
create mode 100644 libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index 22f98bb1a2089a..a65367d9b62c81 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -78,9 +78,9 @@ Deprecations and Removals
supported as an extension anymore, please migrate any code that uses e.g. ``std::vector<const T>`` to be
standards conforming.
-- ``<ccomplex>``, ``<cstdbool>``, and ``<ctgmath>`` are deprecated since C++17 as specified by the standard. They,
- together with ``<ciso646>``, are removed in C++20, but libc++ still provides these headers as an extension and only
- deprecates them.
+- ``<ccomplex>``, ``<cstdalign>`` (previously missing), ``<cstdbool>``, and ``<ctgmath>`` are deprecated since C++17 as
+ specified by the standard. They, together with ``<ciso646>``, are removed in C++20, but libc++ still provides these
+ headers as an extension and only deprecates them.
Upcoming Deprecations and Removals
----------------------------------
diff --git a/libcxx/docs/Status/Cxx17Papers.csv b/libcxx/docs/Status/Cxx17Papers.csv
index feb2c68f60cb46..3058fd44c7250f 100644
--- a/libcxx/docs/Status/Cxx17Papers.csv
+++ b/libcxx/docs/Status/Cxx17Papers.csv
@@ -43,7 +43,7 @@
"","","","","",""
"`P0032R3 <https://wg21.link/P0032R3>`__","Homogeneous interface for variant, any and optional","2016-06 (Oulu)","|Complete|","4.0",""
"`P0040R3 <https://wg21.link/P0040R3>`__","Extending memory management tools","2016-06 (Oulu)","|Complete|","4.0",""
-"`P0063R3 <https://wg21.link/P0063R3>`__","C++17 should refer to C11 instead of C99","2016-06 (Oulu)","|Complete|","7.0","``<ccomplex>``, ``<cstdbool>``, and ``<ctgmath>`` are deprecated since LLVM 20."
+"`P0063R3 <https://wg21.link/P0063R3>`__","C++17 should refer to C11 instead of C99","2016-06 (Oulu)","|Complete|","7.0","``<ccomplex>``, ``<cstdalign>``, ``<cstdbool>``, and ``<ctgmath>`` are deprecated since LLVM 20."
"`P0067R3 <https://wg21.link/P0067R3>`__","Elementary string conversions","2016-06 (Oulu)","|Nothing To Do|","n/a","Resolved by `P0067R5 <https://wg21.link/P0067R5>`__"
"`P0083R3 <https://wg21.link/P0083R3>`__","Splicing Maps and Sets","2016-06 (Oulu)","|Complete|","8.0",""
"`P0084R2 <https://wg21.link/P0084R2>`__","Emplace Return Type","2016-06 (Oulu)","|Complete|","4.0",""
diff --git a/libcxx/include/cstdalign b/libcxx/include/cstdalign
index 4ab973374130ce..2d9187cdbfe8ac 100644
--- a/libcxx/include/cstdalign
+++ b/libcxx/include/cstdalign
@@ -32,4 +32,17 @@ Macros:
#undef __alignof_is_defined
#define __alignof_is_defined 1
+#if _LIBCPP_STD_VER >= 17
+# if _LIBCPP_STD_VER >= 20
+# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED_("removed in C++20")
+# else
+# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED
+# endif
+
+using __standard_header_cstdalign _DEPRECATION_ANNOTATION = void;
+using __use_standard_header_cstdalign = __standard_header_cstdalign;
+
+# undef _DEPRECATION_ANNOTATION
+#endif
+
#endif // _LIBCPP_CSTDALIGN
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
new file mode 100644
index 00000000000000..c73f183640a6e1
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// <cstdalign>
+
+// check that <cstdalign> is deprecated in C++17 and removed in C++20
+
+// UNSUPPORTED: c++03, c++11, c++14
+
+#include "test_macros.h"
+
+#if TEST_STD_VER >= 20
+# include <cstdalign> // expected-warning {{'__standard_header_cstdalign' is deprecated: removed in C++20}}
+#else
+# include <cstdalign> // expected-warning {{'__standard_header_cstdalign' is deprecated}}
+#endif
diff --git a/libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp
index 6b64fa575de2a9..186cd1e1c8bee8 100644
--- a/libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp
@@ -6,7 +6,9 @@
//
//===----------------------------------------------------------------------===//
-// test <cstdalign>
+// test <cstdalign> // deprecated in C++17, removed in C++20, but still provided by libc++ as an extension
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
#include <cstdalign>
>From 81ea61bdfb3e0f0e83fee4d006646f9f67111faa Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Wed, 9 Oct 2024 11:10:12 +0800
Subject: [PATCH 04/22] Try to fix undeprecation/deprecation verification
---
libcxx/test/libcxx/clang_modules_include.gen.py | 3 ++-
libcxx/test/libcxx/double_include.gen.py | 3 ++-
libcxx/test/libcxx/header_inclusions.gen.py | 3 ++-
libcxx/test/libcxx/libcpp_version.gen.py | 3 ++-
libcxx/test/libcxx/no_assert_include.gen.py | 3 ++-
libcxx/test/libcxx/system_reserved_names.gen.py | 3 ++-
.../test/std/depr/depr.cpp.headers/ccomplex.verify.cpp | 8 ++++++--
.../test/std/depr/depr.cpp.headers/ciso646.verify.cpp | 4 +++-
.../std/depr/depr.cpp.headers/cstdalign.verify.cpp | 8 ++++++--
.../test/std/depr/depr.cpp.headers/cstdbool.verify.cpp | 8 ++++++--
.../test/std/depr/depr.cpp.headers/ctgmath.verify.cpp | 10 ++++++++--
libcxx/utils/libcxx/header_information.py | 8 ++++++++
12 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/libcxx/test/libcxx/clang_modules_include.gen.py b/libcxx/test/libcxx/clang_modules_include.gen.py
index bc028f2a0809aa..e72dafbe65ecb0 100644
--- a/libcxx/test/libcxx/clang_modules_include.gen.py
+++ b/libcxx/test/libcxx/clang_modules_include.gen.py
@@ -17,7 +17,7 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, public_headers
+from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
for header in public_headers:
print(f"""\
@@ -41,6 +41,7 @@
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
{lit_header_restrictions.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#include <{header}>
""")
diff --git a/libcxx/test/libcxx/double_include.gen.py b/libcxx/test/libcxx/double_include.gen.py
index afc2947dbece94..35f8c53f46ae57 100644
--- a/libcxx/test/libcxx/double_include.gen.py
+++ b/libcxx/test/libcxx/double_include.gen.py
@@ -15,12 +15,13 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, public_headers
+from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
for header in public_headers:
print(f"""\
//--- {header}.sh.cpp
{lit_header_restrictions.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
// RUN: %{{cxx}} -c %s -o %t.first.o %{{flags}} %{{compile_flags}}
// RUN: %{{cxx}} -c %s -o %t.second.o -DWITH_MAIN %{{flags}} %{{compile_flags}}
diff --git a/libcxx/test/libcxx/header_inclusions.gen.py b/libcxx/test/libcxx/header_inclusions.gen.py
index 2ecc47cbb1891a..97b2e0c9a90a56 100644
--- a/libcxx/test/libcxx/header_inclusions.gen.py
+++ b/libcxx/test/libcxx/header_inclusions.gen.py
@@ -13,7 +13,7 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, public_headers, mandatory_inclusions
+from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers, mandatory_inclusions
for header in public_headers:
header_guard = lambda h: f"_LIBCPP_{h.upper().replace('.', '_').replace('/', '_')}"
@@ -37,6 +37,7 @@
print(f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#include <{header}>
{checks}
diff --git a/libcxx/test/libcxx/libcpp_version.gen.py b/libcxx/test/libcxx/libcpp_version.gen.py
index a9995295e21e4f..ddd88d6f4b9b07 100644
--- a/libcxx/test/libcxx/libcpp_version.gen.py
+++ b/libcxx/test/libcxx/libcpp_version.gen.py
@@ -12,12 +12,13 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, public_headers
+from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
for header in public_headers:
print(f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#include <{header}>
diff --git a/libcxx/test/libcxx/no_assert_include.gen.py b/libcxx/test/libcxx/no_assert_include.gen.py
index 67ab98603ca8fd..a8723744b734ab 100644
--- a/libcxx/test/libcxx/no_assert_include.gen.py
+++ b/libcxx/test/libcxx/no_assert_include.gen.py
@@ -13,7 +13,7 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, public_headers
+from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
for header in public_headers:
if header == 'cassert':
@@ -22,6 +22,7 @@
print(f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#include <{header}>
diff --git a/libcxx/test/libcxx/system_reserved_names.gen.py b/libcxx/test/libcxx/system_reserved_names.gen.py
index e29e7a2cdd6144..35eeaa8c7e040c 100644
--- a/libcxx/test/libcxx/system_reserved_names.gen.py
+++ b/libcxx/test/libcxx/system_reserved_names.gen.py
@@ -14,13 +14,14 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, public_headers
+from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
for header in public_headers:
print(
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#define SYSTEM_RESERVED_NAME This name should not be used in libc++
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
index e012b5fd5d28ba..34b7ad69f86460 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
@@ -15,7 +15,11 @@
#include "test_macros.h"
#if TEST_STD_VER >= 20
-# include <ccomplex> // expected-warning {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
+// expected-warning {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
+
+# include <ccomplex>
#else
-# include <ccomplex> // expected-warning {{'__standard_header_ccomplex' is deprecated}}
+// expected-warning {{'__standard_header_ccomplex' is deprecated}}
+
+# include <ccomplex>
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
index 2f84fd13b96698..65ae794530bdc1 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
@@ -14,4 +14,6 @@
#include "test_macros.h"
-#include <ciso646> // expected-warning {{'__standard_header_ciso646' is deprecated: removed in C++20}}
+// expected-warning {{'__standard_header_ciso646' is deprecated: removed in C++20}}
+
+#include <ciso646>
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
index c73f183640a6e1..04d842ea5abf05 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
@@ -15,7 +15,11 @@
#include "test_macros.h"
#if TEST_STD_VER >= 20
-# include <cstdalign> // expected-warning {{'__standard_header_cstdalign' is deprecated: removed in C++20}}
+// expected-warning {{'__standard_header_cstdalign' is deprecated: removed in C++20}}
+
+# include <cstdalign>
#else
-# include <cstdalign> // expected-warning {{'__standard_header_cstdalign' is deprecated}}
+// expected-warning {{'__standard_header_cstdalign' is deprecated}}
+
+# include <cstdalign>
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
index 99073ce0c9d091..304592009b71d6 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
@@ -15,7 +15,11 @@
#include "test_macros.h"
#if TEST_STD_VER >= 20
-# include <cstdbool> // expected-warning {{'__standard_header_cstdbool' is deprecated: removed in C++20}}
+// expected-warning {{'__standard_header_cstdbool' is deprecated: removed in C++20}}
+
+# include <cstdbool>
#else
-# include <cstdbool> // expected-warning {{'__standard_header_cstdbool' is deprecated}}
+// expected-warning {{'__standard_header_cstdbool' is deprecated}}
+
+# include <cstdbool>
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
index f2b77f2b0c7905..7f47ffa683bf42 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
@@ -15,7 +15,13 @@
#include "test_macros.h"
#if TEST_STD_VER >= 20
-# include <ctgmath> // expected-warning {{'__standard_header_ctgmath' is deprecated: removed in C++20}}
+// expected-warning {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
+// expected-warning {{'__standard_header_ctgmath' is deprecated: removed in C++20}}
+
+# include <ctgmath>
#else
-# include <ctgmath> // expected-warning {{'__standard_header_ctgmath' is deprecated}}
+// expected-warning {{'__standard_header_ccomplex' is deprecated}}
+// expected-warning {{'__standard_header_ctgmath' is deprecated}}
+
+# include <ctgmath>
#endif
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 1431ef2bfdc5ca..1279b09bb32961 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -70,6 +70,14 @@
"wchar.h": "// UNSUPPORTED: no-wide-characters",
"wctype.h": "// UNSUPPORTED: no-wide-characters",
}
+# Undeprecate headers that are deprecated in C++17 and removed in C++20.
+lit_header_undeprecations = {
+ "ccomplex": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "ciso646": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "cstdalign": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "cstdbool": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "ctgmath": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+}
# This table was produced manually, by grepping the TeX source of the Standard's
# library clauses for the string "#include". Each header's synopsis contains
>From 887574ce5a49a452ca89804d90c8ad72cc2e365c Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Wed, 9 Oct 2024 11:52:58 +0800
Subject: [PATCH 05/22] Try to fix generating scripts
---
.../test/libcxx/clang_modules_include.gen.py | 14 +++++---
libcxx/test/libcxx/double_include.gen.py | 14 +++++---
libcxx/test/libcxx/header_inclusions.gen.py | 36 +++++++++++--------
libcxx/test/libcxx/libcpp_version.gen.py | 14 +++++---
libcxx/test/libcxx/no_assert_include.gen.py | 5 +--
.../test/libcxx/system_reserved_names.gen.py | 9 +++--
libcxx/utils/libcxx/header_information.py | 17 ++++-----
7 files changed, 71 insertions(+), 38 deletions(-)
diff --git a/libcxx/test/libcxx/clang_modules_include.gen.py b/libcxx/test/libcxx/clang_modules_include.gen.py
index e72dafbe65ecb0..44afe603a19a3f 100644
--- a/libcxx/test/libcxx/clang_modules_include.gen.py
+++ b/libcxx/test/libcxx/clang_modules_include.gen.py
@@ -17,10 +17,15 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
+from libcxx.header_information import (
+ lit_header_restrictions,
+ header_undeprecations,
+ public_headers,
+)
for header in public_headers:
- print(f"""\
+ print(
+ f"""\
//--- {header}.compile.pass.cpp
// RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only
@@ -41,10 +46,11 @@
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
{lit_header_restrictions.get(header, '')}
-{lit_header_undeprecations.get(header, '')}
+{header_undeprecations.get(header, '')}
#include <{header}>
-""")
+"""
+ )
print(
f"""\
diff --git a/libcxx/test/libcxx/double_include.gen.py b/libcxx/test/libcxx/double_include.gen.py
index 35f8c53f46ae57..eabb04a5d1bed8 100644
--- a/libcxx/test/libcxx/double_include.gen.py
+++ b/libcxx/test/libcxx/double_include.gen.py
@@ -15,13 +15,18 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
+from libcxx.header_information import (
+ lit_header_restrictions,
+ header_undeprecations,
+ public_headers,
+)
for header in public_headers:
- print(f"""\
+ print(
+ f"""\
//--- {header}.sh.cpp
{lit_header_restrictions.get(header, '')}
-{lit_header_undeprecations.get(header, '')}
+{header_undeprecations.get(header, '')}
// RUN: %{{cxx}} -c %s -o %t.first.o %{{flags}} %{{compile_flags}}
// RUN: %{{cxx}} -c %s -o %t.second.o -DWITH_MAIN %{{flags}} %{{compile_flags}}
@@ -33,4 +38,5 @@
#if defined(WITH_MAIN)
int main(int, char**) {{ return 0; }}
#endif
-""")
+"""
+ )
diff --git a/libcxx/test/libcxx/header_inclusions.gen.py b/libcxx/test/libcxx/header_inclusions.gen.py
index 97b2e0c9a90a56..d0c68654eb8135 100644
--- a/libcxx/test/libcxx/header_inclusions.gen.py
+++ b/libcxx/test/libcxx/header_inclusions.gen.py
@@ -12,33 +12,41 @@
# RUN: %{python} %s %{libcxx-dir}/utils
import sys
+
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers, mandatory_inclusions
+from libcxx.header_information import (
+ lit_header_restrictions,
+ header_undeprecations,
+ public_headers,
+ mandatory_inclusions,
+)
for header in public_headers:
- header_guard = lambda h: f"_LIBCPP_{h.upper().replace('.', '_').replace('/', '_')}"
+ header_guard = lambda h: f"_LIBCPP_{h.upper().replace('.', '_').replace('/', '_')}"
- # <cassert> has no header guards
- if header == 'cassert':
- checks = ''
- else:
- checks = f'''
+ # <cassert> has no header guards
+ if header == 'cassert':
+ checks = ""
+ else:
+ checks = f"""
#ifndef {header_guard(header)}
# error <{header}> was expected to define a header guard {header_guard(header)}
#endif
-'''
- for includee in mandatory_inclusions.get(header, []):
- checks += f'''
+"""
+ for includee in mandatory_inclusions.get(header, []):
+ checks += f"""
#ifndef {header_guard(includee)}
# error <{header}> was expected to include <{includee}>
#endif
-'''
+"""
- print(f"""\
+ print(
+ f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
-{lit_header_undeprecations.get(header, '')}
+{header_undeprecations.get(header, '')}
#include <{header}>
{checks}
-""")
+"""
+ )
diff --git a/libcxx/test/libcxx/libcpp_version.gen.py b/libcxx/test/libcxx/libcpp_version.gen.py
index ddd88d6f4b9b07..fd9eca433b7667 100644
--- a/libcxx/test/libcxx/libcpp_version.gen.py
+++ b/libcxx/test/libcxx/libcpp_version.gen.py
@@ -12,17 +12,23 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
+from libcxx.header_information import (
+ lit_header_restrictions,
+ header_undeprecations,
+ public_headers,
+)
for header in public_headers:
- print(f"""\
+ print(
+ f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
-{lit_header_undeprecations.get(header, '')}
+{header_undeprecations.get(header, '')}
#include <{header}>
#ifndef _LIBCPP_VERSION
# error <{header}> does not seem to define _LIBCPP_VERSION
#endif
-""")
+"""
+ )
diff --git a/libcxx/test/libcxx/no_assert_include.gen.py b/libcxx/test/libcxx/no_assert_include.gen.py
index a8723744b734ab..fa7ed7b1e271c5 100644
--- a/libcxx/test/libcxx/no_assert_include.gen.py
+++ b/libcxx/test/libcxx/no_assert_include.gen.py
@@ -12,8 +12,9 @@
# RUN: %{python} %s %{libcxx-dir}/utils
import sys
+
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
+from libcxx.header_information import lit_header_restrictions, header_undeprecations, public_headers
for header in public_headers:
if header == 'cassert':
@@ -22,7 +23,7 @@
print(f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
-{lit_header_undeprecations.get(header, '')}
+{header_undeprecations.get(header, '')}
#include <{header}>
diff --git a/libcxx/test/libcxx/system_reserved_names.gen.py b/libcxx/test/libcxx/system_reserved_names.gen.py
index 35eeaa8c7e040c..6386781864fc73 100644
--- a/libcxx/test/libcxx/system_reserved_names.gen.py
+++ b/libcxx/test/libcxx/system_reserved_names.gen.py
@@ -13,15 +13,20 @@
# RUN: %{python} %s %{libcxx-dir}/utils
import sys
+
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
+from libcxx.header_information import (
+ lit_header_restrictions,
+ header_undeprecations,
+ public_headers,
+)
for header in public_headers:
print(
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
-{lit_header_undeprecations.get(header, '')}
+{header_undeprecations.get(header, '')}
#define SYSTEM_RESERVED_NAME This name should not be used in libc++
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 1279b09bb32961..a9da82f4597be2 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -32,6 +32,15 @@
"syncstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
}
+# Undeprecate headers that are deprecated in C++17 and removed in C++20.
+header_undeprecations = {
+ "ccomplex": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "ciso646": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "cstdalign": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "cstdbool": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "ctgmath": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+}
+
lit_header_restrictions = {
"barrier": "// UNSUPPORTED: no-threads, c++03, c++11, c++14, c++17",
"clocale": "// UNSUPPORTED: no-localization",
@@ -70,14 +79,6 @@
"wchar.h": "// UNSUPPORTED: no-wide-characters",
"wctype.h": "// UNSUPPORTED: no-wide-characters",
}
-# Undeprecate headers that are deprecated in C++17 and removed in C++20.
-lit_header_undeprecations = {
- "ccomplex": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
- "ciso646": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
- "cstdalign": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
- "cstdbool": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
- "ctgmath": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
-}
# This table was produced manually, by grepping the TeX source of the Standard's
# library clauses for the string "#include". Each header's synopsis contains
>From 18c7e9d0581c05efc35a1e4a8eb35050c0f3eb22 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Wed, 9 Oct 2024 13:29:32 +0800
Subject: [PATCH 06/22] More formatting
---
libcxx/test/libcxx/header_inclusions.gen.py | 2 +-
libcxx/test/libcxx/no_assert_include.gen.py | 16 +++++++++++-----
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/libcxx/test/libcxx/header_inclusions.gen.py b/libcxx/test/libcxx/header_inclusions.gen.py
index d0c68654eb8135..11d6e972f23e30 100644
--- a/libcxx/test/libcxx/header_inclusions.gen.py
+++ b/libcxx/test/libcxx/header_inclusions.gen.py
@@ -25,7 +25,7 @@
header_guard = lambda h: f"_LIBCPP_{h.upper().replace('.', '_').replace('/', '_')}"
# <cassert> has no header guards
- if header == 'cassert':
+ if header == "cassert":
checks = ""
else:
checks = f"""
diff --git a/libcxx/test/libcxx/no_assert_include.gen.py b/libcxx/test/libcxx/no_assert_include.gen.py
index fa7ed7b1e271c5..320949ef327392 100644
--- a/libcxx/test/libcxx/no_assert_include.gen.py
+++ b/libcxx/test/libcxx/no_assert_include.gen.py
@@ -14,13 +14,18 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, header_undeprecations, public_headers
+from libcxx.header_information import (
+ lit_header_restrictions,
+ header_undeprecations,
+ public_headers,
+)
for header in public_headers:
- if header == 'cassert':
- continue
+ if header == "cassert":
+ continue
- print(f"""\
+ print(
+ f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
{header_undeprecations.get(header, '')}
@@ -30,4 +35,5 @@
#ifdef assert
# error "Do not include cassert or assert.h in standard header files"
#endif
-""")
+"""
+ )
>From b68ee904676d1b2e30fd75fdc8a7ac48441e54d1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Wed, 9 Oct 2024 14:04:01 +0800
Subject: [PATCH 07/22] Reorganize inclusion per P0063R3 to reduce deprecation
warnings
---
libcxx/include/complex.h | 6 +++++-
libcxx/include/ctgmath | 7 ++++++-
libcxx/include/tgmath.h | 7 ++++++-
libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp | 2 --
4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/libcxx/include/complex.h b/libcxx/include/complex.h
index a3da21c843f365..7e264abe963efe 100644
--- a/libcxx/include/complex.h
+++ b/libcxx/include/complex.h
@@ -24,7 +24,11 @@
#endif
#ifdef __cplusplus
-# include <ccomplex>
+# if _LIBCPP_STD_VER >= 17
+# include <complex>
+# else
+# include <ccomplex>
+# endif
#elif __has_include_next(<complex.h>)
# include_next <complex.h>
#endif
diff --git a/libcxx/include/ctgmath b/libcxx/include/ctgmath
index 370470576bd3d7..ebcd9c32b0e38a 100644
--- a/libcxx/include/ctgmath
+++ b/libcxx/include/ctgmath
@@ -18,7 +18,12 @@
*/
-#include <ccomplex>
+#if _LIBCPP_STD_VER >= 17
+# include <complex>
+#else
+# include <ccomplex>
+#endif
+
#include <cmath>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/tgmath.h b/libcxx/include/tgmath.h
index e6f0a4ab2611fa..9249b8467c8507 100644
--- a/libcxx/include/tgmath.h
+++ b/libcxx/include/tgmath.h
@@ -24,7 +24,12 @@
#endif
#ifdef __cplusplus
-# include <ctgmath>
+# if _LIBCPP_STD_VER >= 17
+# include <complex>
+# include <cmath>
+# else
+# include <ctgmath>
+# endif
#else
# if __has_include_next(<tgmath.h>)
# include_next <tgmath.h>
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
index 7f47ffa683bf42..6c1f64489caaeb 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
@@ -15,12 +15,10 @@
#include "test_macros.h"
#if TEST_STD_VER >= 20
-// expected-warning {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
// expected-warning {{'__standard_header_ctgmath' is deprecated: removed in C++20}}
# include <ctgmath>
#else
-// expected-warning {{'__standard_header_ccomplex' is deprecated}}
// expected-warning {{'__standard_header_ctgmath' is deprecated}}
# include <ctgmath>
>From 70d91b749b7bea0e6348d3bfd7d4c5201b04fd1f Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Thu, 10 Oct 2024 17:22:32 +0800
Subject: [PATCH 08/22] Delete unneeded `<stdalign.h>`
---
libcxx/include/stdalign.h | 42 ---------------------------------------
1 file changed, 42 deletions(-)
delete mode 100644 libcxx/include/stdalign.h
diff --git a/libcxx/include/stdalign.h b/libcxx/include/stdalign.h
deleted file mode 100644
index eb03f665151bd7..00000000000000
--- a/libcxx/include/stdalign.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_STDALIGN_H
-#define _LIBCPP_STDALIGN_H
-
-/*
- stdalign.h synopsis
-
-Macros:
-
- __alignas_is_defined
- __alignof_is_defined
-
-*/
-
-#include <__config>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-#if __has_include_next(<stdalign.h>)
-# include_next <stdalign.h>
-#endif
-
-#ifdef __cplusplus
-# undef alignas
-# undef alignof
-# undef __alignas_is_defined
-# undef __alignof_is_defined
-# define __alignas_is_defined 1
-# define __alignof_is_defined 1
-#endif
-
-#endif // _LIBCPP_STDALIGN_H
>From 8360774a7f5f716721b578067345c318b64d3034 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Thu, 10 Oct 2024 17:23:08 +0800
Subject: [PATCH 09/22] Escape hatch for `<ciso646>`
---
libcxx/docs/ReleaseNotes/20.rst | 3 ++-
libcxx/include/ciso646 | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index a65367d9b62c81..c67a4526dc97ef 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -80,7 +80,8 @@ Deprecations and Removals
- ``<ccomplex>``, ``<cstdalign>`` (previously missing), ``<cstdbool>``, and ``<ctgmath>`` are deprecated since C++17 as
specified by the standard. They, together with ``<ciso646>``, are removed in C++20, but libc++ still provides these
- headers as an extension and only deprecates them.
+ headers as an extension and only deprecates them. The ``_LIBCPP_ENABLE_REMOVED_CISO646`` macro can be defined to
+ suppress deprecation for ``<ciso646>``.
Upcoming Deprecations and Removals
----------------------------------
diff --git a/libcxx/include/ciso646 b/libcxx/include/ciso646
index 4fd409ae9c6666..5298d41dc26667 100644
--- a/libcxx/include/ciso646
+++ b/libcxx/include/ciso646
@@ -21,7 +21,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER >= 20
+#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_ENABLE_REMOVED_CISO646)
using __standard_header_ciso646 _LIBCPP_DEPRECATED_("removed in C++20") = void;
using __use_standard_header_ciso646 = __standard_header_ciso646;
#endif
>From 9c4337c026cebb273d11491653703b5b8c2a85d1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Thu, 10 Oct 2024 17:23:38 +0800
Subject: [PATCH 10/22] Fix some errors for `<ctgmath>` and `<tgmath.h>`
---
libcxx/include/ctgmath | 2 ++
libcxx/include/tgmath.h | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/ctgmath b/libcxx/include/ctgmath
index ebcd9c32b0e38a..75e1326a424d4b 100644
--- a/libcxx/include/ctgmath
+++ b/libcxx/include/ctgmath
@@ -18,6 +18,8 @@
*/
+#include <__config>
+
#if _LIBCPP_STD_VER >= 17
# include <complex>
#else
diff --git a/libcxx/include/tgmath.h b/libcxx/include/tgmath.h
index 9249b8467c8507..49b98a530cd659 100644
--- a/libcxx/include/tgmath.h
+++ b/libcxx/include/tgmath.h
@@ -25,8 +25,8 @@
#ifdef __cplusplus
# if _LIBCPP_STD_VER >= 17
-# include <complex>
# include <cmath>
+# include <complex>
# else
# include <ctgmath>
# endif
>From 1299c8915a81b1f5a09243ce189eab14ed50a151 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Thu, 10 Oct 2024 17:31:54 +0800
Subject: [PATCH 11/22] Revert "Delete unneeded `<stdalign.h>`"
This reverts commit 70d91b749b7bea0e6348d3bfd7d4c5201b04fd1f.
---
libcxx/include/stdalign.h | 42 +++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 libcxx/include/stdalign.h
diff --git a/libcxx/include/stdalign.h b/libcxx/include/stdalign.h
new file mode 100644
index 00000000000000..eb03f665151bd7
--- /dev/null
+++ b/libcxx/include/stdalign.h
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_STDALIGN_H
+#define _LIBCPP_STDALIGN_H
+
+/*
+ stdalign.h synopsis
+
+Macros:
+
+ __alignas_is_defined
+ __alignof_is_defined
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if __has_include_next(<stdalign.h>)
+# include_next <stdalign.h>
+#endif
+
+#ifdef __cplusplus
+# undef alignas
+# undef alignof
+# undef __alignas_is_defined
+# undef __alignof_is_defined
+# define __alignas_is_defined 1
+# define __alignof_is_defined 1
+#endif
+
+#endif // _LIBCPP_STDALIGN_H
>From ca47422b29c5b4d12658733363d1bd019d3011bf Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 14 Oct 2024 09:29:45 +0800
Subject: [PATCH 12/22] Adjust transitive_includes files
---
libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx23.csv | 1 -
libcxx/test/libcxx/transitive_includes/cxx26.csv | 1 -
4 files changed, 4 deletions(-)
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index 0bee6e9beb7af1..be981cf9328902 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -458,7 +458,6 @@ ctgmath array
ctgmath atomic
ctgmath bit
ctgmath bitset
-ctgmath ccomplex
ctgmath cctype
ctgmath cerrno
ctgmath climits
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 026c26f3bd9819..d29ee85ac59760 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -446,7 +446,6 @@ ctgmath array
ctgmath atomic
ctgmath bit
ctgmath bitset
-ctgmath ccomplex
ctgmath cctype
ctgmath cerrno
ctgmath climits
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 861fd2bb9ba98f..399b6ca8eee3a6 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -239,7 +239,6 @@ coroutine limits
coroutine version
cstddef version
ctgmath bitset
-ctgmath ccomplex
ctgmath cctype
ctgmath cerrno
ctgmath climits
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index a31139f1ee8565..35846db56ae3e1 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -239,7 +239,6 @@ coroutine limits
coroutine version
cstddef version
ctgmath bitset
-ctgmath ccomplex
ctgmath cctype
ctgmath cerrno
ctgmath climits
>From 7d05faa0f2bbb8dcfb83b07af2b006f69cae9e30 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 14 Oct 2024 10:52:46 +0800
Subject: [PATCH 13/22] Try to fix deprecation suppressing/verification
---
.../depr/depr.cpp.headers/ccomplex.verify.cpp | 6 ++----
.../depr/depr.cpp.headers/ciso646.verify.cpp | 3 +--
.../depr/depr.cpp.headers/cstdalign.verify.cpp | 6 ++----
.../depr/depr.cpp.headers/cstdbool.verify.cpp | 6 ++----
.../depr/depr.cpp.headers/ctgmath.verify.cpp | 6 ++----
libcxx/utils/libcxx/header_information.py | 18 +++++++++++++-----
6 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
index 34b7ad69f86460..d2562125bcb136 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
@@ -15,11 +15,9 @@
#include "test_macros.h"
#if TEST_STD_VER >= 20
-// expected-warning {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
-
# include <ccomplex>
+// expected-warning {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
#else
-// expected-warning {{'__standard_header_ccomplex' is deprecated}}
-
# include <ccomplex>
+// expected-warning {{'__standard_header_ccomplex' is deprecated}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
index 65ae794530bdc1..d28b2adc16fa3e 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
@@ -14,6 +14,5 @@
#include "test_macros.h"
-// expected-warning {{'__standard_header_ciso646' is deprecated: removed in C++20}}
-
#include <ciso646>
+// expected-warning {{'__standard_header_ciso646' is deprecated: removed in C++20}}
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
index 04d842ea5abf05..d8d8ea5a9a18f9 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
@@ -15,11 +15,9 @@
#include "test_macros.h"
#if TEST_STD_VER >= 20
-// expected-warning {{'__standard_header_cstdalign' is deprecated: removed in C++20}}
-
# include <cstdalign>
+// expected-warning {{'__standard_header_cstdalign' is deprecated: removed in C++20}}
#else
-// expected-warning {{'__standard_header_cstdalign' is deprecated}}
-
# include <cstdalign>
+// expected-warning {{'__standard_header_cstdalign' is deprecated}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
index 304592009b71d6..8420b3541cad16 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
@@ -15,11 +15,9 @@
#include "test_macros.h"
#if TEST_STD_VER >= 20
-// expected-warning {{'__standard_header_cstdbool' is deprecated: removed in C++20}}
-
# include <cstdbool>
+// expected-warning {{'__standard_header_cstdbool' is deprecated: removed in C++20}}
#else
-// expected-warning {{'__standard_header_cstdbool' is deprecated}}
-
# include <cstdbool>
+// expected-warning {{'__standard_header_cstdbool' is deprecated}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
index 6c1f64489caaeb..3dcb239b48d9e4 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
@@ -15,11 +15,9 @@
#include "test_macros.h"
#if TEST_STD_VER >= 20
-// expected-warning {{'__standard_header_ctgmath' is deprecated: removed in C++20}}
-
# include <ctgmath>
+// expected-warning {{'__standard_header_ctgmath' is deprecated: removed in C++20}}
#else
-// expected-warning {{'__standard_header_ctgmath' is deprecated}}
-
# include <ctgmath>
+// expected-warning {{'__standard_header_ctgmath' is deprecated}}
#endif
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index ae2b561081a549..304ad17b873e89 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -34,11 +34,19 @@
# Undeprecate headers that are deprecated in C++17 and removed in C++20.
header_undeprecations = {
- "ccomplex": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
- "ciso646": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
- "cstdalign": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
- "cstdbool": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
- "ctgmath": "#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "ccomplex": '''#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
+#endif''',
+ "ciso646": "#define _LIBCPP_ENABLE_REMOVED_CISO646",
+ "cstdalign": '''#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
+#endif''',
+ "cstdbool": '''#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
+#endif''',
+ "ctgmath": '''#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
+#endif''',
}
lit_header_restrictions = {
>From 53da492263ebbf56faba764214e9ac17508cb594 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 14 Oct 2024 11:51:05 +0800
Subject: [PATCH 14/22] Try to fix deprecation suppressing/verification, take 2
---
.../depr/depr.cpp.headers/ccomplex.verify.cpp | 8 ++++----
.../std/depr/depr.cpp.headers/ciso646.verify.cpp | 2 +-
.../depr/depr.cpp.headers/cstdalign.verify.cpp | 8 ++++----
.../depr/depr.cpp.headers/cstdbool.verify.cpp | 8 ++++----
.../std/depr/depr.cpp.headers/ctgmath.verify.cpp | 8 ++++----
libcxx/utils/libcxx/header_information.py | 16 ++++++++--------
6 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
index d2562125bcb136..a868f13ebfb00b 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
@@ -14,10 +14,10 @@
#include "test_macros.h"
+#include <ccomplex>
+
#if TEST_STD_VER >= 20
-# include <ccomplex>
-// expected-warning {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
+// expected-warning at ccomplex:* {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
#else
-# include <ccomplex>
-// expected-warning {{'__standard_header_ccomplex' is deprecated}}
+// expected-warning at ccomplex:* {{'__standard_header_ccomplex' is deprecated}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
index d28b2adc16fa3e..1ba06cc555d919 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
@@ -15,4 +15,4 @@
#include "test_macros.h"
#include <ciso646>
-// expected-warning {{'__standard_header_ciso646' is deprecated: removed in C++20}}
+// expected-warning at ciso646:* {{'__standard_header_ciso646' is deprecated: removed in C++20}}
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
index d8d8ea5a9a18f9..c8a9599ed3ac2a 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
@@ -14,10 +14,10 @@
#include "test_macros.h"
+#include <cstdalign>
+
#if TEST_STD_VER >= 20
-# include <cstdalign>
-// expected-warning {{'__standard_header_cstdalign' is deprecated: removed in C++20}}
+// expected-warning at cstdalign:* {{'__standard_header_cstdalign' is deprecated: removed in C++20}}
#else
-# include <cstdalign>
-// expected-warning {{'__standard_header_cstdalign' is deprecated}}
+// expected-warning at cstdalign:* {{'__standard_header_cstdalign' is deprecated}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
index 8420b3541cad16..d354bc379d5578 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
@@ -14,10 +14,10 @@
#include "test_macros.h"
+#include <cstdbool>
+
#if TEST_STD_VER >= 20
-# include <cstdbool>
-// expected-warning {{'__standard_header_cstdbool' is deprecated: removed in C++20}}
+// expected-warning at cstdbool:* {{'__standard_header_cstdbool' is deprecated: removed in C++20}}
#else
-# include <cstdbool>
-// expected-warning {{'__standard_header_cstdbool' is deprecated}}
+// expected-warning at cstdbool:* {{'__standard_header_cstdbool' is deprecated}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
index 3dcb239b48d9e4..254899ae63bbc1 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
@@ -14,10 +14,10 @@
#include "test_macros.h"
+#include <ctgmath>
+
#if TEST_STD_VER >= 20
-# include <ctgmath>
-// expected-warning {{'__standard_header_ctgmath' is deprecated: removed in C++20}}
+// expected-warning at ctgmath:* {{'__standard_header_ctgmath' is deprecated: removed in C++20}}
#else
-# include <ctgmath>
-// expected-warning {{'__standard_header_ctgmath' is deprecated}}
+// expected-warning at ctgmath:* {{'__standard_header_ctgmath' is deprecated}}
#endif
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 304ad17b873e89..ffe08933a26401 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -34,19 +34,19 @@
# Undeprecate headers that are deprecated in C++17 and removed in C++20.
header_undeprecations = {
- "ccomplex": '''#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+ "ccomplex": """#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-#endif''',
+#endif""",
"ciso646": "#define _LIBCPP_ENABLE_REMOVED_CISO646",
- "cstdalign": '''#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+ "cstdalign": """#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-#endif''',
- "cstdbool": '''#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+#endif""",
+ "cstdbool": """#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-#endif''',
- "ctgmath": '''#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+#endif""",
+ "ctgmath": """#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-#endif''',
+#endif""",
}
lit_header_restrictions = {
>From 42d680e6ac7a92201e901424e7f40ffe9bff6854 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 14 Oct 2024 13:38:28 +0800
Subject: [PATCH 15/22] Skip modules-build
---
libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp | 2 ++
libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp | 2 ++
libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp | 2 ++
libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp | 2 ++
libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp | 2 ++
5 files changed, 10 insertions(+)
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
index a868f13ebfb00b..80e0ae078dab9e 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
@@ -9,8 +9,10 @@
// <ccomplex>
// check that <ccomplex> is deprecated in C++17 and removed in C++20
+// When built with modules, <ccomplex> should be omitted.
// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: clang-modules-build
#include "test_macros.h"
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
index 1ba06cc555d919..b900e0060ed214 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
@@ -9,8 +9,10 @@
// <ciso646>
// check that <ciso646> is removed in C++20
+// When built with modules, <ciso646> should be omitted.
// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: clang-modules-build
#include "test_macros.h"
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
index c8a9599ed3ac2a..b438a3237400ec 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
@@ -9,8 +9,10 @@
// <cstdalign>
// check that <cstdalign> is deprecated in C++17 and removed in C++20
+// When built with modules, <cstdalign> should be omitted.
// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: clang-modules-build
#include "test_macros.h"
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
index d354bc379d5578..2b93e51f0fa0bf 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
@@ -9,8 +9,10 @@
// <cstdbool>
// check that <cstdbool> is deprecated in C++17 and removed in C++20
+// When built with modules, <cstdbool> should be omitted.
// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: clang-modules-build
#include "test_macros.h"
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
index 254899ae63bbc1..6c6950d31d9eaa 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
@@ -9,8 +9,10 @@
// <ctgmath>
// check that <ctgmath> is deprecated in C++17 and removed in C++20
+// When built with modules, <ctgmath> should be omitted.
// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: clang-modules-build
#include "test_macros.h"
>From 2699c511f8b819705cef83f98b89861d8582f616 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Tue, 15 Oct 2024 01:35:39 +0800
Subject: [PATCH 16/22] Remove libc++'s wrapping `<stdalign.h>`
---
libcxx/include/CMakeLists.txt | 1 -
libcxx/include/module.modulemap | 4 --
libcxx/include/stdalign.h | 42 -------------------
.../stdalign_h.compile.pass.cpp | 3 ++
.../gn/secondary/libcxx/include/BUILD.gn | 1 -
5 files changed, 3 insertions(+), 48 deletions(-)
delete mode 100644 libcxx/include/stdalign.h
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 4a8e67a00a5a17..b13707c88e0790 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -995,7 +995,6 @@ set(files
span
sstream
stack
- stdalign.h
stdatomic.h
stdbool.h
stddef.h
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index b7827f38603e95..72569ff6426f50 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -2197,10 +2197,6 @@ module std_math_h [system] {
header "math.h"
export *
}
-module std_stdalign_h [system] {
- // <stdalign.h>'s __alignas_is_defined and __alignof_is_defined macros require textual inclusion.
- textual header "stdalign.h"
-}
module std_stdatomic_h [system] {
header "stdatomic.h"
export *
diff --git a/libcxx/include/stdalign.h b/libcxx/include/stdalign.h
deleted file mode 100644
index eb03f665151bd7..00000000000000
--- a/libcxx/include/stdalign.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_STDALIGN_H
-#define _LIBCPP_STDALIGN_H
-
-/*
- stdalign.h synopsis
-
-Macros:
-
- __alignas_is_defined
- __alignof_is_defined
-
-*/
-
-#include <__config>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
-
-#if __has_include_next(<stdalign.h>)
-# include_next <stdalign.h>
-#endif
-
-#ifdef __cplusplus
-# undef alignas
-# undef alignof
-# undef __alignas_is_defined
-# undef __alignof_is_defined
-# define __alignas_is_defined 1
-# define __alignof_is_defined 1
-#endif
-
-#endif // _LIBCPP_STDALIGN_H
diff --git a/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
index 0f1cf487d60f6d..4b1fc4214cbd67 100644
--- a/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
@@ -7,6 +7,9 @@
//===----------------------------------------------------------------------===//
// test <stdalign.h>
+//
+// Even though <stdalign.h> is not provided by libc++,
+// we still test that using it with libc++ on the search path will work.
#include <stdalign.h>
diff --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index 6d8aa44d8223ef..a4e39252fc73fe 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -1066,7 +1066,6 @@ if (current_toolchain == default_toolchain) {
"span",
"sstream",
"stack",
- "stdalign.h",
"stdatomic.h",
"stdbool.h",
"stddef.h",
>From 6372fcec242d5abd0f8fa01ac6abe8da68d6562f Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Tue, 15 Oct 2024 01:37:22 +0800
Subject: [PATCH 17/22] Adjust warning messages
---
libcxx/include/ccomplex | 11 +++--------
libcxx/include/ciso646 | 6 +++---
libcxx/include/cstdalign | 19 +++++++++++--------
libcxx/include/cstdbool | 11 +++--------
libcxx/include/ctgmath | 11 +++--------
.../depr/depr.cpp.headers/ccomplex.verify.cpp | 4 ++--
.../depr/depr.cpp.headers/ciso646.verify.cpp | 2 +-
.../depr.cpp.headers/cstdalign.verify.cpp | 4 ++--
.../depr/depr.cpp.headers/cstdbool.verify.cpp | 4 ++--
.../depr/depr.cpp.headers/ctgmath.verify.cpp | 4 ++--
10 files changed, 32 insertions(+), 44 deletions(-)
diff --git a/libcxx/include/ccomplex b/libcxx/include/ccomplex
index e498e06cad20a0..7eb37d0ff35784 100644
--- a/libcxx/include/ccomplex
+++ b/libcxx/include/ccomplex
@@ -23,17 +23,12 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# if _LIBCPP_STD_VER >= 20
-# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED_("removed in C++20")
+# warning <ccomplex> is removed in C++20. Include <complex> instead.
# else
-# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED
+# warning <ccomplex> is deprecated. Include <complex> instead.
# endif
-
-using __standard_header_ccomplex _DEPRECATION_ANNOTATION = void;
-using __use_standard_header_ccomplex = __standard_header_ccomplex;
-
-# undef _DEPRECATION_ANNOTATION
#endif
#endif // _LIBCPP_CCOMPLEX
diff --git a/libcxx/include/ciso646 b/libcxx/include/ciso646
index 5298d41dc26667..f2b70e33bc735d 100644
--- a/libcxx/include/ciso646
+++ b/libcxx/include/ciso646
@@ -21,9 +21,9 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_ENABLE_REMOVED_CISO646)
-using __standard_header_ciso646 _LIBCPP_DEPRECATED_("removed in C++20") = void;
-using __use_standard_header_ciso646 = __standard_header_ciso646;
+#if _LIBCPP_STD_VER >= 20 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_ENABLE_REMOVED_CISO646) && \
+ !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+# warning <ciso646> is removed in C++20. Include <version> instead.
#endif
#endif // _LIBCPP_CISO646
diff --git a/libcxx/include/cstdalign b/libcxx/include/cstdalign
index 2d9187cdbfe8ac..f0f9d9f665349e 100644
--- a/libcxx/include/cstdalign
+++ b/libcxx/include/cstdalign
@@ -22,6 +22,14 @@ Macros:
#include <__config>
+// <stdalign.h> is not provided by libc++
+#if __has_include(<stdalign.h>)
+# include <stdalign.h>
+# ifdef _LIBCPP_STDALIGN_H
+# error "If libc++ starts defining <stdalign.h>, the __has_include check should move to libc++'s <stdalign.h>"
+# endif
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -32,17 +40,12 @@ Macros:
#undef __alignof_is_defined
#define __alignof_is_defined 1
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# if _LIBCPP_STD_VER >= 20
-# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED_("removed in C++20")
+# warning <cstdalign> is removed in C++20.
# else
-# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED
+# warning <cstdalign> is deprecated.
# endif
-
-using __standard_header_cstdalign _DEPRECATION_ANNOTATION = void;
-using __use_standard_header_cstdalign = __standard_header_cstdalign;
-
-# undef _DEPRECATION_ANNOTATION
#endif
#endif // _LIBCPP_CSTDALIGN
diff --git a/libcxx/include/cstdbool b/libcxx/include/cstdbool
index decd9ee6e9cece..bfe32dd1defebe 100644
--- a/libcxx/include/cstdbool
+++ b/libcxx/include/cstdbool
@@ -28,17 +28,12 @@ Macros:
#undef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# if _LIBCPP_STD_VER >= 20
-# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED_("removed in C++20")
+# warning <cstdbool> is removed in C++20.
# else
-# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED
+# warning <cstdbool> is deprecated.
# endif
-
-using __standard_header_cstdbool _DEPRECATION_ANNOTATION = void;
-using __use_standard_header_cstdbool = __standard_header_cstdbool;
-
-# undef _DEPRECATION_ANNOTATION
#endif
#endif // _LIBCPP_CSTDBOOL
diff --git a/libcxx/include/ctgmath b/libcxx/include/ctgmath
index 75e1326a424d4b..522a080864df6b 100644
--- a/libcxx/include/ctgmath
+++ b/libcxx/include/ctgmath
@@ -32,17 +32,12 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_STD_VER >= 17 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# if _LIBCPP_STD_VER >= 20
-# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED_("removed in C++20")
+# warning <ctgmath> is removed in C++20. Include <cmath> and <complex> instead.
# else
-# define _DEPRECATION_ANNOTATION _LIBCPP_DEPRECATED
+# warning <ctgmath> is deprecated. Include <cmath> and <complex> instead.
# endif
-
-using __standard_header_ctgmath _DEPRECATION_ANNOTATION = void;
-using __use_standard_header_ctgmath = __standard_header_ctgmath;
-
-# undef _DEPRECATION_ANNOTATION
#endif
#endif // _LIBCPP_CTGMATH
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
index 80e0ae078dab9e..71d400e1e5c4a5 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
@@ -19,7 +19,7 @@
#include <ccomplex>
#if TEST_STD_VER >= 20
-// expected-warning at ccomplex:* {{'__standard_header_ccomplex' is deprecated: removed in C++20}}
+// expected-warning at ccomplex:* {{<ccomplex> is removed in C++20. Include <complex> instead.}}
#else
-// expected-warning at ccomplex:* {{'__standard_header_ccomplex' is deprecated}}
+// expected-warning at ccomplex:* {{<ccomplex> is deprecated. Include <complex> instead.}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
index b900e0060ed214..fc92ae20872fbf 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
@@ -17,4 +17,4 @@
#include "test_macros.h"
#include <ciso646>
-// expected-warning at ciso646:* {{'__standard_header_ciso646' is deprecated: removed in C++20}}
+// expected-warning at ciso646:* {{<ciso646> is removed in C++20. Include <version> instead.}}
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
index b438a3237400ec..0b02ee774514dc 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
@@ -19,7 +19,7 @@
#include <cstdalign>
#if TEST_STD_VER >= 20
-// expected-warning at cstdalign:* {{'__standard_header_cstdalign' is deprecated: removed in C++20}}
+// expected-warning at cstdalign:* {{<cstdalign> is removed in C++20.}}
#else
-// expected-warning at cstdalign:* {{'__standard_header_cstdalign' is deprecated}}
+// expected-warning at cstdalign:* {{<cstdalign> is deprecated.}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
index 2b93e51f0fa0bf..c5e2a436dd303c 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
@@ -19,7 +19,7 @@
#include <cstdbool>
#if TEST_STD_VER >= 20
-// expected-warning at cstdbool:* {{'__standard_header_cstdbool' is deprecated: removed in C++20}}
+// expected-warning at cstdbool:* {{<cstdbool> is removed in C++20.}}
#else
-// expected-warning at cstdbool:* {{'__standard_header_cstdbool' is deprecated}}
+// expected-warning at cstdbool:* {{<cstdbool> is deprecated.}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
index 6c6950d31d9eaa..73c7f2ba9b2f60 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
@@ -19,7 +19,7 @@
#include <ctgmath>
#if TEST_STD_VER >= 20
-// expected-warning at ctgmath:* {{'__standard_header_ctgmath' is deprecated: removed in C++20}}
+// expected-warning at ctgmath:* {{<ctgmath> is removed in C++20. Include <cmath> and <complex> instead.}}
#else
-// expected-warning at ctgmath:* {{'__standard_header_ctgmath' is deprecated}}
+// expected-warning at ctgmath:* {{<ctgmath> is deprecated. Include <cmath> and <complex> instead.}}
#endif
>From 72180f70320a7724053e83ee165ab3d2817bedaa Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Tue, 15 Oct 2024 01:37:51 +0800
Subject: [PATCH 18/22] Revert some changes in documentations
---
libcxx/docs/ReleaseNotes/20.rst | 2 +-
libcxx/docs/Status/Cxx17Papers.csv | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index 052809f6c25d94..e96df970a26041 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -39,8 +39,8 @@ Implemented Papers
------------------
- P0619R4: Reviewing Deprecated Facilities of C++17 for C++20 (`Github <https://github.com/llvm/llvm-project/issues/99985>`__)
-- P2609R3: Relaxing Ranges Just A Smidge (`Github <https://github.com/llvm/llvm-project/issues/105253>`__)
- P2747R2: ``constexpr`` placement new (`Github <https://github.com/llvm/llvm-project/issues/105427>`__)
+- P2609R3: Relaxing Ranges Just A Smidge (`Github <https://github.com/llvm/llvm-project/issues/105253>`__)
- P2985R0: A type trait for detecting virtual base classes (`Github <https://github.com/llvm/llvm-project/issues/105432>`__)
- ``std::jthread`` and ``<stop_token>`` are not guarded behind ``-fexperimental-library`` anymore
- P2674R1: A trait for implicit lifetime types (`Github <https://github.com/llvm/llvm-project/issues/105259>`__)
diff --git a/libcxx/docs/Status/Cxx17Papers.csv b/libcxx/docs/Status/Cxx17Papers.csv
index 3058fd44c7250f..3b56807312d556 100644
--- a/libcxx/docs/Status/Cxx17Papers.csv
+++ b/libcxx/docs/Status/Cxx17Papers.csv
@@ -43,7 +43,7 @@
"","","","","",""
"`P0032R3 <https://wg21.link/P0032R3>`__","Homogeneous interface for variant, any and optional","2016-06 (Oulu)","|Complete|","4.0",""
"`P0040R3 <https://wg21.link/P0040R3>`__","Extending memory management tools","2016-06 (Oulu)","|Complete|","4.0",""
-"`P0063R3 <https://wg21.link/P0063R3>`__","C++17 should refer to C11 instead of C99","2016-06 (Oulu)","|Complete|","7.0","``<ccomplex>``, ``<cstdalign>``, ``<cstdbool>``, and ``<ctgmath>`` are deprecated since LLVM 20."
+"`P0063R3 <https://wg21.link/P0063R3>`__","C++17 should refer to C11 instead of C99","2016-06 (Oulu)","|Complete|","7.0",""
"`P0067R3 <https://wg21.link/P0067R3>`__","Elementary string conversions","2016-06 (Oulu)","|Nothing To Do|","n/a","Resolved by `P0067R5 <https://wg21.link/P0067R5>`__"
"`P0083R3 <https://wg21.link/P0083R3>`__","Splicing Maps and Sets","2016-06 (Oulu)","|Complete|","8.0",""
"`P0084R2 <https://wg21.link/P0084R2>`__","Emplace Return Type","2016-06 (Oulu)","|Complete|","4.0",""
>From 8588d52d3be627a3c3b8b76c269f5bd9c8aeb089 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Tue, 22 Oct 2024 22:03:12 +0800
Subject: [PATCH 19/22] Address review comments and try to fix CI failures
---
libcxx/docs/ReleaseNotes/20.rst | 4 +--
libcxx/include/ciso646 | 3 +--
libcxx/include/complex.h | 6 +----
libcxx/include/ctgmath | 9 +------
libcxx/include/tgmath.h | 8 ++----
.../test/libcxx/clang_modules_include.gen.py | 4 +--
libcxx/test/libcxx/double_include.gen.py | 4 +--
libcxx/test/libcxx/header_inclusions.gen.py | 4 +--
libcxx/test/libcxx/libcpp_version.gen.py | 4 +--
libcxx/test/libcxx/no_assert_include.gen.py | 4 +--
.../test/libcxx/system_reserved_names.gen.py | 4 +--
.../test/libcxx/transitive_includes/cxx03.csv | 1 -
.../test/libcxx/transitive_includes/cxx11.csv | 1 -
.../test/libcxx/transitive_includes/cxx14.csv | 1 -
.../stdalign_h.compile.pass.cpp | 3 +++
.../depr/depr.cpp.headers/ciso646.verify.cpp | 2 --
...gn.pass.cpp => cstdalign.compile.pass.cpp} | 2 --
libcxx/utils/libcxx/header_information.py | 26 +++++++------------
18 files changed, 31 insertions(+), 59 deletions(-)
rename libcxx/test/std/language.support/support.runtime/{cstdalign.pass.cpp => cstdalign.compile.pass.cpp} (95%)
diff --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index e96df970a26041..64f823493dc5af 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -85,8 +85,8 @@ Deprecations and Removals
- ``<ccomplex>``, ``<cstdalign>`` (previously missing), ``<cstdbool>``, and ``<ctgmath>`` are deprecated since C++17 as
specified by the standard. They, together with ``<ciso646>``, are removed in C++20, but libc++ still provides these
- headers as an extension and only deprecates them. The ``_LIBCPP_ENABLE_REMOVED_CISO646`` macro can be defined to
- suppress deprecation for ``<ciso646>``.
+ headers as an extension and only deprecates them. The ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS`` macro can be defined to
+ suppress deprecation for these headers.
Upcoming Deprecations and Removals
----------------------------------
diff --git a/libcxx/include/ciso646 b/libcxx/include/ciso646
index f2b70e33bc735d..3189bd325625f4 100644
--- a/libcxx/include/ciso646
+++ b/libcxx/include/ciso646
@@ -21,8 +21,7 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER >= 20 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_ENABLE_REMOVED_CISO646) && \
- !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+#if _LIBCPP_STD_VER >= 20 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# warning <ciso646> is removed in C++20. Include <version> instead.
#endif
diff --git a/libcxx/include/complex.h b/libcxx/include/complex.h
index 7e264abe963efe..89595ae2068a64 100644
--- a/libcxx/include/complex.h
+++ b/libcxx/include/complex.h
@@ -24,11 +24,7 @@
#endif
#ifdef __cplusplus
-# if _LIBCPP_STD_VER >= 17
-# include <complex>
-# else
-# include <ccomplex>
-# endif
+# include <complex>
#elif __has_include_next(<complex.h>)
# include_next <complex.h>
#endif
diff --git a/libcxx/include/ctgmath b/libcxx/include/ctgmath
index 522a080864df6b..bceef1626211dd 100644
--- a/libcxx/include/ctgmath
+++ b/libcxx/include/ctgmath
@@ -18,15 +18,8 @@
*/
-#include <__config>
-
-#if _LIBCPP_STD_VER >= 17
-# include <complex>
-#else
-# include <ccomplex>
-#endif
-
#include <cmath>
+#include <complex>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/tgmath.h b/libcxx/include/tgmath.h
index 49b98a530cd659..1c5058cb065a91 100644
--- a/libcxx/include/tgmath.h
+++ b/libcxx/include/tgmath.h
@@ -24,12 +24,8 @@
#endif
#ifdef __cplusplus
-# if _LIBCPP_STD_VER >= 17
-# include <cmath>
-# include <complex>
-# else
-# include <ctgmath>
-# endif
+# include <cmath>
+# include <complex>
#else
# if __has_include_next(<tgmath.h>)
# include_next <tgmath.h>
diff --git a/libcxx/test/libcxx/clang_modules_include.gen.py b/libcxx/test/libcxx/clang_modules_include.gen.py
index 44afe603a19a3f..b897984f898819 100644
--- a/libcxx/test/libcxx/clang_modules_include.gen.py
+++ b/libcxx/test/libcxx/clang_modules_include.gen.py
@@ -19,7 +19,7 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
lit_header_restrictions,
- header_undeprecations,
+ lit_header_undeprecations,
public_headers,
)
@@ -46,7 +46,7 @@
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
{lit_header_restrictions.get(header, '')}
-{header_undeprecations.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#include <{header}>
"""
diff --git a/libcxx/test/libcxx/double_include.gen.py b/libcxx/test/libcxx/double_include.gen.py
index eabb04a5d1bed8..f58e72f94a3533 100644
--- a/libcxx/test/libcxx/double_include.gen.py
+++ b/libcxx/test/libcxx/double_include.gen.py
@@ -17,7 +17,7 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
lit_header_restrictions,
- header_undeprecations,
+ lit_header_undeprecations,
public_headers,
)
@@ -26,7 +26,7 @@
f"""\
//--- {header}.sh.cpp
{lit_header_restrictions.get(header, '')}
-{header_undeprecations.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
// RUN: %{{cxx}} -c %s -o %t.first.o %{{flags}} %{{compile_flags}}
// RUN: %{{cxx}} -c %s -o %t.second.o -DWITH_MAIN %{{flags}} %{{compile_flags}}
diff --git a/libcxx/test/libcxx/header_inclusions.gen.py b/libcxx/test/libcxx/header_inclusions.gen.py
index 11d6e972f23e30..5ceb503675a5e3 100644
--- a/libcxx/test/libcxx/header_inclusions.gen.py
+++ b/libcxx/test/libcxx/header_inclusions.gen.py
@@ -16,7 +16,7 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
lit_header_restrictions,
- header_undeprecations,
+ lit_header_undeprecations,
public_headers,
mandatory_inclusions,
)
@@ -44,7 +44,7 @@
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
-{header_undeprecations.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#include <{header}>
{checks}
diff --git a/libcxx/test/libcxx/libcpp_version.gen.py b/libcxx/test/libcxx/libcpp_version.gen.py
index fd9eca433b7667..b30623fe2c388b 100644
--- a/libcxx/test/libcxx/libcpp_version.gen.py
+++ b/libcxx/test/libcxx/libcpp_version.gen.py
@@ -14,7 +14,7 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
lit_header_restrictions,
- header_undeprecations,
+ lit_header_undeprecations,
public_headers,
)
@@ -23,7 +23,7 @@
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
-{header_undeprecations.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#include <{header}>
diff --git a/libcxx/test/libcxx/no_assert_include.gen.py b/libcxx/test/libcxx/no_assert_include.gen.py
index 320949ef327392..e0dbc3d815f31b 100644
--- a/libcxx/test/libcxx/no_assert_include.gen.py
+++ b/libcxx/test/libcxx/no_assert_include.gen.py
@@ -16,7 +16,7 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
lit_header_restrictions,
- header_undeprecations,
+ lit_header_undeprecations,
public_headers,
)
@@ -28,7 +28,7 @@
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
-{header_undeprecations.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#include <{header}>
diff --git a/libcxx/test/libcxx/system_reserved_names.gen.py b/libcxx/test/libcxx/system_reserved_names.gen.py
index 6386781864fc73..f01126249c8817 100644
--- a/libcxx/test/libcxx/system_reserved_names.gen.py
+++ b/libcxx/test/libcxx/system_reserved_names.gen.py
@@ -17,7 +17,7 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
lit_header_restrictions,
- header_undeprecations,
+ lit_header_undeprecations,
public_headers,
)
@@ -26,7 +26,7 @@
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
-{header_undeprecations.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
#define SYSTEM_RESERVED_NAME This name should not be used in libc++
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 506b5cd02c4495..165a0dd1191cbd 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -458,7 +458,6 @@ ctgmath array
ctgmath atomic
ctgmath bit
ctgmath bitset
-ctgmath ccomplex
ctgmath cctype
ctgmath cerrno
ctgmath climits
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index 506b5cd02c4495..165a0dd1191cbd 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -458,7 +458,6 @@ ctgmath array
ctgmath atomic
ctgmath bit
ctgmath bitset
-ctgmath ccomplex
ctgmath cctype
ctgmath cerrno
ctgmath climits
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index 828e1d62c6ec3e..4d15663858e5f3 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -467,7 +467,6 @@ ctgmath array
ctgmath atomic
ctgmath bit
ctgmath bitset
-ctgmath ccomplex
ctgmath cctype
ctgmath cerrno
ctgmath climits
diff --git a/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
index 4b1fc4214cbd67..d33a1e059b8e7f 100644
--- a/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
@@ -11,6 +11,9 @@
// Even though <stdalign.h> is not provided by libc++,
// we still test that using it with libc++ on the search path will work.
+// TODO: GCC doesn't provide a proper <stdalign.h>.
+// UNSUPPORTED: gcc
+
#include <stdalign.h>
#ifndef __alignas_is_defined
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
index fc92ae20872fbf..0bdced4f059256 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
@@ -14,7 +14,5 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: clang-modules-build
-#include "test_macros.h"
-
#include <ciso646>
// expected-warning at ciso646:* {{<ciso646> is removed in C++20. Include <version> instead.}}
diff --git a/libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdalign.compile.pass.cpp
similarity index 95%
rename from libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp
rename to libcxx/test/std/language.support/support.runtime/cstdalign.compile.pass.cpp
index 186cd1e1c8bee8..fbbaf9b2d136f9 100644
--- a/libcxx/test/std/language.support/support.runtime/cstdalign.pass.cpp
+++ b/libcxx/test/std/language.support/support.runtime/cstdalign.compile.pass.cpp
@@ -27,5 +27,3 @@
#ifdef alignof
# error alignof should not be defined
#endif
-
-int main(int, char**) { return 0; }
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index ffe08933a26401..7b1c40222b9a88 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -32,23 +32,6 @@
"syncstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
}
-# Undeprecate headers that are deprecated in C++17 and removed in C++20.
-header_undeprecations = {
- "ccomplex": """#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
-# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-#endif""",
- "ciso646": "#define _LIBCPP_ENABLE_REMOVED_CISO646",
- "cstdalign": """#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
-# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-#endif""",
- "cstdbool": """#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
-# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-#endif""",
- "ctgmath": """#if !defined (_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
-# define _LIBCPP_DISABLE_DEPRECATION_WARNINGS
-#endif""",
-}
-
lit_header_restrictions = {
"barrier": "// UNSUPPORTED: no-threads, c++03, c++11, c++14, c++17",
"clocale": "// UNSUPPORTED: no-localization",
@@ -88,6 +71,15 @@
"wctype.h": "// UNSUPPORTED: no-wide-characters",
}
+# Undeprecate headers that are deprecated in C++17 and removed in C++20.
+lit_header_undeprecations = {
+ "ccomplex": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "ciso646": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "cstdalign": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "cstdbool": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+ "ctgmath": "// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS",
+}
+
# This table was produced manually, by grepping the TeX source of the Standard's
# library clauses for the string "#include". Each header's synopsis contains
# explicit "#include" directives for its mandatory inclusions.
>From cb710363d54f137434785f3a844cc1e59f59da6d Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Tue, 22 Oct 2024 22:16:08 +0800
Subject: [PATCH 20/22] Fix merge and format errors
---
libcxx/test/libcxx/header_inclusions.gen.py | 4 +++-
libcxx/utils/libcxx/header_information.py | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/libcxx/test/libcxx/header_inclusions.gen.py b/libcxx/test/libcxx/header_inclusions.gen.py
index bc1412c8a80c2d..739caf915c09a0 100644
--- a/libcxx/test/libcxx/header_inclusions.gen.py
+++ b/libcxx/test/libcxx/header_inclusions.gen.py
@@ -22,7 +22,9 @@
)
for header in public_headers:
- header_guard = lambda h: f"_LIBCPP_{str(h).upper().replace('.', '_').replace('/', '_')}"
+ header_guard = (
+ lambda h: f"_LIBCPP_{str(h).upper().replace('.', '_').replace('/', '_')}"
+ )
# <cassert> has no header guards
if header == "cassert":
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 7a209b6a453931..543be3e0cf3af6 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -92,7 +92,7 @@ def has_cxx20_module(self) -> bool:
experimental headers.
"""
# These headers have been removed in C++20 so are never part of a module.
- removed_in_20 = ["ccomplex", "ciso646", "cstdbool", "ctgmath"]
+ removed_in_20 = ["ccomplex", "ciso646", "cstdalign", "cstdbool", "ctgmath"]
return self.is_public() and not self.is_experimental() and not self.is_C_compatibility() and not self._name in removed_in_20
def is_in_modulemap(self) -> bool:
>From cf9e2e2322f06bc064402dbb7d1746c9e25daee1 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 22 Oct 2024 12:37:22 -0400
Subject: [PATCH 21/22] Add missing cstdalign to c header files
---
libcxx/utils/libcxx/header_information.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 543be3e0cf3af6..8e25e2bb971deb 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -66,6 +66,7 @@ def is_cstd(self) -> bool:
"cmath",
"csetjmp",
"csignal",
+ "cstdalign",
"cstdarg",
"cstdbool",
"cstddef",
>From aa83d21c4747b79c37802b4a5b9481e8515567f1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Thu, 24 Oct 2024 01:43:29 +0800
Subject: [PATCH 22/22] Restore to attribute-based method
---
libcxx/include/ccomplex | 11 ++++++++---
libcxx/include/ciso646 | 7 +++++--
libcxx/include/cstdalign | 11 ++++++++---
libcxx/include/cstdbool | 11 ++++++++---
libcxx/include/ctgmath | 11 ++++++++---
.../std/depr/depr.cpp.headers/ccomplex.verify.cpp | 4 ++--
.../test/std/depr/depr.cpp.headers/ciso646.verify.cpp | 2 +-
.../std/depr/depr.cpp.headers/cstdalign.verify.cpp | 4 ++--
.../std/depr/depr.cpp.headers/cstdbool.verify.cpp | 4 ++--
.../test/std/depr/depr.cpp.headers/ctgmath.verify.cpp | 4 ++--
10 files changed, 46 insertions(+), 23 deletions(-)
diff --git a/libcxx/include/ccomplex b/libcxx/include/ccomplex
index 7eb37d0ff35784..887667222ee3a7 100644
--- a/libcxx/include/ccomplex
+++ b/libcxx/include/ccomplex
@@ -23,12 +23,17 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER >= 17 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+#if _LIBCPP_STD_VER >= 17
+
+using __standard_header_ccomplex
# if _LIBCPP_STD_VER >= 20
-# warning <ccomplex> is removed in C++20. Include <complex> instead.
+ _LIBCPP_DEPRECATED_("removed in C++20. Include <complex> instead.")
# else
-# warning <ccomplex> is deprecated. Include <complex> instead.
+ _LIBCPP_DEPRECATED_("Include <complex> instead.")
# endif
+ = void;
+using __use_standard_header_ccomplex = __standard_header_ccomplex;
+
#endif
#endif // _LIBCPP_CCOMPLEX
diff --git a/libcxx/include/ciso646 b/libcxx/include/ciso646
index 3189bd325625f4..5fcac79e38a7f2 100644
--- a/libcxx/include/ciso646
+++ b/libcxx/include/ciso646
@@ -21,8 +21,11 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER >= 20 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
-# warning <ciso646> is removed in C++20. Include <version> instead.
+#if _LIBCPP_STD_VER >= 20
+
+using __standard_header_ciso646 _LIBCPP_DEPRECATED_("removed in C++20. Include <version> instead.") = void;
+using __use_standard_header_ciso646 = __standard_header_ciso646;
+
#endif
#endif // _LIBCPP_CISO646
diff --git a/libcxx/include/cstdalign b/libcxx/include/cstdalign
index f0f9d9f665349e..212b93447696c5 100644
--- a/libcxx/include/cstdalign
+++ b/libcxx/include/cstdalign
@@ -40,12 +40,17 @@ Macros:
#undef __alignof_is_defined
#define __alignof_is_defined 1
-#if _LIBCPP_STD_VER >= 17 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+#if _LIBCPP_STD_VER >= 17
+
+using __standard_header_cstdalign
# if _LIBCPP_STD_VER >= 20
-# warning <cstdalign> is removed in C++20.
+ _LIBCPP_DEPRECATED_("removed in C++20.")
# else
-# warning <cstdalign> is deprecated.
+ _LIBCPP_DEPRECATED
# endif
+ = void;
+using __use_standard_header_cstdalign = __standard_header_cstdalign;
+
#endif
#endif // _LIBCPP_CSTDALIGN
diff --git a/libcxx/include/cstdbool b/libcxx/include/cstdbool
index bfe32dd1defebe..40346f3b151794 100644
--- a/libcxx/include/cstdbool
+++ b/libcxx/include/cstdbool
@@ -28,12 +28,17 @@ Macros:
#undef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
-#if _LIBCPP_STD_VER >= 17 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+#if _LIBCPP_STD_VER >= 17
+
+using __standard_header_cstdbool
# if _LIBCPP_STD_VER >= 20
-# warning <cstdbool> is removed in C++20.
+ _LIBCPP_DEPRECATED_("removed in C++20.")
# else
-# warning <cstdbool> is deprecated.
+ _LIBCPP_DEPRECATED
# endif
+ = void;
+using __use_standard_header_cstdbool = __standard_header_cstdbool;
+
#endif
#endif // _LIBCPP_CSTDBOOL
diff --git a/libcxx/include/ctgmath b/libcxx/include/ctgmath
index bceef1626211dd..f4de90a6c8c611 100644
--- a/libcxx/include/ctgmath
+++ b/libcxx/include/ctgmath
@@ -25,12 +25,17 @@
# pragma GCC system_header
#endif
-#if _LIBCPP_STD_VER >= 17 && defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
+#if _LIBCPP_STD_VER >= 17
+
+using __standard_header_ctgmath
# if _LIBCPP_STD_VER >= 20
-# warning <ctgmath> is removed in C++20. Include <cmath> and <complex> instead.
+ _LIBCPP_DEPRECATED_("removed in C++20. Include <cmath> and <complex> instead.")
# else
-# warning <ctgmath> is deprecated. Include <cmath> and <complex> instead.
+ _LIBCPP_DEPRECATED_("Include <cmath> and <complex> instead.")
# endif
+ = void;
+using __use_standard_header_ctgmath = __standard_header_ctgmath;
+
#endif
#endif // _LIBCPP_CTGMATH
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
index 71d400e1e5c4a5..0eaf82ce5cef01 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
@@ -19,7 +19,7 @@
#include <ccomplex>
#if TEST_STD_VER >= 20
-// expected-warning at ccomplex:* {{<ccomplex> is removed in C++20. Include <complex> instead.}}
+// expected-warning at ccomplex:* {{'__standard_header_ccomplex' is deprecated: removed in C++20. Include <complex> instead.}}
#else
-// expected-warning at ccomplex:* {{<ccomplex> is deprecated. Include <complex> instead.}}
+// expected-warning at ccomplex:* {{'__standard_header_ccomplex' is deprecated: Include <complex> instead.}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
index 0bdced4f059256..04acd100815485 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
@@ -15,4 +15,4 @@
// UNSUPPORTED: clang-modules-build
#include <ciso646>
-// expected-warning at ciso646:* {{<ciso646> is removed in C++20. Include <version> instead.}}
+// expected-warning at ciso646:* {{'__standard_header_ciso646' is deprecated: removed in C++20. Include <version> instead.}}
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
index 0b02ee774514dc..dc9f1af55b3f14 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
@@ -19,7 +19,7 @@
#include <cstdalign>
#if TEST_STD_VER >= 20
-// expected-warning at cstdalign:* {{<cstdalign> is removed in C++20.}}
+// expected-warning at cstdalign:* {{'__standard_header_cstdalign' is deprecated: removed in C++20.}}
#else
-// expected-warning at cstdalign:* {{<cstdalign> is deprecated.}}
+// expected-warning at cstdalign:* {{'__standard_header_cstdalign' is deprecated}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
index c5e2a436dd303c..eddefe14d35eac 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
@@ -19,7 +19,7 @@
#include <cstdbool>
#if TEST_STD_VER >= 20
-// expected-warning at cstdbool:* {{<cstdbool> is removed in C++20.}}
+// expected-warning at cstdbool:* {{'__standard_header_cstdbool' is deprecated: removed in C++20.}}
#else
-// expected-warning at cstdbool:* {{<cstdbool> is deprecated.}}
+// expected-warning at cstdbool:* {{'__standard_header_cstdbool' is deprecated}}
#endif
diff --git a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
index 73c7f2ba9b2f60..097ab1643d15af 100644
--- a/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
+++ b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
@@ -19,7 +19,7 @@
#include <ctgmath>
#if TEST_STD_VER >= 20
-// expected-warning at ctgmath:* {{<ctgmath> is removed in C++20. Include <cmath> and <complex> instead.}}
+// expected-warning at ctgmath:* {{'__standard_header_ctgmath' is deprecated: removed in C++20. Include <cmath> and <complex> instead.}}
#else
-// expected-warning at ctgmath:* {{<ctgmath> is deprecated. Include <cmath> and <complex> instead.}}
+// expected-warning at ctgmath:* {{'__standard_header_ctgmath' is deprecated: Include <cmath> and <complex> instead.}}
#endif
More information about the llvm-commits
mailing list