[llvm] 63eb40e - [libc++] Deprecate and remove meaningless `<cxxx>` headers (#111615)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 18:49:30 PDT 2024


Author: A. Jiang
Date: 2024-10-30T09:49:26+08:00
New Revision: 63eb40eeb1b7aac57a181f6b5f9170ea94cef738

URL: https://github.com/llvm/llvm-project/commit/63eb40eeb1b7aac57a181f6b5f9170ea94cef738
DIFF: https://github.com/llvm/llvm-project/commit/63eb40eeb1b7aac57a181f6b5f9170ea94cef738.diff

LOG: [libc++] Deprecate and remove meaningless `<cxxx>` headers (#111615)

This PR deprecates `<ccomplex>`, `<cstdbool>`, `<ctgmath>`, and
`<ciso646>` in C++17 and "removes" them in C++20 by special deprecation
warnings.

`<cstdalign>` is previously missing. This PR also tries to add them, and
then deprecates and "removes" `<cstdalign>`.

Papers:
- https://wg21.link/P0063R3
- https://wg21.link/P0619R4

Closes #99985.

---------

Co-authored-by: Louis Dionne <ldionne.2 at gmail.com>

Added: 
    libcxx/include/cstdalign
    libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
    libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
    libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
    libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
    libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
    libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
    libcxx/test/std/language.support/support.runtime/cstdalign.compile.pass.cpp

Modified: 
    libcxx/docs/ReleaseNotes/20.rst
    libcxx/docs/Status/Cxx20Papers.csv
    libcxx/include/CMakeLists.txt
    libcxx/include/ccomplex
    libcxx/include/ciso646
    libcxx/include/complex.h
    libcxx/include/cstdbool
    libcxx/include/ctgmath
    libcxx/include/module.modulemap
    libcxx/include/tgmath.h
    libcxx/test/libcxx/clang_modules_include.gen.py
    libcxx/test/libcxx/double_include.gen.py
    libcxx/test/libcxx/header_inclusions.gen.py
    libcxx/test/libcxx/include_as_c.sh.cpp
    libcxx/test/libcxx/libcpp_version.gen.py
    libcxx/test/libcxx/no_assert_include.gen.py
    libcxx/test/libcxx/system_reserved_names.gen.py
    libcxx/test/libcxx/transitive_includes/cxx03.csv
    libcxx/test/libcxx/transitive_includes/cxx11.csv
    libcxx/test/libcxx/transitive_includes/cxx14.csv
    libcxx/test/libcxx/transitive_includes/cxx17.csv
    libcxx/test/libcxx/transitive_includes/cxx20.csv
    libcxx/test/libcxx/transitive_includes/cxx23.csv
    libcxx/test/libcxx/transitive_includes/cxx26.csv
    libcxx/test/std/depr/depr.c.headers/ciso646.compile.pass.cpp
    libcxx/test/std/language.support/support.runtime/cstdbool.pass.cpp
    libcxx/test/std/numerics/c.math/ctgmath.pass.cpp
    libcxx/test/std/numerics/complex.number/ccmplx/ccomplex.pass.cpp
    libcxx/utils/libcxx/header_information.py
    llvm/utils/gn/secondary/libcxx/include/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/ReleaseNotes/20.rst b/libcxx/docs/ReleaseNotes/20.rst
index 38b8df3b2a7718..bf3aafe6139ee9 100644
--- a/libcxx/docs/ReleaseNotes/20.rst
+++ b/libcxx/docs/ReleaseNotes/20.rst
@@ -38,6 +38,7 @@ What's New in Libc++ 20.0.0?
 Implemented Papers
 ------------------
 
+- P0619R4: Reviewing Deprecated Facilities of C++17 for C++20 (`Github <https://github.com/llvm/llvm-project/issues/99985>`__)
 - 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>`__)
@@ -89,6 +90,11 @@ Deprecations and Removals
   the ``_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT`` macro can be defined to make the function non-``noexcept``. That macro
   will be removed in LLVM 21.
 
+- ``<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_DISABLE_DEPRECATION_WARNINGS`` macro can be defined to
+  suppress deprecation for these headers.
+
 Upcoming Deprecations and Removals
 ----------------------------------
 

diff  --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv
index 9a057be8ad0519..5cd77be4d58def 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/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index e84a55e25f2fa4..87eaf64b245017 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -923,6 +923,7 @@ set(files
   coroutine
   csetjmp
   csignal
+  cstdalign
   cstdarg
   cstdbool
   cstddef

diff  --git a/libcxx/include/ccomplex b/libcxx/include/ccomplex
index 94d2c8d7d003d4..d379c9e7f0174a 100644
--- a/libcxx/include/ccomplex
+++ b/libcxx/include/ccomplex
@@ -23,4 +23,16 @@
 #  pragma GCC system_header
 #endif
 
+#if _LIBCPP_STD_VER >= 20
+
+using __standard_header_ccomplex _LIBCPP_DEPRECATED_("removed in C++20. Include <complex> instead.") = void;
+using __use_standard_header_ccomplex = __standard_header_ccomplex;
+
+#elif _LIBCPP_STD_VER >= 17
+
+using __standard_header_ccomplex _LIBCPP_DEPRECATED_("Include <complex> instead.") = void;
+using __use_standard_header_ccomplex                                               = __standard_header_ccomplex;
+
+#endif
+
 #endif // _LIBCPP_CCOMPLEX

diff  --git a/libcxx/include/ciso646 b/libcxx/include/ciso646
index 1d859f08fac572..5fcac79e38a7f2 100644
--- a/libcxx/include/ciso646
+++ b/libcxx/include/ciso646
@@ -21,4 +21,11 @@
 #  pragma GCC system_header
 #endif
 
+#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/complex.h b/libcxx/include/complex.h
index a3da21c843f365..89595ae2068a64 100644
--- a/libcxx/include/complex.h
+++ b/libcxx/include/complex.h
@@ -24,7 +24,7 @@
 #endif
 
 #ifdef __cplusplus
-#  include <ccomplex>
+#  include <complex>
 #elif __has_include_next(<complex.h>)
 #  include_next <complex.h>
 #endif

diff  --git a/libcxx/include/cstdalign b/libcxx/include/cstdalign
new file mode 100644
index 00000000000000..e6a2a3c7177422
--- /dev/null
+++ b/libcxx/include/cstdalign
@@ -0,0 +1,55 @@
+// -*- 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>
+
+// <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
+
+#undef __alignas_is_defined
+#define __alignas_is_defined 1
+
+#undef __alignof_is_defined
+#define __alignof_is_defined 1
+
+#if _LIBCPP_STD_VER >= 20
+
+using __standard_header_cstdalign _LIBCPP_DEPRECATED_("removed in C++20.") = void;
+using __use_standard_header_cstdalign                                      = __standard_header_cstdalign;
+
+#elif _LIBCPP_STD_VER >= 17
+
+using __standard_header_cstdalign _LIBCPP_DEPRECATED = void;
+using __use_standard_header_cstdalign                = __standard_header_cstdalign;
+
+#endif
+
+#endif // _LIBCPP_CSTDALIGN

diff  --git a/libcxx/include/cstdbool b/libcxx/include/cstdbool
index ef731c021a4ab8..1d627258e10c09 100644
--- a/libcxx/include/cstdbool
+++ b/libcxx/include/cstdbool
@@ -28,4 +28,16 @@ Macros:
 #undef __bool_true_false_are_defined
 #define __bool_true_false_are_defined 1
 
+#if _LIBCPP_STD_VER >= 20
+
+using __standard_header_cstdbool _LIBCPP_DEPRECATED_("removed in C++20.") = void;
+using __use_standard_header_cstdbool                                      = __standard_header_cstdbool;
+
+#elif _LIBCPP_STD_VER >= 17
+
+using __standard_header_cstdbool _LIBCPP_DEPRECATED = void;
+using __use_standard_header_cstdbool                = __standard_header_cstdbool;
+
+#endif
+
 #endif // _LIBCPP_CSTDBOOL

diff  --git a/libcxx/include/ctgmath b/libcxx/include/ctgmath
index 6237979be4906c..7dbe952f021b74 100644
--- a/libcxx/include/ctgmath
+++ b/libcxx/include/ctgmath
@@ -18,11 +18,23 @@
 
 */
 
-#include <ccomplex>
 #include <cmath>
+#include <complex>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif
 
+#if _LIBCPP_STD_VER >= 20
+
+using __standard_header_ctgmath _LIBCPP_DEPRECATED_("removed in C++20. Include <cmath> and <complex> instead.") = void;
+using __use_standard_header_ctgmath = __standard_header_ctgmath;
+
+#elif _LIBCPP_STD_VER >= 17
+
+using __standard_header_ctgmath _LIBCPP_DEPRECATED_("Include <cmath> and <complex> instead.") = void;
+using __use_standard_header_ctgmath = __standard_header_ctgmath;
+
+#endif
+
 #endif // _LIBCPP_CTGMATH

diff  --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index c3d08000731992..af8c3c15eb2767 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -1109,6 +1109,11 @@ module std [system] {
     export *
   }
 
+  module cstdalign {
+    header "cstdalign"
+    export *
+  }
+
   module cstdarg {
     header "cstdarg"
     export *

diff  --git a/libcxx/include/tgmath.h b/libcxx/include/tgmath.h
index e6f0a4ab2611fa..1c5058cb065a91 100644
--- a/libcxx/include/tgmath.h
+++ b/libcxx/include/tgmath.h
@@ -24,7 +24,8 @@
 #endif
 
 #ifdef __cplusplus
-#  include <ctgmath>
+#  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 bc028f2a0809aa..b897984f898819 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, public_headers
+from libcxx.header_information import (
+    lit_header_restrictions,
+    lit_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,9 +46,11 @@
 // UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
 
 {lit_header_restrictions.get(header, '')}
+{lit_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 afc2947dbece94..f58e72f94a3533 100644
--- a/libcxx/test/libcxx/double_include.gen.py
+++ b/libcxx/test/libcxx/double_include.gen.py
@@ -15,12 +15,18 @@
 
 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"""\
+    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}}
@@ -32,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 e5def1ad4cb70d..739caf915c09a0 100644
--- a/libcxx/test/libcxx/header_inclusions.gen.py
+++ b/libcxx/test/libcxx/header_inclusions.gen.py
@@ -12,32 +12,43 @@
 # RUN: %{python} %s %{libcxx-dir}/utils
 
 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_{str(h).upper().replace('.', '_').replace('/', '_')}"
+    header_guard = (
+        lambda h: f"_LIBCPP_{str(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, '')}
 
 #include <{header}>
 {checks}
-""")
+"""
+    )

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/libcxx/libcpp_version.gen.py b/libcxx/test/libcxx/libcpp_version.gen.py
index a9995295e21e4f..b30623fe2c388b 100644
--- a/libcxx/test/libcxx/libcpp_version.gen.py
+++ b/libcxx/test/libcxx/libcpp_version.gen.py
@@ -12,16 +12,23 @@
 
 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"""\
+    print(
+        f"""\
 //--- {header}.compile.pass.cpp
 {lit_header_restrictions.get(header, '')}
+{lit_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 67ab98603ca8fd..e0dbc3d815f31b 100644
--- a/libcxx/test/libcxx/no_assert_include.gen.py
+++ b/libcxx/test/libcxx/no_assert_include.gen.py
@@ -12,20 +12,28 @@
 # RUN: %{python} %s %{libcxx-dir}/utils
 
 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':
-    continue
+    if header == "cassert":
+        continue
 
-  print(f"""\
+    print(
+        f"""\
 //--- {header}.compile.pass.cpp
 {lit_header_restrictions.get(header, '')}
+{lit_header_undeprecations.get(header, '')}
 
 #include <{header}>
 
 #ifdef assert
 # error "Do not include cassert or assert.h in standard header files"
 #endif
-""")
+"""
+    )

diff  --git a/libcxx/test/libcxx/system_reserved_names.gen.py b/libcxx/test/libcxx/system_reserved_names.gen.py
index e29e7a2cdd6144..f01126249c8817 100644
--- a/libcxx/test/libcxx/system_reserved_names.gen.py
+++ b/libcxx/test/libcxx/system_reserved_names.gen.py
@@ -13,14 +13,20 @@
 # RUN: %{python} %s %{libcxx-dir}/utils
 
 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/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 2dc84963f0891e..48c501863cb76c 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 2dc84963f0891e..48c501863cb76c 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 27e22975573584..6191c9012c631b 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/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index b17eb1f2347a86..5d46162e3f8996 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 9efec327889c1d..20fe9878ce3eae 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 e17f732663a9b2..5ee89ec307cc29 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -238,7 +238,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 c56f5cdfad0072..ee17223e66bee4 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -238,7 +238,6 @@ coroutine limits
 coroutine version
 cstddef version
 ctgmath bitset
-ctgmath ccomplex
 ctgmath cctype
 ctgmath cerrno
 ctgmath climits

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.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..e7290aab2c6616
--- /dev/null
+++ b/libcxx/test/std/depr/depr.c.headers/stdalign_h.compile.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+//
+// 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> for C++ until 15.
+// UNSUPPORTED: gcc
+
+#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/depr/depr.cpp.headers/ccomplex.verify.cpp b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
new file mode 100644
index 00000000000000..0eaf82ce5cef01
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// When built with modules, <ccomplex> should be omitted.
+
+// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: clang-modules-build
+
+#include "test_macros.h"
+
+#include <ccomplex>
+
+#if TEST_STD_VER >= 20
+// expected-warning at ccomplex:* {{'__standard_header_ccomplex' is deprecated: removed in C++20. Include <complex> instead.}}
+#else
+// 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
new file mode 100644
index 00000000000000..04acd100815485
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <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 <ciso646>
+// 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
new file mode 100644
index 00000000000000..dc9f1af55b3f14
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// When built with modules, <cstdalign> should be omitted.
+
+// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: clang-modules-build
+
+#include "test_macros.h"
+
+#include <cstdalign>
+
+#if TEST_STD_VER >= 20
+// expected-warning at cstdalign:* {{'__standard_header_cstdalign' is deprecated: removed in C++20.}}
+#else
+// 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
new file mode 100644
index 00000000000000..eddefe14d35eac
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/cstdbool.verify.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// When built with modules, <cstdbool> should be omitted.
+
+// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: clang-modules-build
+
+#include "test_macros.h"
+
+#include <cstdbool>
+
+#if TEST_STD_VER >= 20
+// expected-warning at cstdbool:* {{'__standard_header_cstdbool' is deprecated: removed in C++20.}}
+#else
+// 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
new file mode 100644
index 00000000000000..097ab1643d15af
--- /dev/null
+++ b/libcxx/test/std/depr/depr.cpp.headers/ctgmath.verify.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+// When built with modules, <ctgmath> should be omitted.
+
+// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: clang-modules-build
+
+#include "test_macros.h"
+
+#include <ctgmath>
+
+#if TEST_STD_VER >= 20
+// expected-warning at ctgmath:* {{'__standard_header_ctgmath' is deprecated: removed in C++20. Include <cmath> and <complex> instead.}}
+#else
+// expected-warning at ctgmath:* {{'__standard_header_ctgmath' is deprecated: Include <cmath> and <complex> instead.}}
+#endif

diff  --git a/libcxx/test/std/language.support/support.runtime/cstdalign.compile.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdalign.compile.pass.cpp
new file mode 100644
index 00000000000000..fbbaf9b2d136f9
--- /dev/null
+++ b/libcxx/test/std/language.support/support.runtime/cstdalign.compile.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> // 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>
+
+#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/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>
 

diff  --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 3b12dcb9f56c0b..cac620e4f1fe77 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",
@@ -92,7 +93,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_cxx03_frozen_header(self) -> bool:
@@ -236,6 +237,15 @@ def __hash__(self) -> int:
     "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.

diff  --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index 8121e34dcf6eff..776f1d32c5f520 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -995,6 +995,7 @@ if (current_toolchain == default_toolchain) {
       "coroutine",
       "csetjmp",
       "csignal",
+      "cstdalign",
       "cstdarg",
       "cstdbool",
       "cstddef",


        


More information about the llvm-commits mailing list