[libcxx-commits] [libcxx] fafed06 - [libc++] Granularize <type_traits> includes in <bit>, <numbers> and <coroutine>

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jan 21 06:09:26 PST 2023


Author: Nikolas Klauser
Date: 2023-01-21T15:09:21+01:00
New Revision: fafed06b2ea985324b844fa1a90b50553c34914b

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

LOG: [libc++] Granularize <type_traits> includes in <bit>, <numbers> and <coroutine>

`<coroutine>` seems to be new enough to not be a huge problem.

Reviewed By: Mordante, #libc

Spies: libcxx-commits, ChuanqiXu

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

Added: 
    

Modified: 
    libcxx/include/__coroutine/coroutine_handle.h
    libcxx/include/__coroutine/coroutine_traits.h
    libcxx/include/__numeric/gcd_lcm.h
    libcxx/include/__numeric/midpoint.h
    libcxx/include/coroutine
    libcxx/include/numbers
    libcxx/include/numeric
    libcxx/test/libcxx/transitive_includes/cxx2b.csv
    libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.fail.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__coroutine/coroutine_handle.h b/libcxx/include/__coroutine/coroutine_handle.h
index 8f7ed2ee48af..0a6cc1cab690 100644
--- a/libcxx/include/__coroutine/coroutine_handle.h
+++ b/libcxx/include/__coroutine/coroutine_handle.h
@@ -13,8 +13,9 @@
 #include <__config>
 #include <__functional/hash.h>
 #include <__memory/addressof.h>
+#include <__type_traits/remove_cv.h>
 #include <compare>
-#include <type_traits>
+#include <cstddef>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

diff  --git a/libcxx/include/__coroutine/coroutine_traits.h b/libcxx/include/__coroutine/coroutine_traits.h
index 87eb21830a5d..d513075098c6 100644
--- a/libcxx/include/__coroutine/coroutine_traits.h
+++ b/libcxx/include/__coroutine/coroutine_traits.h
@@ -10,7 +10,7 @@
 #define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
 
 #include <__config>
-#include <type_traits>
+#include <__type_traits/void_t.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

diff  --git a/libcxx/include/__numeric/gcd_lcm.h b/libcxx/include/__numeric/gcd_lcm.h
index b3d776b3a44f..5a3f81b695e2 100644
--- a/libcxx/include/__numeric/gcd_lcm.h
+++ b/libcxx/include/__numeric/gcd_lcm.h
@@ -12,8 +12,12 @@
 
 #include <__assert>
 #include <__config>
+#include <__type_traits/common_type.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_signed.h>
+#include <__type_traits/make_unsigned.h>
 #include <limits>
-#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

diff  --git a/libcxx/include/__numeric/midpoint.h b/libcxx/include/__numeric/midpoint.h
index ada6adf72883..bac3642cbd2a 100644
--- a/libcxx/include/__numeric/midpoint.h
+++ b/libcxx/include/__numeric/midpoint.h
@@ -11,8 +11,18 @@
 #define _LIBCPP___NUMERIC_MIDPOINT_H
 
 #include <__config>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_null_pointer.h>
+#include <__type_traits/is_object.h>
+#include <__type_traits/is_pointer.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_void.h>
+#include <__type_traits/make_unsigned.h>
+#include <__type_traits/remove_pointer.h>
+#include <cstddef>
 #include <limits>
-#include <type_traits>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header

diff  --git a/libcxx/include/coroutine b/libcxx/include/coroutine
index e0ce32384368..f264570128bb 100644
--- a/libcxx/include/coroutine
+++ b/libcxx/include/coroutine
@@ -57,6 +57,7 @@ struct suspend_always;
 
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <iosfwd>
+#  include <type_traits>
 #endif
 
 #endif // _LIBCPP_COROUTINE

diff  --git a/libcxx/include/numbers b/libcxx/include/numbers
index 1d9b6b0e5fb3..72034a6bc06b 100644
--- a/libcxx/include/numbers
+++ b/libcxx/include/numbers
@@ -61,7 +61,6 @@ namespace std::numbers {
 #include <__assert> // all public C++ headers provide the assertion handler
 #include <__concepts/arithmetic.h>
 #include <__config>
-#include <type_traits>
 #include <version>
 
 #if _LIBCPP_STD_VER > 17
@@ -133,6 +132,7 @@ _LIBCPP_END_NAMESPACE_STD
 
 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
 #  include <concepts>
+#  include <type_traits>
 #endif
 
 #endif // _LIBCPP_NUMBERS

diff  --git a/libcxx/include/numeric b/libcxx/include/numeric
index 2fb6f9ed0192..100dbe1c3232 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -175,6 +175,7 @@ template<class T>
 #  include <concepts>
 #  include <functional>
 #  include <iterator>
+#  include <type_traits>
 #endif
 
 #endif // _LIBCPP_NUMERIC

diff  --git a/libcxx/test/libcxx/transitive_includes/cxx2b.csv b/libcxx/test/libcxx/transitive_includes/cxx2b.csv
index 186d0b4f5d12..23cc6d70803c 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx2b.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx2b.csv
@@ -138,7 +138,6 @@ coroutine cstddef
 coroutine cstdint
 coroutine cstring
 coroutine limits
-coroutine type_traits
 coroutine version
 cstddef version
 ctgmath ccomplex
@@ -452,12 +451,10 @@ new cstddef
 new cstdlib
 new exception
 new version
-numbers type_traits
 numbers version
 numeric cmath
 numeric cstddef
 numeric limits
-numeric type_traits
 numeric version
 optional compare
 optional cstddef

diff  --git a/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.fail.cpp b/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.fail.cpp
index 962291dd9787..fab7d78d1f60 100644
--- a/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.fail.cpp
+++ b/libcxx/test/std/numerics/bit/bit.pow.two/bit_ceil.fail.cpp
@@ -20,8 +20,6 @@
 #include <cstdint>
 #include <limits>
 
-#include "test_macros.h"
-
 class A{};
 enum       E1 : unsigned char { rEd };
 enum class E2 : unsigned char { red };


        


More information about the libcxx-commits mailing list