-
Notifications
You must be signed in to change notification settings - Fork 12k
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++] Avoid including <ostream> in <fstream> and <strstream> #116014
Merged
+6
−26
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
philnik777
force-pushed
the
avoid_ostream_include
branch
from
November 13, 2024 10:25
465a81b
to
c13636d
Compare
philnik777
force-pushed
the
avoid_ostream_include
branch
6 times, most recently
from
November 16, 2024 13:07
0ebfa04
to
07417cf
Compare
philnik777
force-pushed
the
avoid_ostream_include
branch
from
November 16, 2024 14:19
07417cf
to
e5691cc
Compare
llvmbot
added
the
libc++
libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
label
Nov 16, 2024
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesThis reduces the include time of Full diff: https://github.com/llvm/llvm-project/pull/116014.diff 5 Files Affected:
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index e3b9abbbdcf056..e188bfc9042a7c 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -193,6 +193,8 @@ typedef basic_fstream<wchar_t> wfstream;
#include <__fwd/fstream.h>
#include <__locale>
#include <__memory/addressof.h>
+#include <__memory/unique_ptr.h>
+#include <__ostream/basic_ostream.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_same.h>
#include <__utility/move.h>
@@ -200,7 +202,7 @@ typedef basic_fstream<wchar_t> wfstream;
#include <__utility/unreachable.h>
#include <cstdio>
#include <istream>
-#include <ostream>
+#include <streambuf>
#include <typeinfo>
#include <version>
diff --git a/libcxx/include/strstream b/libcxx/include/strstream
index 9ff4024a7c7e21..b263fe1a76ad22 100644
--- a/libcxx/include/strstream
+++ b/libcxx/include/strstream
@@ -130,8 +130,9 @@ private:
*/
#include <__config>
+#include <__ostream/basic_ostream.h>
#include <istream>
-#include <ostream>
+#include <streambuf>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 854ad1b5df6f1e..c0cabf49f81a5d 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -410,13 +410,11 @@ forward_list limits
forward_list new
forward_list tuple
forward_list version
-fstream array
fstream bitset
fstream cctype
fstream cerrno
fstream climits
fstream clocale
-fstream cmath
fstream compare
fstream cstddef
fstream cstdint
@@ -427,7 +425,6 @@ fstream ctime
fstream cwchar
fstream cwctype
fstream filesystem
-fstream format
fstream initializer_list
fstream iomanip
fstream ios
@@ -436,9 +433,6 @@ fstream istream
fstream limits
fstream locale
fstream new
-fstream optional
-fstream ostream
-fstream print
fstream ratio
fstream stdexcept
fstream streambuf
@@ -1081,13 +1075,11 @@ string_view limits
string_view new
string_view stdexcept
string_view version
-strstream array
strstream bitset
strstream cctype
strstream cerrno
strstream climits
strstream clocale
-strstream cmath
strstream compare
strstream cstddef
strstream cstdint
@@ -1097,7 +1089,6 @@ strstream cstring
strstream ctime
strstream cwchar
strstream cwctype
-strstream format
strstream initializer_list
strstream ios
strstream iosfwd
@@ -1105,9 +1096,6 @@ strstream istream
strstream limits
strstream locale
strstream new
-strstream optional
-strstream ostream
-strstream print
strstream ratio
strstream stdexcept
strstream streambuf
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index ba2faaee5e3757..5bbf5b41047b5d 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -410,13 +410,11 @@ forward_list limits
forward_list new
forward_list tuple
forward_list version
-fstream array
fstream bitset
fstream cctype
fstream cerrno
fstream climits
fstream clocale
-fstream cmath
fstream compare
fstream cstddef
fstream cstdint
@@ -426,7 +424,6 @@ fstream cstring
fstream ctime
fstream cwchar
fstream cwctype
-fstream format
fstream initializer_list
fstream iomanip
fstream ios
@@ -435,9 +432,6 @@ fstream istream
fstream limits
fstream locale
fstream new
-fstream optional
-fstream ostream
-fstream print
fstream ratio
fstream stdexcept
fstream streambuf
@@ -1080,13 +1074,11 @@ string_view limits
string_view new
string_view stdexcept
string_view version
-strstream array
strstream bitset
strstream cctype
strstream cerrno
strstream climits
strstream clocale
-strstream cmath
strstream compare
strstream cstddef
strstream cstdint
@@ -1096,7 +1088,6 @@ strstream cstring
strstream ctime
strstream cwchar
strstream cwctype
-strstream format
strstream initializer_list
strstream ios
strstream iosfwd
@@ -1104,9 +1095,6 @@ strstream istream
strstream limits
strstream locale
strstream new
-strstream optional
-strstream ostream
-strstream print
strstream ratio
strstream stdexcept
strstream streambuf
diff --git a/libcxx/test/std/input.output/file.streams/fstreams/native_handle_test_helpers.h b/libcxx/test/std/input.output/file.streams/fstreams/native_handle_test_helpers.h
index 4bc862d789848c..9cafec5bf72817 100644
--- a/libcxx/test/std/input.output/file.streams/fstreams/native_handle_test_helpers.h
+++ b/libcxx/test/std/input.output/file.streams/fstreams/native_handle_test_helpers.h
@@ -10,6 +10,7 @@
#define TEST_STD_INPUT_OUTPUT_FILE_STREAMS_FSTREAMS_TEST_HELPERS_H
#include <cassert>
+#include <cerrno>
#include <concepts>
#include <cstdio>
#include <fstream>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reduces the include time of
<fstream>
from ~800ms to ~500ms.