-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc++] Remove <tuple> include from <__format/concepts.h> #80214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesFull diff: https://github.com/llvm/llvm-project/pull/80214.diff 5 Files Affected:
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@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()
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
8d45507
to
e10abb8
Compare
@@ -86,7 +86,6 @@ chrono sstream | |||
chrono stdexcept | |||
chrono string | |||
chrono string_view | |||
chrono tuple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK we wanted to keep our transitive set stable. Maybe we should discuss this policy during a monthly meeting. Based on the several remarks on the size by the Chromium team and recently #80196 I think we should revise our header stability policy or at least have a plan how to remove transitive includes.
@vitaut recently blogged about this too, and _LIBCPP_REMOVE_TRANSITIVE_INCLUDES
does not seem to be well known.
@ldionne can you put this on the agenda?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until now we've only kept the includes up to C++20 stable. C++23 was always fair game. I agree that we should rethink our policy on this, since the amount of transitive includes that we could avoid has become massive. I'm currently also working on a patch to reduce the transitive includes further by including things in the top level headers by version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until now we've only kept the includes up to C++20 stable. C++23 was always fair game. I agree that we should rethink our policy on this, since the amount of transitive includes that we could avoid has become massive.
I know, but at some point it was said only the C++ development version is fair game, which would mean C++26. Hence the proposal to discuss this. I was already considering to put it on the agenda after a private conversation with Victor.
I'm currently also working on a patch to reduce the transitive includes further by including things in the top level headers by version.
The last time I had a patch to improve the transitive includes by #ifdef-ing
it got a lukewarm response. So nice to hear the response now is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the last monthly meeting we didn't declare C++23 includes frozen.
@@ -2972,6 +2972,7 @@ _LIBCPP_POP_MACROS | |||
# include <atomic> | |||
# include <concepts> | |||
# include <cstdlib> | |||
# include <tuple> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the tuple dependency for C++20 and now we need to keep it for C++11 - C++17 where tuple was never used. IMO a good reason to discuss our policy.
d34138a
to
9e46767
Compare
9e46767
to
7e1a4ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! modulo a nit.
# if _LIBCPP_STD_VER >= 17 | ||
template <class _Tp> | ||
inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; | ||
# endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you mention this in the description?
This also moves
tuple_size_v
intotuple_size
as a drive-by.