Skip to content

Commit c9d36bd

Browse files
committed
[libc++] Granularize <exception> includes
Reviewed By: ldionne, #libc Spies: mikhail.ramalho, smeenai, libcxx-commits Differential Revision: https://reviews.llvm.org/D146097
1 parent 5b1145b commit c9d36bd

File tree

21 files changed

+32
-30
lines changed

21 files changed

+32
-30
lines changed

libcxx/include/__expected/bad_expected_access.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
#define _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
1111

1212
#include <__config>
13+
#include <__exception/exception.h>
1314
#include <__utility/move.h>
1415

15-
#include <exception>
16-
1716
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1817
# pragma GCC system_header
1918
#endif

libcxx/include/__format/buffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <__iterator/incrementable_traits.h>
2828
#include <__iterator/iterator_traits.h>
2929
#include <__iterator/wrap_iter.h>
30+
#include <__memory/addressof.h>
3031
#include <__type_traits/add_pointer.h>
3132
#include <__utility/move.h>
3233
#include <cstddef>

libcxx/include/__functional/function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <__assert>
1414
#include <__config>
15+
#include <__exception/exception.h>
1516
#include <__functional/binary_function.h>
1617
#include <__functional/invoke.h>
1718
#include <__functional/unary_function.h>
@@ -32,7 +33,6 @@
3233
#include <__utility/piecewise_construct.h>
3334
#include <__utility/swap.h>
3435
#include <__verbose_abort>
35-
#include <exception>
3636
#include <new>
3737
#include <tuple>
3838
#include <typeinfo>

libcxx/include/__ranges/join_view.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <__iterator/iterator_traits.h>
2323
#include <__iterator/iterator_with_data.h>
2424
#include <__iterator/segmented_iterator.h>
25+
#include <__memory/addressof.h>
2526
#include <__ranges/access.h>
2627
#include <__ranges/all.h>
2728
#include <__ranges/concepts.h>

libcxx/include/functional

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,6 @@ POLICY: For non-variadic implementations, the number of arguments is limited
543543
#include <__functional/unary_negate.h>
544544
#include <__functional/unwrap_ref.h>
545545
#include <__utility/forward.h>
546-
#include <exception>
547546
#include <memory> // TODO: find out why removing this breaks the modules build
548547
#include <typeinfo>
549548
#include <version>
@@ -555,6 +554,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
555554
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
556555
# include <atomic>
557556
# include <concepts>
557+
# include <exception>
558558
# include <tuple>
559559
# include <type_traits>
560560
# include <utility>

libcxx/include/future

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
366366
#include <__chrono/duration.h>
367367
#include <__chrono/time_point.h>
368368
#include <__config>
369+
#include <__exception/exception_ptr.h>
369370
#include <__memory/allocator_arg_t.h>
370371
#include <__memory/allocator_destructor.h>
371372
#include <__memory/shared_ptr.h>
@@ -377,8 +378,6 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
377378
#include <__utility/auto_cast.h>
378379
#include <__utility/forward.h>
379380
#include <__utility/move.h>
380-
#include <__verbose_abort>
381-
#include <exception>
382381
#include <mutex>
383382
#include <new>
384383
#include <system_error>
@@ -2461,6 +2460,7 @@ _LIBCPP_END_NAMESPACE_STD
24612460

24622461
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
24632462
# include <atomic>
2463+
# include <exception>
24642464
#endif
24652465

24662466
#endif // _LIBCPP_FUTURE

libcxx/include/map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
549549
#include <__iterator/erase_if_container.h>
550550
#include <__iterator/iterator_traits.h>
551551
#include <__iterator/reverse_iterator.h>
552+
#include <__memory/addressof.h>
552553
#include <__memory/allocator.h>
553554
#include <__memory_resource/polymorphic_allocator.h>
554555
#include <__node_handle>

libcxx/include/new

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ void operator delete[](void* ptr, void*) noexcept;
8989
#include <__assert> // all public C++ headers provide the assertion handler
9090
#include <__availability>
9191
#include <__config>
92+
#include <__exception/exception.h>
93+
#include <__type_traits/alignment_of.h>
9294
#include <__type_traits/is_function.h>
9395
#include <__type_traits/is_same.h>
9496
#include <__type_traits/remove_cv.h>
9597
#include <__verbose_abort>
9698
#include <cstddef>
9799
#include <cstdlib>
98-
#include <exception>
99100
#include <version>
100101

101102
#if defined(_LIBCPP_ABI_VCRUNTIME)
@@ -365,6 +366,7 @@ inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUC
365366
_LIBCPP_END_NAMESPACE_STD
366367

367368
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
369+
# include <exception>
368370
# include <type_traits>
369371
#endif
370372

libcxx/include/ostream

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, cons
165165

166166
#include <__assert> // all public C++ headers provide the assertion handler
167167
#include <__config>
168+
#include <__exception/operations.h>
168169
#include <__memory/shared_ptr.h>
169170
#include <__memory/unique_ptr.h>
170171
#include <__type_traits/conjunction.h>

libcxx/include/stdexcept

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ public:
4343

4444
#include <__assert> // all public C++ headers provide the assertion handler
4545
#include <__config>
46-
#include <__verbose_abort>
46+
#include <__exception/exception.h>
4747
#include <cstdlib>
48-
#include <exception>
4948
#include <iosfwd> // for string forward decl
5049

5150
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -300,4 +299,8 @@ void __throw_underflow_error(const char*__msg)
300299

301300
_LIBCPP_END_NAMESPACE_STD
302301

302+
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
303+
# include <exception>
304+
#endif
305+
303306
#endif // _LIBCPP_STDEXCEPT

libcxx/include/thread

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
8585

8686
#include <__assert> // all public C++ headers provide the assertion handler
8787
#include <__config>
88+
#include <__exception/terminate.h>
8889
#include <__functional/hash.h>
90+
#include <__memory/addressof.h>
8991
#include <__memory/unique_ptr.h>
9092
#include <__mutex_base>
9193
#include <__thread/poll_with_backoff.h>

libcxx/include/typeinfo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ public:
5959
#include <__assert> // all public C++ headers provide the assertion handler
6060
#include <__availability>
6161
#include <__config>
62+
#include <__exception/exception.h>
6263
#include <__type_traits/is_constant_evaluated.h>
6364
#include <__verbose_abort>
6465
#include <cstddef>
6566
#include <cstdint>
6667
#include <cstdlib>
67-
#include <exception>
6868

6969
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
7070
# pragma GCC system_header
@@ -415,6 +415,7 @@ void __throw_bad_cast()
415415
_LIBCPP_END_NAMESPACE_STD
416416

417417
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
418+
# include <exception>
418419
# include <type_traits>
419420
#endif
420421

libcxx/include/variant

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ namespace std {
210210
#include <__compare/compare_three_way_result.h>
211211
#include <__compare/three_way_comparable.h>
212212
#include <__config>
213+
#include <__exception/exception.h>
213214
#include <__functional/hash.h>
214215
#include <__functional/invoke.h>
215216
#include <__functional/operations.h>
@@ -239,7 +240,6 @@ namespace std {
239240
#include <__utility/swap.h>
240241
#include <__variant/monostate.h>
241242
#include <__verbose_abort>
242-
#include <exception>
243243
#include <initializer_list>
244244
#include <limits>
245245
#include <new>
@@ -1834,6 +1834,7 @@ _LIBCPP_END_NAMESPACE_STD
18341834
_LIBCPP_POP_MACROS
18351835

18361836
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1837+
# include <exception>
18371838
# include <type_traits>
18381839
# include <typeinfo>
18391840
# include <utility>

libcxx/test/libcxx/transitive_includes/cxx03.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ exception version
213213
execution version
214214
expected cstddef
215215
expected cstdlib
216-
expected exception
217216
expected initializer_list
218217
expected new
219218
expected version

libcxx/test/libcxx/transitive_includes/cxx11.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ exception version
213213
execution version
214214
expected cstddef
215215
expected cstdlib
216-
expected exception
217216
expected initializer_list
218217
expected new
219218
expected version

libcxx/test/libcxx/transitive_includes/cxx14.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ exception version
213213
execution version
214214
expected cstddef
215215
expected cstdlib
216-
expected exception
217216
expected initializer_list
218217
expected new
219218
expected version

libcxx/test/libcxx/transitive_includes/cxx17.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ exception version
213213
execution version
214214
expected cstddef
215215
expected cstdlib
216-
expected exception
217216
expected initializer_list
218217
expected new
219218
expected version

libcxx/test/libcxx/transitive_includes/cxx20.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ exception version
220220
execution version
221221
expected cstddef
222222
expected cstdlib
223-
expected exception
224223
expected initializer_list
225224
expected new
226225
expected version

libcxx/test/libcxx/transitive_includes/cxx2b.csv

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ exception version
151151
execution version
152152
expected cstddef
153153
expected cstdlib
154-
expected exception
155154
expected initializer_list
156155
expected new
157156
expected version
@@ -277,7 +276,6 @@ functional cstddef
277276
functional cstdint
278277
functional cstdlib
279278
functional cstring
280-
functional exception
281279
functional initializer_list
282280
functional iosfwd
283281
functional limits
@@ -293,7 +291,6 @@ future cstddef
293291
future cstdint
294292
future cstdlib
295293
future cstring
296-
future exception
297294
future initializer_list
298295
future iosfwd
299296
future limits
@@ -420,7 +417,6 @@ mutex typeinfo
420417
mutex version
421418
new cstddef
422419
new cstdlib
423-
new exception
424420
new version
425421
numbers version
426422
numeric cmath
@@ -548,7 +544,6 @@ stack deque
548544
stack initializer_list
549545
stack version
550546
stdexcept cstdlib
551-
stdexcept exception
552547
stdexcept iosfwd
553548
streambuf cstdint
554549
streambuf ios
@@ -618,7 +613,6 @@ typeindex version
618613
typeinfo cstddef
619614
typeinfo cstdint
620615
typeinfo cstdlib
621-
typeinfo exception
622616
unordered_map cmath
623617
unordered_map compare
624618
unordered_map cstddef
@@ -663,7 +657,6 @@ variant compare
663657
variant cstddef
664658
variant cstdint
665659
variant cstring
666-
variant exception
667660
variant initializer_list
668661
variant limits
669662
variant new

libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@
5555
// that terminate has been called)
5656

5757

58-
#include <condition_variable>
5958
#include <atomic>
60-
#include <thread>
59+
#include <cassert>
6160
#include <chrono>
62-
#include <string>
61+
#include <condition_variable>
6362
#include <cstdlib>
64-
#include <cassert>
63+
#include <exception>
64+
#include <string>
65+
#include <thread>
6566

6667
#include "make_test_thread.h"
6768

libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515

1616
// ~thread();
1717

18-
#include <thread>
19-
#include <new>
20-
#include <cstdlib>
2118
#include <cassert>
19+
#include <cstdlib>
20+
#include <exception>
21+
#include <new>
22+
#include <thread>
2223

2324
#include "make_test_thread.h"
2425
#include "test_macros.h"

0 commit comments

Comments
 (0)