[libcxx-commits] [libcxx] [libc++][modules] Consolidate modules for math and tuple (PR #107398)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 5 05:48:24 PDT 2024


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/107398

The module for tuple is kept private and does not contain <tuple> itself, because that pulls in too many dependencies. Only the utilities related to tuple are consolidated into a single module.

>From adafeeda9a4f0e069d38bdbb9e0376a550bf52aa Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Fri, 30 Aug 2024 16:34:36 -0400
Subject: [PATCH] [libc++][modules] Consolidate modules for math and tuple

The module for tuple is kept private and does not contain <tuple>
itself, because that pulls in too many dependencies. Only the
utilities related to tuple are consolidated into a single module.
---
 libcxx/include/__math/copysign.h              |  1 -
 libcxx/include/__math/remainder.h             |  1 -
 libcxx/include/__tuple/find_index.h           |  2 +-
 libcxx/include/__tuple/make_tuple_types.h     |  2 +-
 libcxx/include/__tuple/sfinae_helpers.h       |  2 +-
 libcxx/include/__tuple/tuple_element.h        |  2 +-
 libcxx/include/__tuple/tuple_indices.h        |  2 +-
 libcxx/include/__tuple/tuple_like_ext.h       |  2 +-
 .../include/__tuple/tuple_like_no_subrange.h  |  2 +-
 libcxx/include/__tuple/tuple_size.h           |  2 +-
 libcxx/include/module.modulemap               | 82 +++++++++----------
 11 files changed, 49 insertions(+), 51 deletions(-)

diff --git a/libcxx/include/__math/copysign.h b/libcxx/include/__math/copysign.h
index b38690bb581a11..2c3b0dd6f97b70 100644
--- a/libcxx/include/__math/copysign.h
+++ b/libcxx/include/__math/copysign.h
@@ -13,7 +13,6 @@
 #include <__type_traits/enable_if.h>
 #include <__type_traits/is_arithmetic.h>
 #include <__type_traits/promote.h>
-#include <limits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__math/remainder.h b/libcxx/include/__math/remainder.h
index 0fbf0b8ef97b9e..0adb7f3af5de2c 100644
--- a/libcxx/include/__math/remainder.h
+++ b/libcxx/include/__math/remainder.h
@@ -14,7 +14,6 @@
 #include <__type_traits/is_arithmetic.h>
 #include <__type_traits/is_same.h>
 #include <__type_traits/promote.h>
-#include <limits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/find_index.h b/libcxx/include/__tuple/find_index.h
index 133b00419d0c6c..cc7329d3e89b4b 100644
--- a/libcxx/include/__tuple/find_index.h
+++ b/libcxx/include/__tuple/find_index.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TUPLE_FIND_INDEX_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__type_traits/is_same.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/make_tuple_types.h b/libcxx/include/__tuple/make_tuple_types.h
index 9e0fefae2f2f58..53e98c3d6e9757 100644
--- a/libcxx/include/__tuple/make_tuple_types.h
+++ b/libcxx/include/__tuple/make_tuple_types.h
@@ -10,6 +10,7 @@
 #define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/array.h>
 #include <__fwd/tuple.h>
 #include <__tuple/tuple_element.h>
@@ -19,7 +20,6 @@
 #include <__type_traits/copy_cvref.h>
 #include <__type_traits/remove_cv.h>
 #include <__type_traits/remove_reference.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/sfinae_helpers.h b/libcxx/include/__tuple/sfinae_helpers.h
index c7145e0b011a99..a785cec138b2f8 100644
--- a/libcxx/include/__tuple/sfinae_helpers.h
+++ b/libcxx/include/__tuple/sfinae_helpers.h
@@ -10,6 +10,7 @@
 #define _LIBCPP___TUPLE_SFINAE_HELPERS_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/tuple.h>
 #include <__tuple/make_tuple_types.h>
 #include <__tuple/tuple_element.h>
@@ -23,7 +24,6 @@
 #include <__type_traits/is_same.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_element.h b/libcxx/include/__tuple/tuple_element.h
index 9127c47dc8f1a5..1404460e743529 100644
--- a/libcxx/include/__tuple/tuple_element.h
+++ b/libcxx/include/__tuple/tuple_element.h
@@ -10,9 +10,9 @@
 #define _LIBCPP___TUPLE_TUPLE_ELEMENT_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__tuple/tuple_indices.h>
 #include <__tuple/tuple_types.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_indices.h b/libcxx/include/__tuple/tuple_indices.h
index 501e711255ec10..25dc9ec6859161 100644
--- a/libcxx/include/__tuple/tuple_indices.h
+++ b/libcxx/include/__tuple/tuple_indices.h
@@ -10,8 +10,8 @@
 #define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__utility/integer_sequence.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_like_ext.h b/libcxx/include/__tuple/tuple_like_ext.h
index 0cc21e0b75fd1a..45c0e65d62ff3c 100644
--- a/libcxx/include/__tuple/tuple_like_ext.h
+++ b/libcxx/include/__tuple/tuple_like_ext.h
@@ -10,12 +10,12 @@
 #define _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/array.h>
 #include <__fwd/pair.h>
 #include <__fwd/tuple.h>
 #include <__tuple/tuple_types.h>
 #include <__type_traits/integral_constant.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_like_no_subrange.h b/libcxx/include/__tuple/tuple_like_no_subrange.h
index 274b0bf188e1f4..30018d6a05ae29 100644
--- a/libcxx/include/__tuple/tuple_like_no_subrange.h
+++ b/libcxx/include/__tuple/tuple_like_no_subrange.h
@@ -10,13 +10,13 @@
 #define _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/array.h>
 #include <__fwd/complex.h>
 #include <__fwd/pair.h>
 #include <__fwd/tuple.h>
 #include <__tuple/tuple_size.h>
 #include <__type_traits/remove_cvref.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/__tuple/tuple_size.h b/libcxx/include/__tuple/tuple_size.h
index 21c9811abeee7b..b970280fe37842 100644
--- a/libcxx/include/__tuple/tuple_size.h
+++ b/libcxx/include/__tuple/tuple_size.h
@@ -10,13 +10,13 @@
 #define _LIBCPP___TUPLE_TUPLE_SIZE_H
 
 #include <__config>
+#include <__cstddef/size_t.h>
 #include <__fwd/tuple.h>
 #include <__tuple/tuple_types.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/integral_constant.h>
 #include <__type_traits/is_const.h>
 #include <__type_traits/is_volatile.h>
-#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 3abc11723a5a92..65a93fbffd800d 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -517,6 +517,26 @@ module std_locale_h [system] {
 }
 module std_math_h [system] {
   header "math.h"
+  module abs                             { header "__math/abs.h" }
+  module copysign                        { header "__math/copysign.h" }
+  module error_functions                 { header "__math/error_functions.h" }
+  module exponential_functions           { header "__math/exponential_functions.h" }
+  module fdim                            { header "__math/fdim.h" }
+  module fma                             { header "__math/fma.h" }
+  module gamma                           { header "__math/gamma.h" }
+  module hyperbolic_functions            { header "__math/hyperbolic_functions.h" }
+  module hypot                           { header "__math/hypot.h" }
+  module inverse_hyperbolic_functions    { header "__math/inverse_hyperbolic_functions.h" }
+  module inverse_trigonometric_functions { header "__math/inverse_trigonometric_functions.h" }
+  module logarithms                      { header "__math/logarithms.h" }
+  module min_max                         { header "__math/min_max.h" }
+  module modulo                          { header "__math/modulo.h" }
+  module remainder                       { header "__math/remainder.h" }
+  module roots                           { header "__math/roots.h" }
+  module rounding_functions              { header "__math/rounding_functions.h" }
+  module special_functions               { header "__math/special_functions.h" }
+  module traits                          { header "__math/traits.h" }
+  module trigonometric_functions         { header "__math/trigonometric_functions.h" }
   export *
 }
 // <setjmp.h> provided by C library.
@@ -1469,27 +1489,6 @@ module std_private_locale_locale_base_api                      [system] {
   export *
 }
 
-module std_private_math_abs                             [system] { header "__math/abs.h" }
-module std_private_math_copysign                        [system] { header "__math/copysign.h" }
-module std_private_math_error_functions                 [system] { header "__math/error_functions.h" }
-module std_private_math_exponential_functions           [system] { header "__math/exponential_functions.h" }
-module std_private_math_fdim                            [system] { header "__math/fdim.h" }
-module std_private_math_fma                             [system] { header "__math/fma.h" }
-module std_private_math_gamma                           [system] { header "__math/gamma.h" }
-module std_private_math_hyperbolic_functions            [system] { header "__math/hyperbolic_functions.h" }
-module std_private_math_hypot                           [system] { header "__math/hypot.h" }
-module std_private_math_inverse_hyperbolic_functions    [system] { header "__math/inverse_hyperbolic_functions.h" }
-module std_private_math_inverse_trigonometric_functions [system] { header "__math/inverse_trigonometric_functions.h" }
-module std_private_math_logarithms                      [system] { header "__math/logarithms.h" }
-module std_private_math_min_max                         [system] { header "__math/min_max.h" }
-module std_private_math_modulo                          [system] { header "__math/modulo.h" }
-module std_private_math_remainder                       [system] { header "__math/remainder.h" }
-module std_private_math_roots                           [system] { header "__math/roots.h" }
-module std_private_math_rounding_functions              [system] { header "__math/rounding_functions.h" }
-module std_private_math_special_functions               [system] { header "__math/special_functions.h" }
-module std_private_math_traits                          [system] { header "__math/traits.h" }
-module std_private_math_trigonometric_functions         [system] { header "__math/trigonometric_functions.h" }
-
 module std_private_memory_addressof                       [system] { header "__memory/addressof.h" }
 module std_private_memory_align                           [system] { header "__memory/align.h" }
 module std_private_memory_aligned_alloc                   [system] { header "__memory/aligned_alloc.h" }
@@ -1805,26 +1804,27 @@ module std_private_thread_thread               [system] {
 }
 module std_private_thread_timed_backoff_policy [system] { header "__thread/timed_backoff_policy.h" }
 
-module std_private_tuple_find_index             [system] { header "__tuple/find_index.h" }
-module std_private_tuple_ignore                 [system] { header "__tuple/ignore.h" }
-module std_private_tuple_make_tuple_types       [system] { header "__tuple/make_tuple_types.h" }
-module std_private_tuple_tuple_like_no_subrange [system] {
-  header "__tuple/tuple_like_no_subrange.h"
-}
-module std_private_tuple_sfinae_helpers         [system] { header "__tuple/sfinae_helpers.h" }
-module std_private_tuple_tuple_element          [system] { header "__tuple/tuple_element.h" }
-module std_private_tuple_tuple_fwd              [system] { header "__fwd/tuple.h" }
-module std_private_tuple_tuple_indices          [system] { header "__tuple/tuple_indices.h" }
-module std_private_tuple_tuple_like             [system] {
-  header "__tuple/tuple_like.h"
-  export *
-}
-module std_private_tuple_tuple_like_ext         [system] { header "__tuple/tuple_like_ext.h" }
-module std_private_tuple_tuple_size             [system] {
-  header "__tuple/tuple_size.h"
-  export std_private_type_traits_integral_constant
+module std_private_tuple_fwd [system] { header "__fwd/tuple.h" }
+
+module std_private_tuple [system] {
+  module find_index             { header "__tuple/find_index.h" }
+  module ignore                 { header "__tuple/ignore.h" }
+  module make_tuple_types       { header "__tuple/make_tuple_types.h" }
+  module tuple_like_no_subrange { header "__tuple/tuple_like_no_subrange.h" }
+  module sfinae_helpers         { header "__tuple/sfinae_helpers.h" }
+  module tuple_element          { header "__tuple/tuple_element.h" }
+  module tuple_indices          { header "__tuple/tuple_indices.h" }
+  module tuple_like             {
+    header "__tuple/tuple_like.h"
+    export *
+  }
+  module tuple_like_ext         { header "__tuple/tuple_like_ext.h" }
+  module tuple_size             {
+    header "__tuple/tuple_size.h"
+    export std_private_type_traits_integral_constant
+  }
+  module tuple_types            { header "__tuple/tuple_types.h" }
 }
-module std_private_tuple_tuple_types            [system] { header "__tuple/tuple_types.h" }
 
 module std_private_type_traits_add_const                                 [system] { header "__type_traits/add_const.h" }
 module std_private_type_traits_add_cv                                    [system] { header "__type_traits/add_cv.h" }
@@ -2079,7 +2079,7 @@ module std_private_utility_no_destroy             [system] { header "__utility/n
 module std_private_utility_pair                   [system] {
   header "__utility/pair.h"
   export std_private_ranges_subrange_fwd
-  export std_private_tuple_pair_like
+  export std_private_tuple.pair_like
   export std_private_type_traits_is_assignable
   export std_private_type_traits_is_constructible
   export std_private_type_traits_is_convertible



More information about the libcxx-commits mailing list