-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
[libc++][vector] include formatter only in C++23 #112675
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-libcxx Author: Takuto Ikuta (atetubou) ChangesThis is to reduce included header file size in pre C++23 build. e.g. 2% of total included file coming from formatter_bool.h in chrome build. Full diff: https://github.com/llvm/llvm-project/pull/112675.diff 1 Files Affected:
diff --git a/libcxx/include/vector b/libcxx/include/vector
index dc31f31838264c..93755afdde711c 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -324,8 +324,6 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
#include <__config>
#include <__debug_utils/sanitizers.h>
#include <__format/enable_insertable.h>
-#include <__format/formatter.h>
-#include <__format/formatter_bool.h>
#include <__functional/hash.h>
#include <__functional/unary_function.h>
#include <__fwd/vector.h>
@@ -391,6 +389,11 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
#include <compare>
#include <initializer_list>
+#if _LIBCPP_STD_VER >= 23
+# include <__format/formatter.h>
+# include <__format/formatter_bool.h>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
|
03ddb1b
to
1776748
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.
Perhaps we should correspondingly remove related entries in cxx11.csv ~ cxx20.csv in libcxx/test/libcxx/transitive_includes
.
There was some discussion of this in https://reviews.llvm.org/D149543 with @mordante I'm not familiar with the standard's requirements, but if they're only needed only in C++23, making the includes conditional sounds like a good option. |
This is to reduce included header file size in pre C++23 build. e.g. 2% of total included file coming from formatter_bool.h in chrome build. https://commondatastorage.googleapis.com/chromium-browser-clang/chrome_includes_2024-10-17_004801.html#view=edges&filter=&sort=asize&reverse=&includer=%5Ethird_party%2Flibc%5C%2B%5C%2B%2Fsrc%2Finclude%2Fvector%24&included=&limit=1000
1776748
to
dc18532
Compare
I updated From my understanding, formatter headers are only used from C++23's code for |
This is to reduce included header file size in pre C++23 build.
e.g. 2% of total included file coming from formatter_bool.h in chrome build.
https://commondatastorage.googleapis.com/chromium-browser-clang/chrome_includes_2024-10-17_004801.html#view=edges&filter=&sort=asize&reverse=&includer=%5Ethird_party%2Flibc%5C%2B%5C%2B%2Fsrc%2Finclude%2Fvector%24&included=&limit=1000