public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed 1/3] libstdc++: Make headers include their prerequisites
@ 2022-05-26 12:36 Jonathan Wakely
  2022-05-26 12:36 ` [committed 2/3] libstdc++: Remove some unnecessary includes Jonathan Wakely
  2022-05-26 12:36 ` [committed 3/3] libstdc++: Refactor includes for unordered containers Jonathan Wakely
  0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Wakely @ 2022-05-26 12:36 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: Nathan Sidwell

From: Nathan Sidwell <nathan@acm.org>

Tested powerpc64le-linux, pushed to trunk.

-- >8 --

These headers were relying on their includers having already included
some prerequisites.  That makes them unsuitable to be header-units.

So directly include the needed headers.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h: Include required headers.
	* include/bits/hashtable_policy.h: Likewise.
	* include/bits/stl_heap.h: Likewise.
	* include/bits/stl_iterator_base_funcs.h: Likewise.
---
 libstdc++-v3/include/bits/hashtable.h               | 2 ++
 libstdc++-v3/include/bits/hashtable_policy.h        | 2 ++
 libstdc++-v3/include/bits/stl_heap.h                | 1 +
 libstdc++-v3/include/bits/stl_iterator_base_funcs.h | 1 +
 4 files changed, 6 insertions(+)

diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h
index 5e1a417f7cd..edc151ef15b 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -37,6 +37,8 @@
 #if __cplusplus > 201402L
 # include <bits/node_handle.h>
 #endif
+#include <bits/functional_hash.h>
+#include <bits/stl_function.h> // equal_to, _Identity, _Select1st
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index 0f0b0f9ea51..799c3e986b4 100644
--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -33,6 +33,8 @@
 
 #include <tuple>		// for std::tuple, std::forward_as_tuple
 #include <bits/stl_algobase.h>	// for std::min, std::is_permutation.
+#include <ext/aligned_buffer.h>	// for __gnu_cxx::__aligned_buffer
+#include <ext/alloc_traits.h>	// for std::__alloc_rebind
 #include <ext/numeric_traits.h>	// for __gnu_cxx::__int_traits
 
 namespace std _GLIBCXX_VISIBILITY(default)
diff --git a/libstdc++-v3/include/bits/stl_heap.h b/libstdc++-v3/include/bits/stl_heap.h
index 6e08f81c115..eee946c3818 100644
--- a/libstdc++-v3/include/bits/stl_heap.h
+++ b/libstdc++-v3/include/bits/stl_heap.h
@@ -58,6 +58,7 @@
 #include <debug/debug.h>
 #include <bits/move.h>
 #include <bits/predefined_ops.h>
+#include <bits/stl_iterator_base_funcs.h>
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
index e9dc54cc628..1551b226ff4 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
@@ -63,6 +63,7 @@
 
 #include <bits/concept_check.h>
 #include <debug/assertions.h>
+#include <bits/stl_iterator_base_types.h>
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-- 
2.34.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [committed 2/3] libstdc++: Remove some unnecessary includes
  2022-05-26 12:36 [committed 1/3] libstdc++: Make headers include their prerequisites Jonathan Wakely
@ 2022-05-26 12:36 ` Jonathan Wakely
  2022-05-26 12:36 ` [committed 3/3] libstdc++: Refactor includes for unordered containers Jonathan Wakely
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2022-05-26 12:36 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Tested powerpc64le-linux, pushed to trunk.

-- >8 --

These headers do not use anything in <bits/stl_iterator_base_types.h>
directly, and it's included by <bits/stl_iterator_base_funcs.h> and
<bits/stl_iterator.h> anyway, because they do need it.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algobase.h: Do not include
	<bits/stl_iterator_base_types.h>.
	* include/std/string: Likewise.
	* include/std/variant: Likewise.
---
 libstdc++-v3/include/bits/ranges_algobase.h | 1 -
 libstdc++-v3/include/std/string             | 1 -
 libstdc++-v3/include/std/variant            | 1 -
 3 files changed, 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/ranges_algobase.h b/libstdc++-v3/include/bits/ranges_algobase.h
index 1bbc44fc668..f6f0b9c83b0 100644
--- a/libstdc++-v3/include/bits/ranges_algobase.h
+++ b/libstdc++-v3/include/bits/ranges_algobase.h
@@ -33,7 +33,6 @@
 #if __cplusplus > 201703L
 
 #include <compare>
-#include <bits/stl_iterator_base_types.h>
 #include <bits/stl_iterator_base_funcs.h>
 #include <bits/stl_iterator.h>
 #include <bits/ranges_base.h> // ranges::begin, ranges::range etc.
diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string
index 24051663f74..4a0633067bd 100644
--- a/libstdc++-v3/include/std/string
+++ b/libstdc++-v3/include/std/string
@@ -42,7 +42,6 @@
 #include <bits/cpp_type_traits.h>
 #include <bits/localefwd.h>    // For operators >>, <<, and getline.
 #include <bits/ostream_insert.h>
-#include <bits/stl_iterator_base_types.h>
 #include <bits/stl_iterator_base_funcs.h>
 #include <bits/stl_iterator.h>
 #include <bits/stl_function.h> // For less
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index beed396fccb..c5f25ef6b47 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -40,7 +40,6 @@
 #include <bits/functional_hash.h>
 #include <bits/invoke.h>
 #include <bits/parse_numbers.h>
-#include <bits/stl_iterator_base_types.h>
 #include <bits/stl_iterator_base_funcs.h>
 #include <bits/stl_construct.h>
 #include <bits/utility.h> // in_place_index_t
-- 
2.34.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [committed 3/3] libstdc++: Refactor includes for unordered containers
  2022-05-26 12:36 [committed 1/3] libstdc++: Make headers include their prerequisites Jonathan Wakely
  2022-05-26 12:36 ` [committed 2/3] libstdc++: Remove some unnecessary includes Jonathan Wakely
@ 2022-05-26 12:36 ` Jonathan Wakely
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2022-05-26 12:36 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Tested powerpc64le-linux, pushed to trunk.

-- >8 --

This moves some #include directives to the relevant place. For example,
<bits/hashtable_policy.h> needs <bits/stl_pair.h> so should include it
directly instead of relying on <unordered_map> and <unordered_set> to do
so first.

libstdc++-v3/ChangeLog:

	* include/bits/functional_hash.h (__is_fast_hash): Add doxygen
	comment.
	* include/bits/hashtable.h: Do not include <bits/stl_function.h>
	here.
	* include/bits/hashtable_policy.h: Include <bits/stl_pair.h> and
	<bits/functional_hash.h>.
	* include/bits/unordered_map.h: Include required headers.
	* include/bits/unordered_set.h: Likewise.
	* include/std/unordered_map: Do not include headers for indirect
	dependencies.
	* include/std/unordered_set: Likewise.
---
 libstdc++-v3/include/bits/functional_hash.h  | 15 +++++++++++----
 libstdc++-v3/include/bits/hashtable.h        |  3 +--
 libstdc++-v3/include/bits/hashtable_policy.h |  2 ++
 libstdc++-v3/include/bits/unordered_map.h    |  5 +++++
 libstdc++-v3/include/bits/unordered_set.h    |  5 +++++
 libstdc++-v3/include/std/unordered_map       |  8 --------
 libstdc++-v3/include/std/unordered_set       |  8 --------
 7 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/libstdc++-v3/include/bits/functional_hash.h b/libstdc++-v3/include/bits/functional_hash.h
index c00113eff83..292c0ee03f7 100644
--- a/libstdc++-v3/include/bits/functional_hash.h
+++ b/libstdc++-v3/include/bits/functional_hash.h
@@ -280,10 +280,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// @} group hashes
 
-  // Hint about performance of hash functor. If not fast the hash-based
-  // containers will cache the hash code.
-  // Default behavior is to consider that hashers are fast unless specified
-  // otherwise.
+  /** Hint about performance of hash functions.
+   *
+   * If a given hash function object is not fast, the hash-based containers
+   * will cache the hash code.
+   * The default behavior is to consider that hashers are fast unless specified
+   * otherwise.
+   *
+   * Users can specialize this for their own hash functions in order to force
+   * caching of hash codes in unordered containers. Specializing this trait
+   * affects the ABI of the unordered containers, so use it carefully.
+   */
   template<typename _Hash>
     struct __is_fast_hash : public std::true_type
     { };
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h
index edc151ef15b..29ec1192f32 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -34,11 +34,10 @@
 
 #include <bits/hashtable_policy.h>
 #include <bits/enable_special_members.h>
+#include <bits/stl_function.h> // __has_is_transparent_t
 #if __cplusplus > 201402L
 # include <bits/node_handle.h>
 #endif
-#include <bits/functional_hash.h>
-#include <bits/stl_function.h> // equal_to, _Identity, _Select1st
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index 799c3e986b4..1a259702f98 100644
--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -32,7 +32,9 @@
 #define _HASHTABLE_POLICY_H 1
 
 #include <tuple>		// for std::tuple, std::forward_as_tuple
+#include <bits/functional_hash.h> // for __is_fast_hash
 #include <bits/stl_algobase.h>	// for std::min, std::is_permutation.
+#include <bits/stl_pair.h>	// for std::pair
 #include <ext/aligned_buffer.h>	// for __gnu_cxx::__aligned_buffer
 #include <ext/alloc_traits.h>	// for std::__alloc_rebind
 #include <ext/numeric_traits.h>	// for __gnu_cxx::__int_traits
diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h
index d5edfde8caf..5a3e6f61af2 100644
--- a/libstdc++-v3/include/bits/unordered_map.h
+++ b/libstdc++-v3/include/bits/unordered_map.h
@@ -30,6 +30,11 @@
 #ifndef _UNORDERED_MAP_H
 #define _UNORDERED_MAP_H
 
+#include <bits/hashtable.h>
+#include <bits/allocator.h>
+#include <bits/functional_hash.h> // hash
+#include <bits/stl_function.h>    // equal_to
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
diff --git a/libstdc++-v3/include/bits/unordered_set.h b/libstdc++-v3/include/bits/unordered_set.h
index d2fa2c51171..740bbafd4c9 100644
--- a/libstdc++-v3/include/bits/unordered_set.h
+++ b/libstdc++-v3/include/bits/unordered_set.h
@@ -30,6 +30,11 @@
 #ifndef _UNORDERED_SET_H
 #define _UNORDERED_SET_H
 
+#include <bits/hashtable.h>
+#include <bits/allocator.h>
+#include <bits/functional_hash.h> // hash
+#include <bits/stl_function.h>    // equal_to
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
diff --git a/libstdc++-v3/include/std/unordered_map b/libstdc++-v3/include/std/unordered_map
index e13bb9a2148..b50ec2a8de2 100644
--- a/libstdc++-v3/include/std/unordered_map
+++ b/libstdc++-v3/include/std/unordered_map
@@ -35,15 +35,7 @@
 # include <bits/c++0x_warning.h>
 #else
 
-#include <type_traits>
 #include <initializer_list>
-#include <bits/allocator.h>
-#include <ext/alloc_traits.h>
-#include <ext/aligned_buffer.h>
-#include <bits/stl_pair.h>
-#include <bits/stl_function.h> // equal_to, _Identity, _Select1st
-#include <bits/functional_hash.h>
-#include <bits/hashtable.h>
 #include <bits/unordered_map.h>
 #include <bits/range_access.h>
 #include <bits/erase_if.h>
diff --git a/libstdc++-v3/include/std/unordered_set b/libstdc++-v3/include/std/unordered_set
index 8b665718a83..edaa517635b 100644
--- a/libstdc++-v3/include/std/unordered_set
+++ b/libstdc++-v3/include/std/unordered_set
@@ -35,15 +35,7 @@
 # include <bits/c++0x_warning.h>
 #else
 
-#include <type_traits>
 #include <initializer_list>
-#include <bits/allocator.h>
-#include <ext/alloc_traits.h>
-#include <ext/aligned_buffer.h>
-#include <bits/stl_pair.h>
-#include <bits/stl_function.h> // equal_to, _Identity, _Select1st
-#include <bits/functional_hash.h>
-#include <bits/hashtable.h>
 #include <bits/unordered_set.h>
 #include <bits/range_access.h>
 #include <bits/erase_if.h>
-- 
2.34.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-26 12:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26 12:36 [committed 1/3] libstdc++: Make headers include their prerequisites Jonathan Wakely
2022-05-26 12:36 ` [committed 2/3] libstdc++: Remove some unnecessary includes Jonathan Wakely
2022-05-26 12:36 ` [committed 3/3] libstdc++: Refactor includes for unordered containers Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).