Skip to content

Commit 3861df3

Browse files
committed
[libc++] Simplify how headers are deprecated
1 parent eca6144 commit 3861df3

File tree

12 files changed

+27
-78
lines changed

12 files changed

+27
-78
lines changed

libcxx/include/__config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,12 @@ typedef __char32_t char32_t;
721721
# define _LIBCPP_DEPRECATED_(m)
722722
# endif
723723

724+
# if defined(__DEPRECATED) && __DEPRECATED && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && !__building_module(std)
725+
# define _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS 1
726+
# else
727+
# define _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS 0
728+
# endif
729+
724730
# if !defined(_LIBCPP_CXX03_LANG)
725731
# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
726732
# else

libcxx/include/ccomplex

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,10 @@
2626
# pragma GCC system_header
2727
# endif
2828

29-
# if _LIBCPP_STD_VER >= 20
30-
31-
using __standard_header_ccomplex
32-
_LIBCPP_DEPRECATED_("removed in C++20. Include <complex> instead.") _LIBCPP_NODEBUG = void;
33-
using __use_standard_header_ccomplex _LIBCPP_NODEBUG = __standard_header_ccomplex;
34-
35-
# elif _LIBCPP_STD_VER >= 17
36-
37-
using __standard_header_ccomplex _LIBCPP_DEPRECATED_("Include <complex> instead.") _LIBCPP_NODEBUG = void;
38-
using __use_standard_header_ccomplex _LIBCPP_NODEBUG = __standard_header_ccomplex;
39-
29+
# if _LIBCPP_STD_VER >= 17 && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS
30+
# warning <ccomplex> is removed in C++20. Include <complex> instead.
4031
# endif
32+
4133
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
4234

4335
#endif // _LIBCPP_CCOMPLEX

libcxx/include/ciso646

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424
# pragma GCC system_header
2525
# endif
2626

27-
# if _LIBCPP_STD_VER >= 20
28-
29-
using __standard_header_ciso646
30-
_LIBCPP_DEPRECATED_("removed in C++20. Include <version> instead.") _LIBCPP_NODEBUG = void;
31-
using __use_standard_header_ciso646 _LIBCPP_NODEBUG = __standard_header_ciso646;
32-
27+
# if _LIBCPP_STD_VER >= 20 && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS
28+
# warning <ciso646> is removed in C++20. Include <version> instead.
3329
# endif
30+
3431
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
3532

3633
#endif // _LIBCPP_CISO646

libcxx/include/cstdalign

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,10 @@ Macros:
4343
# undef __alignof_is_defined
4444
# define __alignof_is_defined 1
4545

46-
# if _LIBCPP_STD_VER >= 20
47-
48-
using __standard_header_cstdalign _LIBCPP_DEPRECATED_("removed in C++20.") _LIBCPP_NODEBUG = void;
49-
using __use_standard_header_cstdalign _LIBCPP_NODEBUG = __standard_header_cstdalign;
50-
51-
# elif _LIBCPP_STD_VER >= 17
52-
53-
using __standard_header_cstdalign _LIBCPP_DEPRECATED _LIBCPP_NODEBUG = void;
54-
using __use_standard_header_cstdalign _LIBCPP_NODEBUG = __standard_header_cstdalign;
55-
46+
# if _LIBCPP_STD_VER >= 17 && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS
47+
# warning <cstdalign> is removed in C++20.
5648
# endif
49+
5750
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
5851

5952
#endif // _LIBCPP_CSTDALIGN

libcxx/include/cstdbool

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,10 @@ Macros:
3131
# undef __bool_true_false_are_defined
3232
# define __bool_true_false_are_defined 1
3333

34-
# if _LIBCPP_STD_VER >= 20
35-
36-
using __standard_header_cstdbool _LIBCPP_DEPRECATED_("removed in C++20.") _LIBCPP_NODEBUG = void;
37-
using __use_standard_header_cstdbool _LIBCPP_NODEBUG = __standard_header_cstdbool;
38-
39-
# elif _LIBCPP_STD_VER >= 17
40-
41-
using __standard_header_cstdbool _LIBCPP_DEPRECATED _LIBCPP_NODEBUG = void;
42-
using __use_standard_header_cstdbool _LIBCPP_NODEBUG = __standard_header_cstdbool;
43-
34+
# if _LIBCPP_STD_VER >= 17 && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS
35+
# warning <cstdbool> is removed in C++20.
4436
# endif
37+
4538
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
4639

4740
#endif // _LIBCPP_CSTDBOOL

libcxx/include/ctgmath

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,8 @@
2828
# pragma GCC system_header
2929
# endif
3030

31-
# if _LIBCPP_STD_VER >= 20
32-
33-
using __standard_header_ctgmath
34-
_LIBCPP_DEPRECATED_("removed in C++20. Include <cmath> and <complex> instead.") _LIBCPP_NODEBUG = void;
35-
using __use_standard_header_ctgmath _LIBCPP_NODEBUG = __standard_header_ctgmath;
36-
37-
# elif _LIBCPP_STD_VER >= 17
38-
39-
using __standard_header_ctgmath _LIBCPP_DEPRECATED_("Include <cmath> and <complex> instead.") _LIBCPP_NODEBUG = void;
40-
using __use_standard_header_ctgmath _LIBCPP_NODEBUG = __standard_header_ctgmath;
41-
31+
# if _LIBCPP_STD_VER >= 17 && _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS
32+
# warning <ctgmath> is removed in C++20. Include <cmath> and <complex> instead.
4233
# endif
4334

4435
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)

libcxx/test/libcxx/transitive_includes.gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
// UNSUPPORTED: LIBCXX-FREEBSD-FIXME
9090
9191
// RUN: mkdir %t
92-
// RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} --trace-includes -fshow-skipped-includes --preprocess > /dev/null 2> %t/trace-includes.txt
92+
// RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} -Wno-deprecated --trace-includes -fshow-skipped-includes --preprocess > /dev/null 2> %t/trace-includes.txt
9393
// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes/to_csv.py %t/trace-includes.txt > %t/actual_transitive_includes.csv
9494
// RUN: cat %{{libcxx-dir}}/test/libcxx/transitive_includes/%{{cxx_std}}.csv | awk '/^{escaped_header} / {{ print }}' > %t/expected_transitive_includes.csv
9595
// RUN: diff -w %t/expected_transitive_includes.csv %t/actual_transitive_includes.csv

libcxx/test/std/depr/depr.cpp.headers/ccomplex.verify.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
// UNSUPPORTED: c++03, c++11, c++14
1515
// UNSUPPORTED: clang-modules-build
1616

17-
#include "test_macros.h"
18-
1917
#include <ccomplex>
2018

21-
#if TEST_STD_VER >= 20
22-
// expected-warning@ccomplex:* {{'__standard_header_ccomplex' is deprecated: removed in C++20. Include <complex> instead.}}
23-
#else
24-
// expected-warning@ccomplex:* {{'__standard_header_ccomplex' is deprecated: Include <complex> instead.}}
25-
#endif
19+
// expected-warning@ccomplex:* {{<ccomplex> is removed in C++20. Include <complex> instead.}}

libcxx/test/std/depr/depr.cpp.headers/ciso646.verify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
// UNSUPPORTED: clang-modules-build
1616

1717
#include <ciso646>
18-
// expected-warning@ciso646:* {{'__standard_header_ciso646' is deprecated: removed in C++20. Include <version> instead.}}
18+
19+
// expected-warning@ciso646:* {{<ciso646> is removed in C++20. Include <version> instead.}}

libcxx/test/std/depr/depr.cpp.headers/cstdalign.verify.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414
// UNSUPPORTED: c++03, c++11, c++14
1515
// UNSUPPORTED: clang-modules-build
1616

17-
#include "test_macros.h"
18-
1917
#include <cstdalign>
2018

21-
#if TEST_STD_VER >= 20
22-
// expected-warning@cstdalign:* {{'__standard_header_cstdalign' is deprecated: removed in C++20.}}
23-
#else
24-
// expected-warning@cstdalign:* {{'__standard_header_cstdalign' is deprecated}}
25-
#endif
19+
// expected-warning@cstdalign:* {{<cstdalign> is removed in C++20.}}

0 commit comments

Comments
 (0)