Skip to content

Commit

Permalink
[libc++] Granularize <exception> includes
Browse files Browse the repository at this point in the history
Reviewed By: ldionne, #libc

Spies: mikhail.ramalho, smeenai, libcxx-commits

Differential Revision: https://reviews.llvm.org/D146097
  • Loading branch information
philnik777 committed Mar 19, 2023
1 parent 5b1145b commit c9d36bd
Show file tree
Hide file tree
Showing 21 changed files with 32 additions and 30 deletions.
3 changes: 1 addition & 2 deletions libcxx/include/__expected/bad_expected_access.h
Expand Up @@ -10,10 +10,9 @@
#define _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H

#include <__config>
#include <__exception/exception.h>
#include <__utility/move.h>

#include <exception>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__format/buffer.h
Expand Up @@ -27,6 +27,7 @@
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/wrap_iter.h>
#include <__memory/addressof.h>
#include <__type_traits/add_pointer.h>
#include <__utility/move.h>
#include <cstddef>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__functional/function.h
Expand Up @@ -12,6 +12,7 @@

#include <__assert>
#include <__config>
#include <__exception/exception.h>
#include <__functional/binary_function.h>
#include <__functional/invoke.h>
#include <__functional/unary_function.h>
Expand All @@ -32,7 +33,6 @@
#include <__utility/piecewise_construct.h>
#include <__utility/swap.h>
#include <__verbose_abort>
#include <exception>
#include <new>
#include <tuple>
#include <typeinfo>
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/__ranges/join_view.h
Expand Up @@ -22,6 +22,7 @@
#include <__iterator/iterator_traits.h>
#include <__iterator/iterator_with_data.h>
#include <__iterator/segmented_iterator.h>
#include <__memory/addressof.h>
#include <__ranges/access.h>
#include <__ranges/all.h>
#include <__ranges/concepts.h>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/functional
Expand Up @@ -543,7 +543,6 @@ POLICY: For non-variadic implementations, the number of arguments is limited
#include <__functional/unary_negate.h>
#include <__functional/unwrap_ref.h>
#include <__utility/forward.h>
#include <exception>
#include <memory> // TODO: find out why removing this breaks the modules build
#include <typeinfo>
#include <version>
Expand All @@ -555,6 +554,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <atomic>
# include <concepts>
# include <exception>
# include <tuple>
# include <type_traits>
# include <utility>
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/future
Expand Up @@ -366,6 +366,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
#include <__chrono/duration.h>
#include <__chrono/time_point.h>
#include <__config>
#include <__exception/exception_ptr.h>
#include <__memory/allocator_arg_t.h>
#include <__memory/allocator_destructor.h>
#include <__memory/shared_ptr.h>
Expand All @@ -377,8 +378,6 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
#include <__utility/auto_cast.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__verbose_abort>
#include <exception>
#include <mutex>
#include <new>
#include <system_error>
Expand Down Expand Up @@ -2461,6 +2460,7 @@ _LIBCPP_END_NAMESPACE_STD

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <atomic>
# include <exception>
#endif

#endif // _LIBCPP_FUTURE
1 change: 1 addition & 0 deletions libcxx/include/map
Expand Up @@ -549,6 +549,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
#include <__iterator/erase_if_container.h>
#include <__iterator/iterator_traits.h>
#include <__iterator/reverse_iterator.h>
#include <__memory/addressof.h>
#include <__memory/allocator.h>
#include <__memory_resource/polymorphic_allocator.h>
#include <__node_handle>
Expand Down
4 changes: 3 additions & 1 deletion libcxx/include/new
Expand Up @@ -89,13 +89,14 @@ void operator delete[](void* ptr, void*) noexcept;
#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
#include <__exception/exception.h>
#include <__type_traits/alignment_of.h>
#include <__type_traits/is_function.h>
#include <__type_traits/is_same.h>
#include <__type_traits/remove_cv.h>
#include <__verbose_abort>
#include <cstddef>
#include <cstdlib>
#include <exception>
#include <version>

#if defined(_LIBCPP_ABI_VCRUNTIME)
Expand Down Expand Up @@ -365,6 +366,7 @@ inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUC
_LIBCPP_END_NAMESPACE_STD

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <exception>
# include <type_traits>
#endif

Expand Down
1 change: 1 addition & 0 deletions libcxx/include/ostream
Expand Up @@ -165,6 +165,7 @@ basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, cons

#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__exception/operations.h>
#include <__memory/shared_ptr.h>
#include <__memory/unique_ptr.h>
#include <__type_traits/conjunction.h>
Expand Down
7 changes: 5 additions & 2 deletions libcxx/include/stdexcept
Expand Up @@ -43,9 +43,8 @@ public:

#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__verbose_abort>
#include <__exception/exception.h>
#include <cstdlib>
#include <exception>
#include <iosfwd> // for string forward decl

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

_LIBCPP_END_NAMESPACE_STD

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <exception>
#endif

#endif // _LIBCPP_STDEXCEPT
2 changes: 2 additions & 0 deletions libcxx/include/thread
Expand Up @@ -85,7 +85,9 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);

#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__exception/terminate.h>
#include <__functional/hash.h>
#include <__memory/addressof.h>
#include <__memory/unique_ptr.h>
#include <__mutex_base>
#include <__thread/poll_with_backoff.h>
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/typeinfo
Expand Up @@ -59,12 +59,12 @@ public:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__availability>
#include <__config>
#include <__exception/exception.h>
#include <__type_traits/is_constant_evaluated.h>
#include <__verbose_abort>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <exception>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
Expand Down Expand Up @@ -415,6 +415,7 @@ void __throw_bad_cast()
_LIBCPP_END_NAMESPACE_STD

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <exception>
# include <type_traits>
#endif

Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/variant
Expand Up @@ -210,6 +210,7 @@ namespace std {
#include <__compare/compare_three_way_result.h>
#include <__compare/three_way_comparable.h>
#include <__config>
#include <__exception/exception.h>
#include <__functional/hash.h>
#include <__functional/invoke.h>
#include <__functional/operations.h>
Expand Down Expand Up @@ -239,7 +240,6 @@ namespace std {
#include <__utility/swap.h>
#include <__variant/monostate.h>
#include <__verbose_abort>
#include <exception>
#include <initializer_list>
#include <limits>
#include <new>
Expand Down Expand Up @@ -1834,6 +1834,7 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <exception>
# include <type_traits>
# include <typeinfo>
# include <utility>
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx03.csv
Expand Up @@ -213,7 +213,6 @@ exception version
execution version
expected cstddef
expected cstdlib
expected exception
expected initializer_list
expected new
expected version
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx11.csv
Expand Up @@ -213,7 +213,6 @@ exception version
execution version
expected cstddef
expected cstdlib
expected exception
expected initializer_list
expected new
expected version
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx14.csv
Expand Up @@ -213,7 +213,6 @@ exception version
execution version
expected cstddef
expected cstdlib
expected exception
expected initializer_list
expected new
expected version
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx17.csv
Expand Up @@ -213,7 +213,6 @@ exception version
execution version
expected cstddef
expected cstdlib
expected exception
expected initializer_list
expected new
expected version
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/transitive_includes/cxx20.csv
Expand Up @@ -220,7 +220,6 @@ exception version
execution version
expected cstddef
expected cstdlib
expected exception
expected initializer_list
expected new
expected version
Expand Down
7 changes: 0 additions & 7 deletions libcxx/test/libcxx/transitive_includes/cxx2b.csv
Expand Up @@ -151,7 +151,6 @@ exception version
execution version
expected cstddef
expected cstdlib
expected exception
expected initializer_list
expected new
expected version
Expand Down Expand Up @@ -277,7 +276,6 @@ functional cstddef
functional cstdint
functional cstdlib
functional cstring
functional exception
functional initializer_list
functional iosfwd
functional limits
Expand All @@ -293,7 +291,6 @@ future cstddef
future cstdint
future cstdlib
future cstring
future exception
future initializer_list
future iosfwd
future limits
Expand Down Expand Up @@ -420,7 +417,6 @@ mutex typeinfo
mutex version
new cstddef
new cstdlib
new exception
new version
numbers version
numeric cmath
Expand Down Expand Up @@ -548,7 +544,6 @@ stack deque
stack initializer_list
stack version
stdexcept cstdlib
stdexcept exception
stdexcept iosfwd
streambuf cstdint
streambuf ios
Expand Down Expand Up @@ -618,7 +613,6 @@ typeindex version
typeinfo cstddef
typeinfo cstdint
typeinfo cstdlib
typeinfo exception
unordered_map cmath
unordered_map compare
unordered_map cstddef
Expand Down Expand Up @@ -663,7 +657,6 @@ variant compare
variant cstddef
variant cstdint
variant cstring
variant exception
variant initializer_list
variant limits
variant new
Expand Down
Expand Up @@ -55,13 +55,14 @@
// that terminate has been called)


#include <condition_variable>
#include <atomic>
#include <thread>
#include <cassert>
#include <chrono>
#include <string>
#include <condition_variable>
#include <cstdlib>
#include <cassert>
#include <exception>
#include <string>
#include <thread>

#include "make_test_thread.h"

Expand Down
Expand Up @@ -15,10 +15,11 @@

// ~thread();

#include <thread>
#include <new>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <exception>
#include <new>
#include <thread>

#include "make_test_thread.h"
#include "test_macros.h"
Expand Down

0 comments on commit c9d36bd

Please sign in to comment.