Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cd7e179
[libc++] Deprecate and remove meaningless `<cxxx>` headers
frederick-vs-ja Oct 9, 2024
a7fdda0
[libc++] Add missed `<cstdalign>` and `<stdalign.h>` headers
frederick-vs-ja Oct 9, 2024
fdf253d
[libc++] Deprecate and remove `<cstdalign>`
frederick-vs-ja Oct 9, 2024
81ea61b
Try to fix undeprecation/deprecation verification
frederick-vs-ja Oct 9, 2024
887574c
Try to fix generating scripts
frederick-vs-ja Oct 9, 2024
18c7e9d
More formatting
frederick-vs-ja Oct 9, 2024
b68ee90
Reorganize inclusion per P0063R3 to reduce deprecation warnings
frederick-vs-ja Oct 9, 2024
70d91b7
Delete unneeded `<stdalign.h>`
frederick-vs-ja Oct 10, 2024
8360774
Escape hatch for `<ciso646>`
frederick-vs-ja Oct 10, 2024
9c4337c
Fix some errors for `<ctgmath>` and `<tgmath.h>`
frederick-vs-ja Oct 10, 2024
1299c89
Revert "Delete unneeded `<stdalign.h>`"
frederick-vs-ja Oct 10, 2024
ca47422
Adjust transitive_includes files
frederick-vs-ja Oct 14, 2024
27abb5f
Merge branch 'main' into cxx20-removed-headers
frederick-vs-ja Oct 14, 2024
7d05faa
Try to fix deprecation suppressing/verification
frederick-vs-ja Oct 14, 2024
53da492
Try to fix deprecation suppressing/verification, take 2
frederick-vs-ja Oct 14, 2024
42d680e
Skip modules-build
frederick-vs-ja Oct 14, 2024
2699c51
Remove libc++'s wrapping `<stdalign.h>`
frederick-vs-ja Oct 14, 2024
6372fce
Adjust warning messages
frederick-vs-ja Oct 14, 2024
72180f7
Revert some changes in documentations
frederick-vs-ja Oct 14, 2024
8588d52
Address review comments and try to fix CI failures
frederick-vs-ja Oct 22, 2024
6c4b524
Merge branch 'main' into cxx20-removed-headers
frederick-vs-ja Oct 22, 2024
cb71036
Fix merge and format errors
frederick-vs-ja Oct 22, 2024
cf9e2e2
Add missing cstdalign to c header files
ldionne Oct 22, 2024
aa83d21
Restore to attribute-based method
frederick-vs-ja Oct 23, 2024
2f7ab3b
Reform deprecation messages and add more comments
frederick-vs-ja Oct 27, 2024
42214df
Fix `#else if`
frederick-vs-ja Oct 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion libcxx/docs/ReleaseNotes/20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
- P2674R1: A trait for implicit lifetime types (`Github <https://github.com/llvm/llvm-project/issues/105259>`__)
Expand Down Expand Up @@ -82,6 +83,11 @@ Deprecations and Removals
were private but could cause ambiguity in name lookup. Code that expects such ambiguity will possibly not compile in
LLVM 20.

- ``<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>``.

Upcoming Deprecations and Removals
----------------------------------

Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx17Papers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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>``, ``<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",""
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx20Papers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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|","",""
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ set(files
coroutine
csetjmp
csignal
cstdalign
cstdarg
cstdbool
cstddef
Expand Down Expand Up @@ -994,6 +995,7 @@ set(files
span
sstream
stack
stdalign.h
stdatomic.h
stdbool.h
stddef.h
Expand Down
13 changes: 13 additions & 0 deletions libcxx/include/ccomplex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a very complex way of writing

#if defined(__DEPRECATED) && __DEPRECATED
#  warning "<ccomplex> is deprecated"
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're only doing this for <hash_map> & <hash_set>. I guess the deprecation warnings should be controllable by _LIBCPP_DISABLE_DEPRECATION_WARNINGS (which is mentioned in __config).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should probably slap a && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we need to switch back to the [[deprecated]]-based method...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frederick-vs-ja Does that solve the issue with modules?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that works as CI is green now.


#endif // _LIBCPP_CCOMPLEX
5 changes: 5 additions & 0 deletions libcxx/include/ciso646
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +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;
#endif

#endif // _LIBCPP_CISO646
6 changes: 5 additions & 1 deletion libcxx/include/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions libcxx/include/cstdalign
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// -*- 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

#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
13 changes: 13 additions & 0 deletions libcxx/include/cstdbool
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 21 additions & 1 deletion libcxx/include/ctgmath
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,31 @@

*/

#include <ccomplex>
#include <__config>

#if _LIBCPP_STD_VER >= 17
# include <complex>
#else
# include <ccomplex>
#endif

#include <cmath>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# 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
9 changes: 9 additions & 0 deletions libcxx/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,11 @@ module std [system] {
export *
}

module cstdalign {
header "cstdalign"
export *
}

module cstdarg {
header "cstdarg"
export *
Expand Down Expand Up @@ -2192,6 +2197,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 *
Expand Down
42 changes: 42 additions & 0 deletions libcxx/include/stdalign.h
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion libcxx/include/tgmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
#endif

#ifdef __cplusplus
# include <ctgmath>
# if _LIBCPP_STD_VER >= 17
# include <cmath>
# include <complex>
# else
# include <ctgmath>
# endif
#else
# if __has_include_next(<tgmath.h>)
# include_next <tgmath.h>
Expand Down
13 changes: 10 additions & 3 deletions libcxx/test/libcxx/clang_modules_include.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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

Expand All @@ -41,9 +46,11 @@
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME

{lit_header_restrictions.get(header, '')}
{header_undeprecations.get(header, '')}

#include <{header}>
""")
"""
)

print(
f"""\
Expand Down
13 changes: 10 additions & 3 deletions libcxx/test/libcxx/double_include.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
header_undeprecations,
public_headers,
)

for header in public_headers:
print(f"""\
print(
f"""\
//--- {header}.sh.cpp
{lit_header_restrictions.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}}
Expand All @@ -32,4 +38,5 @@
#if defined(WITH_MAIN)
int main(int, char**) {{ return 0; }}
#endif
""")
"""
)
35 changes: 22 additions & 13 deletions libcxx/test/libcxx/header_inclusions.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,41 @@
# 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,
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, '')}
{header_undeprecations.get(header, '')}

#include <{header}>
{checks}
""")
"""
)
1 change: 1 addition & 0 deletions libcxx/test/libcxx/include_as_c.sh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#endif
#include <math.h>
#include <setjmp.h>
#include <stdalign.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
Expand Down
Loading