[libcxx-commits] [libcxx] 91121ea - [libc++][PSTL] Reduce the amount of transitive includes

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 3 14:29:55 PDT 2023


Author: Nikolas Klauser
Date: 2023-05-03T14:29:48-07:00
New Revision: 91121ea6dc123733100d54622c9e89b1f6e89126

URL: https://github.com/llvm/llvm-project/commit/91121ea6dc123733100d54622c9e89b1f6e89126
DIFF: https://github.com/llvm/llvm-project/commit/91121ea6dc123733100d54622c9e89b1f6e89126.diff

LOG: [libc++][PSTL] Reduce the amount of transitive includes

Reviewed By: ldionne, #libc

Spies: libcxx-commits, miyuki

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

Added: 
    

Modified: 
    libcxx/include/__algorithm/pstl_any_all_none_of.h
    libcxx/include/__algorithm/pstl_find.h
    libcxx/include/__iterator/iterator_traits.h
    libcxx/include/__memory/allocator.h
    libcxx/include/__pstl/internal/execution_defs.h
    libcxx/include/__pstl/internal/execution_impl.h
    libcxx/include/__pstl/internal/parallel_backend_utils.h
    libcxx/include/__pstl/internal/parallel_impl.h
    libcxx/include/__pstl/internal/unseq_backend_simd.h
    libcxx/include/__pstl/internal/utils.h
    libcxx/include/__utility/terminate_on_exception.h
    libcxx/include/any
    libcxx/include/valarray
    libcxx/test/libcxx/transitive_includes/cxx2b.csv
    libcxx/test/support/test_execution_policies.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__algorithm/pstl_any_all_none_of.h b/libcxx/include/__algorithm/pstl_any_all_none_of.h
index e6446c26f7e63..6c01634eafdf3 100644
--- a/libcxx/include/__algorithm/pstl_any_all_none_of.h
+++ b/libcxx/include/__algorithm/pstl_any_all_none_of.h
@@ -11,7 +11,7 @@
 
 #include <__algorithm/any_of.h>
 #include <__config>
-#include <__functional/not_fn.h>
+#include <__iterator/iterator_traits.h>
 #include <__pstl/internal/parallel_impl.h>
 #include <__pstl/internal/unseq_backend_simd.h>
 #include <__type_traits/enable_if.h>
@@ -58,7 +58,9 @@ template <class _ExecutionPolicy,
           enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
 all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
-  return !std::any_of(__policy, __first, __last, std::not_fn(__pred));
+  return !std::any_of(__policy, __first, __last, [&](__iter_reference<_ForwardIterator> __value) {
+    return !__pred(__value);
+  });
 }
 
 template <class _ExecutionPolicy,

diff  --git a/libcxx/include/__algorithm/pstl_find.h b/libcxx/include/__algorithm/pstl_find.h
index d3c886d2c4bc9..8edb14bc59f74 100644
--- a/libcxx/include/__algorithm/pstl_find.h
+++ b/libcxx/include/__algorithm/pstl_find.h
@@ -12,7 +12,6 @@
 #include <__algorithm/comp.h>
 #include <__algorithm/find.h>
 #include <__config>
-#include <__functional/not_fn.h>
 #include <__pstl/internal/parallel_impl.h>
 #include <__pstl/internal/unseq_backend_simd.h>
 #include <__type_traits/is_execution_policy.h>
@@ -94,7 +93,9 @@ template <class _ExecutionPolicy,
           enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
 _LIBCPP_HIDE_FROM_ABI _ForwardIterator
 find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
-  return std::find_if(__policy, __first, __last, std::not_fn(std::move(__pred)));
+  return std::find_if(__policy, __first, __last, [&](__iter_reference<_ForwardIterator> __value) {
+    return !__pred(__value);
+  });
 }
 
 _LIBCPP_END_NAMESPACE_STD

diff  --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h
index 0318e4b62591e..f066b962e7a54 100644
--- a/libcxx/include/__iterator/iterator_traits.h
+++ b/libcxx/include/__iterator/iterator_traits.h
@@ -534,6 +534,9 @@ using __iter_
diff _t = typename iterator_traits<_Iter>::
diff erence_type;
 template<class _InputIterator>
 using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
 
+template <class _Iter>
+using __iter_reference = typename iterator_traits<_Iter>::reference;
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H

diff  --git a/libcxx/include/__memory/allocator.h b/libcxx/include/__memory/allocator.h
index 6e7800cbd2b9f..98f68899e4efb 100644
--- a/libcxx/include/__memory/allocator.h
+++ b/libcxx/include/__memory/allocator.h
@@ -21,7 +21,6 @@
 #include <__utility/forward.h>
 #include <cstddef>
 #include <new>
-#include <stdexcept>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

diff  --git a/libcxx/include/__pstl/internal/execution_defs.h b/libcxx/include/__pstl/internal/execution_defs.h
index 21a4dc4e432af..af6164bc722cb 100644
--- a/libcxx/include/__pstl/internal/execution_defs.h
+++ b/libcxx/include/__pstl/internal/execution_defs.h
@@ -10,7 +10,9 @@
 #ifndef _PSTL_EXECUTION_POLICY_DEFS_H
 #define _PSTL_EXECUTION_POLICY_DEFS_H
 
-#include <type_traits>
+#include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/integral_constant.h>
 
 #include "pstl_config.h"
 

diff  --git a/libcxx/include/__pstl/internal/execution_impl.h b/libcxx/include/__pstl/internal/execution_impl.h
index c930824c28629..cc60bce8216b7 100644
--- a/libcxx/include/__pstl/internal/execution_impl.h
+++ b/libcxx/include/__pstl/internal/execution_impl.h
@@ -10,8 +10,7 @@
 #ifndef _PSTL_EXECUTION_IMPL_H
 #define _PSTL_EXECUTION_IMPL_H
 
-#include <iterator>
-#include <type_traits>
+#include <__iterator/iterator_traits.h>
 
 #include "execution_defs.h"
 #include "pstl_config.h"

diff  --git a/libcxx/include/__pstl/internal/parallel_backend_utils.h b/libcxx/include/__pstl/internal/parallel_backend_utils.h
index 9d9e0c5e3960d..177717f28499d 100644
--- a/libcxx/include/__pstl/internal/parallel_backend_utils.h
+++ b/libcxx/include/__pstl/internal/parallel_backend_utils.h
@@ -10,8 +10,9 @@
 #ifndef _PSTL_PARALLEL_BACKEND_UTILS_H
 #define _PSTL_PARALLEL_BACKEND_UTILS_H
 
-#include <iterator>
-#include <utility>
+#include <__iterator/iterator_traits.h>
+#include <__memory/addressof.h>
+
 #include "utils.h"
 
 #include "pstl_config.h"

diff  --git a/libcxx/include/__pstl/internal/parallel_impl.h b/libcxx/include/__pstl/internal/parallel_impl.h
index 41744009b97cd..961afd75f5129 100644
--- a/libcxx/include/__pstl/internal/parallel_impl.h
+++ b/libcxx/include/__pstl/internal/parallel_impl.h
@@ -12,10 +12,8 @@
 
 #include "pstl_config.h"
 
+#include <__atomic/atomic.h>
 #include <__pstl/internal/parallel_backend.h>
-#include <atomic>
-// This header defines the minimum set of parallel routines required to support Parallel STL,
-// implemented on top of Intel(R) Threading Building Blocks (Intel(R) TBB) library
 
 namespace __pstl
 {

diff  --git a/libcxx/include/__pstl/internal/unseq_backend_simd.h b/libcxx/include/__pstl/internal/unseq_backend_simd.h
index 1a32a341bbf63..3d7750036f5b7 100644
--- a/libcxx/include/__pstl/internal/unseq_backend_simd.h
+++ b/libcxx/include/__pstl/internal/unseq_backend_simd.h
@@ -11,7 +11,7 @@
 #define _PSTL_UNSEQ_BACKEND_SIMD_H
 
 #include <__functional/operations.h>
-#include <type_traits>
+#include <__utility/pair.h>
 
 #include "pstl_config.h"
 #include "utils.h"

diff  --git a/libcxx/include/__pstl/internal/utils.h b/libcxx/include/__pstl/internal/utils.h
index 1623983a1322c..baaf4a69f201b 100644
--- a/libcxx/include/__pstl/internal/utils.h
+++ b/libcxx/include/__pstl/internal/utils.h
@@ -11,9 +11,9 @@
 #define _PSTL_UTILS_H
 
 #include <__exception/terminate.h>
-#include <iterator>
+#include <__pstl/internal/pstl_config.h>
+#include <__utility/forward.h>
 #include <new>
-#include <utility>
 
 namespace __pstl {
 namespace __internal {

diff  --git a/libcxx/include/__utility/terminate_on_exception.h b/libcxx/include/__utility/terminate_on_exception.h
index 532d8eafb2a3d..c046dee1e9569 100644
--- a/libcxx/include/__utility/terminate_on_exception.h
+++ b/libcxx/include/__utility/terminate_on_exception.h
@@ -10,7 +10,7 @@
 #define _LIBCPP___UTILITY_TERMINATE_ON_EXCEPTION_H
 
 #include <__config>
-#include <exception>
+#include <__exception/terminate.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

diff  --git a/libcxx/include/any b/libcxx/include/any
index d2f85269599f8..e056444f83c98 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -721,6 +721,7 @@ _LIBCPP_END_NAMESPACE_STD
 #  include <iosfwd>
 #  include <iterator>
 #  include <memory>
+#  include <stdexcept>
 #  include <type_traits>
 #  include <variant>
 #endif

diff  --git a/libcxx/include/valarray b/libcxx/include/valarray
index 76ae4a3f8c668..001e111a07d5b 100644
--- a/libcxx/include/valarray
+++ b/libcxx/include/valarray
@@ -4937,6 +4937,7 @@ _LIBCPP_POP_MACROS
 #  include <cstdlib>
 #  include <cstring>
 #  include <functional>
+#  include <stdexcept>
 #  include <type_traits>
 #endif
 

diff  --git a/libcxx/test/libcxx/transitive_includes/cxx2b.csv b/libcxx/test/libcxx/transitive_includes/cxx2b.csv
index 3f5758630f348..06bdb93e57ab5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx2b.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx2b.csv
@@ -13,7 +13,6 @@ any cstring
 any initializer_list
 any limits
 any new
-any stdexcept
 any typeinfo
 any version
 array compare
@@ -635,7 +634,6 @@ valarray cstdint
 valarray initializer_list
 valarray limits
 valarray new
-valarray stdexcept
 valarray version
 variant compare
 variant cstddef

diff  --git a/libcxx/test/support/test_execution_policies.h b/libcxx/test/support/test_execution_policies.h
index d9180fb913bcc..d0cf0ddb6f0d5 100644
--- a/libcxx/test/support/test_execution_policies.h
+++ b/libcxx/test/support/test_execution_policies.h
@@ -10,6 +10,7 @@
 #define TEST_SUPPORT_TEST_EXECUTION_POLICIES
 
 #include <cstdlib>
+#include <exception>
 #include <execution>
 #include <type_traits>
 #include <utility>


        


More information about the libcxx-commits mailing list