[libc++] Granularize algorithm includes
authorNikolas Klauser <nikolasklauser@berlin.de>
Tue, 15 Feb 2022 17:18:08 +0000 (18:18 +0100)
committerNikolas Klauser <nikolasklauser@berlin.de>
Wed, 16 Feb 2022 03:12:22 +0000 (04:12 +0100)
Reviewed By: Mordante, ldionne, Quuxplusone, #libc, #libc_abi

Spies: #libc_vendors, libcxx-commits, miyuki

Differential Revision: https://reviews.llvm.org/D119667

35 files changed:
libcxx/docs/ReleaseNotes.rst
libcxx/include/__bit_reference
libcxx/include/__filesystem/path.h
libcxx/include/__format/formatter.h
libcxx/include/__hash_table
libcxx/include/__split_buffer
libcxx/include/__tree
libcxx/include/array
libcxx/include/bitset
libcxx/include/deque
libcxx/include/experimental/functional
libcxx/include/experimental/simd
libcxx/include/ext/hash_map
libcxx/include/ext/hash_set
libcxx/include/format
libcxx/include/forward_list
libcxx/include/fstream
libcxx/include/list
libcxx/include/locale
libcxx/include/map
libcxx/include/queue
libcxx/include/random
libcxx/include/regex
libcxx/include/set
libcxx/include/string
libcxx/include/string_view
libcxx/include/unordered_map
libcxx/include/unordered_set
libcxx/include/valarray
libcxx/include/vector
libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/deduct.pass.cpp
libcxx/test/std/containers/sequences/list/list.ops/sort.pass.cpp
libcxx/test/std/utilities/format/format.formatter/format.formatter.spec/formatter.floating_point.pass.cpp
libcxxabi/src/demangle/Utility.h
libcxxabi/test/test_demangle.pass.cpp

index 0b77702..c57a7de 100644 (file)
@@ -52,6 +52,10 @@ API Changes
   ``<filesystem>`` header. The associated macro
   ``_LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM`` has also been removed.
 
+- Transitive includes of ``<algorithm>`` have been removed. If you see compiler errors
+  related to missing declarations inside namespace ``std`` when updating libc++,
+  you are probably missing ``#include <algorithm>`` in a file where you use algorithms.
+
 ABI Changes
 -----------
 
index 482738f..423acee 100644 (file)
 #ifndef _LIBCPP___BIT_REFERENCE
 #define _LIBCPP___BIT_REFERENCE
 
+#include <__algorithm/min.h>
 #include <__bits>
 #include <__config>
-#include <algorithm>
+#include <__iterator/iterator_traits.h>
+#include <__memory/pointer_traits.h>
+#include <cstring>
+#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
index 89b5107..6b4b1ae 100644 (file)
@@ -10,6 +10,8 @@
 #ifndef _LIBCPP___FILESYSTEM_PATH_H
 #define _LIBCPP___FILESYSTEM_PATH_H
 
+#include <__algorithm/replace.h>
+#include <__algorithm/replace_copy.h>
 #include <__availability>
 #include <__config>
 #include <__iterator/back_insert_iterator.h>
index 1f42314..7e1ae31 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <__algorithm/copy.h>
 #include <__algorithm/fill_n.h>
+#include <__algorithm/transform.h>
 #include <__availability>
 #include <__config>
 #include <__format/format_error.h>
index cce9145..6b1f65c 100644 (file)
 #ifndef _LIBCPP__HASH_TABLE
 #define _LIBCPP__HASH_TABLE
 
+#include <__algorithm/max.h>
+#include <__algorithm/min.h>
 #include <__bits> // __libcpp_clz
 #include <__config>
 #include <__debug>
-#include <algorithm>
+#include <__functional/hash.h>
 #include <cmath>
 #include <initializer_list>
 #include <iterator>
index bd6d231..9565e16 100644 (file)
@@ -2,9 +2,17 @@
 #ifndef _LIBCPP_SPLIT_BUFFER
 #define _LIBCPP_SPLIT_BUFFER
 
+#include <__algorithm/max.h>
+#include <__algorithm/move.h>
+#include <__algorithm/move_backward.h>
 #include <__config>
+#include <__iterator/distance.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/move_iterator.h>
+#include <__memory/allocator.h>
+#include <__memory/compressed_pair.h>
 #include <__utility/forward.h>
-#include <algorithm>
+#include <memory>
 #include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
index 2733a1e..eeb6b11 100644 (file)
@@ -10,9 +10,9 @@
 #ifndef _LIBCPP___TREE
 #define _LIBCPP___TREE
 
+#include <__algorithm/min.h>
 #include <__config>
 #include <__utility/forward.h>
-#include <algorithm>
 #include <iterator>
 #include <limits>
 #include <memory>
index 8d6a3b5..e55ee43 100644 (file)
@@ -108,11 +108,14 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
 
 */
 
+#include <__algorithm/equal.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/swap_ranges.h>
 #include <__config>
 #include <__debug>
 #include <__tuple>
 #include <__utility/unreachable.h>
-#include <algorithm>
 #include <iterator>
 #include <stdexcept>
 #include <type_traits>
index fa37e70..875e8ef 100644 (file)
@@ -112,8 +112,10 @@ template <size_t N> struct hash<std::bitset<N>>;
 
 */
 
+#include <__algorithm/fill.h>
 #include <__bit_reference>
 #include <__config>
+#include <__functional/unary_function.h>
 #include <climits>
 #include <cstddef>
 #include <iosfwd>
index 33e7134..fc96475 100644 (file)
@@ -160,12 +160,20 @@ template <class T, class Allocator, class Predicate>
 
 */
 
+#include <__algorithm/copy.h>
+#include <__algorithm/copy_backward.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/min.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
+#include <__algorithm/unwrap_iter.h>
 #include <__config>
 #include <__debug>
 #include <__iterator/iterator_traits.h>
 #include <__split_buffer>
 #include <__utility/forward.h>
-#include <algorithm>
 #include <compare>
 #include <initializer_list>
 #include <iterator>
index de21ab6..087f7c9 100644 (file)
@@ -62,7 +62,6 @@ inline namespace fundamentals_v1 {
 
 #include <__debug>
 #include <__memory/uses_allocator.h>
-#include <algorithm>
 #include <array>
 #include <experimental/__config>
 #include <functional>
index 6e8bfab..31426a9 100644 (file)
@@ -649,7 +649,6 @@ public:
 
 */
 
-#include <algorithm>
 #include <array>
 #include <cstddef>
 #include <experimental/__config>
index 4d9c08c..1816626 100644 (file)
@@ -201,6 +201,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
 
 */
 
+#include <__algorithm/is_permutation.h>
 #include <__config>
 #include <__hash_table>
 #include <ext/__hash>
index 254f482..cbd621b 100644 (file)
@@ -192,6 +192,7 @@ template <class Value, class Hash, class Pred, class Alloc>
 
 */
 
+#include <__algorithm/is_permutation.h>
 #include <__config>
 #include <__hash_table>
 #include <ext/__hash>
index 03c25f1..356a305 100644 (file)
@@ -122,6 +122,7 @@ namespace std {
 // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES.
 #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
 
+#include <__algorithm/clamp.h>
 #include <__config>
 #include <__debug>
 #include <__format/format_arg.h>
index 5e864fe..e01a8e7 100644 (file)
@@ -179,9 +179,11 @@ template <class T, class Allocator, class Predicate>
 
 */
 
+#include <__algorithm/comp.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/min.h>
 #include <__config>
 #include <__utility/forward.h>
-#include <algorithm>
 #include <initializer_list>
 #include <iterator>
 #include <limits>
index 9ee3d14..d7d8fb1 100644 (file)
@@ -179,6 +179,7 @@ typedef basic_fstream<wchar_t> wfstream;
 
 */
 
+#include <__algorithm/max.h>
 #include <__availability>
 #include <__config>
 #include <__debug>
index 91e2c97..c643cb5 100644 (file)
@@ -180,10 +180,13 @@ template <class T, class Allocator, class Predicate>
 
 */
 
+#include <__algorithm/comp.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/min.h>
 #include <__config>
 #include <__debug>
 #include <__utility/forward.h>
-#include <algorithm>
 #include <initializer_list>
 #include <iterator>
 #include <limits>
index ed2b971..fa82d44 100644 (file)
@@ -187,10 +187,14 @@ template <class charT> class messages_byname;
 
 */
 
+#include <__algorithm/equal.h>
+#include <__algorithm/find.h>
+#include <__algorithm/max.h>
+#include <__algorithm/reverse.h>
+#include <__algorithm/unwrap_iter.h>
 #include <__config>
 #include <__debug>
 #include <__locale>
-#include <algorithm>
 #ifndef __APPLE__
 # include <cstdarg>
 #endif
index cb856fa..a68c6d1 100644 (file)
@@ -528,6 +528,8 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred);  // C++20
 
 */
 
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
 #include <__config>
 #include <__debug>
 #include <__functional/is_transparent.h>
index fe0af16..b8b7ec4 100644 (file)
@@ -217,11 +217,13 @@ template <class T, class Container, class Compare>
 
 */
 
+#include <__algorithm/make_heap.h>
+#include <__algorithm/pop_heap.h>
+#include <__algorithm/push_heap.h>
 #include <__config>
 #include <__iterator/iterator_traits.h>
 #include <__memory/uses_allocator.h>
 #include <__utility/forward.h>
-#include <algorithm>
 #include <compare>
 #include <deque>
 #include <functional>
index 0c7d490..cf1ac24 100644 (file)
@@ -1717,7 +1717,6 @@ class piecewise_linear_distribution
 #include <initializer_list>
 #include <version>
 
-#include <algorithm>   // for backward compatibility; TODO remove it
 #include <cmath>       // for backward compatibility; TODO remove it
 #include <cstddef>     // for backward compatibility; TODO remove it
 #include <cstdint>     // for backward compatibility; TODO remove it
index f2b53f1..dadd7b9 100644 (file)
@@ -762,6 +762,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
 } // std
 */
 
+#include <__algorithm/find.h>
 #include <__config>
 #include <__debug>
 #include <__iterator/wrap_iter.h>
index 898fa6c..b346e57 100644 (file)
@@ -471,6 +471,8 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred);  // C++20
 
 */
 
+#include <__algorithm/equal.h>
+#include <__algorithm/lexicographical_compare.h>
 #include <__config>
 #include <__debug>
 #include <__functional/is_transparent.h>
index 809ae41..3e7f2e9 100644 (file)
@@ -518,11 +518,14 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1
 
 */
 
+#include <__algorithm/max.h>
+#include <__algorithm/min.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
 #include <__config>
 #include <__debug>
 #include <__ios/fpos.h>
 #include <__iterator/wrap_iter.h>
-#include <algorithm>
 #include <compare>
 #include <cstdio>  // EOF
 #include <cstdlib>
index 48fd083..a5256fb 100644 (file)
@@ -195,6 +195,7 @@ namespace std {
 
 */
 
+#include <__algorithm/min.h>
 #include <__config>
 #include <__debug>
 #include <__ranges/concepts.h>
@@ -203,7 +204,6 @@ namespace std {
 #include <__ranges/enable_view.h>
 #include <__ranges/size.h>
 #include <__string>
-#include <algorithm>
 #include <compare>
 #include <iosfwd>
 #include <iterator>
index f0f5d1c..34c3d18 100644 (file)
@@ -514,6 +514,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
 
 */
 
+#include <__algorithm/is_permutation.h>
 #include <__config>
 #include <__debug>
 #include <__functional/is_transparent.h>
index b3a653f..bf972be 100644 (file)
@@ -459,6 +459,7 @@ template <class Value, class Hash, class Pred, class Alloc>
 
 */
 
+#include <__algorithm/is_permutation.h>
 #include <__config>
 #include <__debug>
 #include <__functional/is_transparent.h>
index 5536398..ac1ca9b 100644 (file)
@@ -341,8 +341,14 @@ template <class T> unspecified2 end(const valarray<T>& v);
 
 */
 
+#include <__algorithm/copy.h>
+#include <__algorithm/count.h>
+#include <__algorithm/fill.h>
+#include <__algorithm/max_element.h>
+#include <__algorithm/min.h>
+#include <__algorithm/min_element.h>
+#include <__algorithm/unwrap_iter.h>
 #include <__config>
-#include <algorithm>
 #include <cmath>
 #include <cstddef>
 #include <functional>
index 43584e0..26683ae 100644 (file)
@@ -271,14 +271,22 @@ erase_if(vector<T, Allocator>& c, Predicate pred);    // C++20
 
 */
 
+#include <__algorithm/copy.h>
+#include <__algorithm/equal.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/lexicographical_compare.h>
+#include <__algorithm/remove.h>
+#include <__algorithm/remove_if.h>
+#include <__algorithm/rotate.h>
+#include <__algorithm/unwrap_iter.h>
 #include <__bit_reference>
 #include <__config>
 #include <__debug>
+#include <__functional/hash.h>
 #include <__iterator/iterator_traits.h>
 #include <__iterator/wrap_iter.h>
 #include <__split_buffer>
 #include <__utility/forward.h>
-#include <algorithm>
 #include <climits>
 #include <compare>
 #include <cstdlib>
index 61f31af..74eb69b 100644 (file)
@@ -14,6 +14,7 @@
 //    -> forward_list<typename iterator_traits<InputIterator>::value_type, Allocator>;
 //
 
+#include <algorithm>
 #include <forward_list>
 #include <iterator>
 #include <cassert>
index 97272ae..4ec821c 100644 (file)
@@ -17,6 +17,7 @@
 #define DEMANGLE_UTILITY_H
 
 #include "StringView.h"
+#include <algorithm>
 #include <array>
 #include <cstdint>
 #include <cstdlib>
index 5371f4b..cc9e4ac 100644 (file)
@@ -15,6 +15,7 @@
 // UNSUPPORTED: use_system_cxx_lib && target={{.+}}-apple-macosx11.0
 
 #include "support/timer.h"
+#include <algorithm>
 #include <cassert>
 #include <cstdio>
 #include <cstdlib>