[libcxx-commits] [libcxx] [libc++] Remove <tuple> include from <__format/concepts.h> (PR #80214)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 31 15:20:46 PST 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/80214

None

>From f7aba33f30e902b480ac3a83e777d3402f84174f Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 1 Feb 2024 00:20:27 +0100
Subject: [PATCH] [libc++] Remove <tuple> include from <__format/concepts.h>

---
 libcxx/include/__format/concepts.h                         | 4 +++-
 libcxx/include/__tuple/tuple_size.h                        | 7 ++++++-
 libcxx/include/tuple                                       | 3 ---
 .../tuple/tuple.tuple/tuple.helper/tuple_size_v.verify.cpp | 2 +-
 libcxx/test/tools/clang_tidy_checks/CMakeLists.txt         | 2 +-
 5 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/libcxx/include/__format/concepts.h b/libcxx/include/__format/concepts.h
index 299c5f40ee35b..37181d837ebf2 100644
--- a/libcxx/include/__format/concepts.h
+++ b/libcxx/include/__format/concepts.h
@@ -15,10 +15,12 @@
 #include <__config>
 #include <__format/format_fwd.h>
 #include <__format/format_parse_context.h>
+#include <__fwd/tuple.h>
+#include <__tuple/tuple_size.h>
 #include <__type_traits/is_specialization.h>
 #include <__type_traits/remove_const.h>
+#include <__type_traits/remove_reference.h>
 #include <__utility/pair.h>
-#include <tuple>
 
 #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 b8320106fb269..18a17fd4d5878 100644
--- a/libcxx/include/__tuple/tuple_size.h
+++ b/libcxx/include/__tuple/tuple_size.h
@@ -43,7 +43,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< volatile _Tp,
 
 template <class _Tp>
 struct _LIBCPP_TEMPLATE_VIS
-    tuple_size<__enable_if_tuple_size_imp< const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
+tuple_size<__enable_if_tuple_size_imp<const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
     : public integral_constant<size_t, tuple_size<_Tp>::value> {};
 
 #else
@@ -63,6 +63,11 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> > : public integral_constan
 template <class... _Tp>
 struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {};
 
+#  if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
+#  endif
+
 #endif // _LIBCPP_CXX03_LANG
 
 _LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index 0e5f0b4831b41..a293f978c9f6f 100644
--- a/libcxx/include/tuple
+++ b/libcxx/include/tuple
@@ -1410,9 +1410,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_T1, _T2>::pair(
       second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {}
 
 #  if _LIBCPP_STD_VER >= 17
-template <class _Tp>
-inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
-
 #    define _LIBCPP_NOEXCEPT_RETURN(...)                                                                               \
       noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
 
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.verify.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.verify.cpp
index 7570230b4b074..573d973b706c2 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.verify.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.verify.cpp
@@ -20,5 +20,5 @@ void f() {
     (void)std::tuple_size_v<std::tuple<> &>; // expected-note {{requested here}}
     (void)std::tuple_size_v<int>; // expected-note {{requested here}}
     (void)std::tuple_size_v<std::tuple<>*>; // expected-note {{requested here}}
-    // expected-error at tuple:* 3 {{implicit instantiation of undefined template}}
+    // expected-error@*:* 3 {{implicit instantiation of undefined template}}
 }
diff --git a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
index 978e709521652..ab448061f52dc 100644
--- a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
+++ b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
@@ -5,7 +5,7 @@
 set(LLVM_DIR_SAVE ${LLVM_DIR})
 set(Clang_DIR_SAVE ${Clang_DIR})
 
-find_package(Clang 18)
+find_package(Clang 19)
 if (NOT Clang_FOUND)
   find_package(Clang 17)
 endif()



More information about the libcxx-commits mailing list