diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -385,11 +385,17 @@ __functional/unwrap_ref.h __functional/weak_result_type.h __fwd/array.h + __fwd/fstream.h __fwd/get.h __fwd/hash.h + __fwd/ios.h + __fwd/istream.h __fwd/memory_resource.h + __fwd/ostream.h __fwd/pair.h __fwd/span.h + __fwd/sstream.h + __fwd/streambuf.h __fwd/string.h __fwd/string_view.h __fwd/subrange.h diff --git a/libcxx/include/__fwd/fstream.h b/libcxx/include/__fwd/fstream.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__fwd/fstream.h @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_FSTREAM_H +#define _LIBCPP___FWD_FSTREAM_H + +#include <__config> +#include <__fwd/string.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template > + class _LIBCPP_TEMPLATE_VIS basic_filebuf; +template > + class _LIBCPP_TEMPLATE_VIS basic_ifstream; +template > + class _LIBCPP_TEMPLATE_VIS basic_ofstream; +template > + class _LIBCPP_TEMPLATE_VIS basic_fstream; + +typedef basic_filebuf filebuf; +typedef basic_ifstream ifstream; +typedef basic_ofstream ofstream; +typedef basic_fstream fstream; + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +typedef basic_filebuf wfilebuf; +typedef basic_ifstream wifstream; +typedef basic_ofstream wofstream; +typedef basic_fstream wfstream; +#endif + +template + class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfilebuf)) basic_filebuf; +template + class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wifstream)) basic_ifstream; +template + class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wofstream)) basic_ofstream; +template + class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfstream)) basic_fstream; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_FSTREAM_H diff --git a/libcxx/include/__fwd/ios.h b/libcxx/include/__fwd/ios.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__fwd/ios.h @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_IOS_H +#define _LIBCPP___FWD_IOS_H + +#include <__config> +#include <__fwd/string.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template > + class _LIBCPP_TEMPLATE_VIS basic_ios; + +typedef basic_ios ios; +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +typedef basic_ios wios; +#endif + +template + class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios; + +#if defined(_NEWLIB_VERSION) +// On newlib, off_t is 'long int' +typedef long int streamoff; // for char_traits in +#else +typedef long long streamoff; // for char_traits in +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_IOS_H diff --git a/libcxx/include/__fwd/istream.h b/libcxx/include/__fwd/istream.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__fwd/istream.h @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_ISTREAM_H +#define _LIBCPP___FWD_ISTREAM_H + +#include <__config> +#include <__fwd/string.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template > + class _LIBCPP_TEMPLATE_VIS basic_istream; + +template > + class _LIBCPP_TEMPLATE_VIS basic_iostream; + +typedef basic_istream istream; +typedef basic_iostream iostream; + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +typedef basic_istream wistream; +typedef basic_iostream wiostream; +#endif + +template + class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistream)) basic_istream; + +template + class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wiostream)) basic_iostream; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_ISTREAM_H diff --git a/libcxx/include/__fwd/ostream.h b/libcxx/include/__fwd/ostream.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__fwd/ostream.h @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_OSTREAM_H +#define _LIBCPP___FWD_OSTREAM_H + +#include <__config> +#include <__fwd/string.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template > + class _LIBCPP_TEMPLATE_VIS basic_ostream; + +typedef basic_ostream ostream; + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +typedef basic_ostream wostream; +#endif + +template + class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostream)) basic_ostream; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_OSTREAM_H diff --git a/libcxx/include/__fwd/sstream.h b/libcxx/include/__fwd/sstream.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__fwd/sstream.h @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_SSTREAM_H +#define _LIBCPP___FWD_SSTREAM_H + +#include <__config> +#include <__fwd/string.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template , + class _Allocator = allocator<_CharT> > + class _LIBCPP_TEMPLATE_VIS basic_stringbuf; + +template , + class _Allocator = allocator<_CharT> > + class _LIBCPP_TEMPLATE_VIS basic_istringstream; +template , + class _Allocator = allocator<_CharT> > + class _LIBCPP_TEMPLATE_VIS basic_ostringstream; +template , + class _Allocator = allocator<_CharT> > + class _LIBCPP_TEMPLATE_VIS basic_stringstream; + +typedef basic_stringbuf stringbuf; +typedef basic_istringstream istringstream; +typedef basic_ostringstream ostringstream; +typedef basic_stringstream stringstream; + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +typedef basic_stringbuf wstringbuf; +typedef basic_istringstream wistringstream; +typedef basic_ostringstream wostringstream; +typedef basic_stringstream wstringstream; +#endif + +template + class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringbuf)) basic_stringbuf; +template + class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistringstream)) basic_istringstream; +template + class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostringstream)) basic_ostringstream; +template + class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringstream)) basic_stringstream; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_SSTREAM_H diff --git a/libcxx/include/__fwd/streambuf.h b/libcxx/include/__fwd/streambuf.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__fwd/streambuf.h @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_STREAMBUF_H +#define _LIBCPP___FWD_STREAMBUF_H + +#include <__config> +#include <__fwd/string.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template > + class _LIBCPP_TEMPLATE_VIS basic_streambuf; + +typedef basic_streambuf streambuf; + +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +typedef basic_streambuf wstreambuf; +#endif + +template + class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstreambuf)) basic_streambuf; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_STREAMBUF_H diff --git a/libcxx/include/fstream b/libcxx/include/fstream --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -183,6 +183,7 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__availability> #include <__config> +#include <__fwd/fstream.h> #include <__locale> #include <__utility/move.h> #include <__utility/swap.h> diff --git a/libcxx/include/ios b/libcxx/include/ios --- a/libcxx/include/ios +++ b/libcxx/include/ios @@ -217,6 +217,7 @@ #endif #include <__assert> // all public C++ headers provide the assertion handler +#include <__fwd/ios.h> #include <__ios/fpos.h> #include <__locale> #include <__system_error/error_category.h> diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd --- a/libcxx/include/iosfwd +++ b/libcxx/include/iosfwd @@ -96,6 +96,12 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__fwd/fstream.h> +#include <__fwd/ios.h> +#include <__fwd/istream.h> +#include <__fwd/ostream.h> +#include <__fwd/sstream.h> +#include <__fwd/streambuf.h> #include <__fwd/string.h> #include <__mbstate_t.h> #include @@ -108,112 +114,11 @@ class _LIBCPP_TYPE_VIS ios_base; -template > - class _LIBCPP_TEMPLATE_VIS basic_ios; - -template > - class _LIBCPP_TEMPLATE_VIS basic_streambuf; -template > - class _LIBCPP_TEMPLATE_VIS basic_istream; -template > - class _LIBCPP_TEMPLATE_VIS basic_ostream; -template > - class _LIBCPP_TEMPLATE_VIS basic_iostream; - -template , - class _Allocator = allocator<_CharT> > - class _LIBCPP_TEMPLATE_VIS basic_stringbuf; -template , - class _Allocator = allocator<_CharT> > - class _LIBCPP_TEMPLATE_VIS basic_istringstream; -template , - class _Allocator = allocator<_CharT> > - class _LIBCPP_TEMPLATE_VIS basic_ostringstream; -template , - class _Allocator = allocator<_CharT> > - class _LIBCPP_TEMPLATE_VIS basic_stringstream; - -template > - class _LIBCPP_TEMPLATE_VIS basic_filebuf; -template > - class _LIBCPP_TEMPLATE_VIS basic_ifstream; -template > - class _LIBCPP_TEMPLATE_VIS basic_ofstream; -template > - class _LIBCPP_TEMPLATE_VIS basic_fstream; - template > class _LIBCPP_TEMPLATE_VIS istreambuf_iterator; template > class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator; -typedef basic_ios ios; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -typedef basic_ios wios; -#endif - -typedef basic_streambuf streambuf; -typedef basic_istream istream; -typedef basic_ostream ostream; -typedef basic_iostream iostream; - -typedef basic_stringbuf stringbuf; -typedef basic_istringstream istringstream; -typedef basic_ostringstream ostringstream; -typedef basic_stringstream stringstream; - -typedef basic_filebuf filebuf; -typedef basic_ifstream ifstream; -typedef basic_ofstream ofstream; -typedef basic_fstream fstream; - -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -typedef basic_streambuf wstreambuf; -typedef basic_istream wistream; -typedef basic_ostream wostream; -typedef basic_iostream wiostream; - -typedef basic_stringbuf wstringbuf; -typedef basic_istringstream wistringstream; -typedef basic_ostringstream wostringstream; -typedef basic_stringstream wstringstream; - -typedef basic_filebuf wfilebuf; -typedef basic_ifstream wifstream; -typedef basic_ofstream wofstream; -typedef basic_fstream wfstream; -#endif - -template - class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios; - -template - class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstreambuf)) basic_streambuf; -template - class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistream)) basic_istream; -template - class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostream)) basic_ostream; -template - class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wiostream)) basic_iostream; - -template - class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringbuf)) basic_stringbuf; -template - class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistringstream)) basic_istringstream; -template - class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostringstream)) basic_ostringstream; -template - class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringstream)) basic_stringstream; - -template - class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfilebuf)) basic_filebuf; -template - class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wifstream)) basic_ifstream; -template - class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wofstream)) basic_ofstream; -template - class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfstream)) basic_fstream; - template class _LIBCPP_TEMPLATE_VIS fpos; typedef fpos streampos; typedef fpos wstreampos; @@ -223,13 +128,6 @@ typedef fpos u16streampos; typedef fpos u32streampos; -#if defined(_NEWLIB_VERSION) -// On newlib, off_t is 'long int' -typedef long int streamoff; // for char_traits in -#else -typedef long long streamoff; // for char_traits in -#endif - // Include other forward declarations here template > class _LIBCPP_TEMPLATE_VIS vector; diff --git a/libcxx/include/istream b/libcxx/include/istream --- a/libcxx/include/istream +++ b/libcxx/include/istream @@ -160,6 +160,7 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__fwd/istream.h> #include <__iterator/istreambuf_iterator.h> #include <__type_traits/conjunction.h> #include <__type_traits/enable_if.h> diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -1012,6 +1012,14 @@ module iosfwd { header "iosfwd" export * + module __iosfwd { + module fstream_fwd { private header "__fwd/fstream.h" } + module ios_fwd { private header "__fwd/ios.h" } + module istream_fwd { private header "__fwd/istream.h" } + module ostream_fwd { private header "__fwd/ostream.h" } + module sstream_fwd { private header "__fwd/sstream.h" } + module streambuf_fwd { private header "__fwd/streambuf.h" } + } } module iostream { @requires_LIBCXX_ENABLE_LOCALIZATION@ diff --git a/libcxx/include/ostream b/libcxx/include/ostream --- a/libcxx/include/ostream +++ b/libcxx/include/ostream @@ -166,6 +166,7 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> #include <__exception/operations.h> +#include <__fwd/ostream.h> #include <__memory/shared_ptr.h> #include <__memory/unique_ptr.h> #include <__system_error/error_code.h> diff --git a/libcxx/include/sstream b/libcxx/include/sstream --- a/libcxx/include/sstream +++ b/libcxx/include/sstream @@ -187,6 +187,7 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__fwd/sstream.h> #include <__utility/swap.h> #include #include diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf --- a/libcxx/include/streambuf +++ b/libcxx/include/streambuf @@ -109,6 +109,7 @@ #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__fwd/streambuf.h> #include #include #include diff --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp --- a/libcxx/test/libcxx/private_headers.verify.cpp +++ b/libcxx/test/libcxx/private_headers.verify.cpp @@ -427,11 +427,17 @@ #include <__functional/unwrap_ref.h> // expected-error@*:* {{use of private header from outside its module: '__functional/unwrap_ref.h'}} #include <__functional/weak_result_type.h> // expected-error@*:* {{use of private header from outside its module: '__functional/weak_result_type.h'}} #include <__fwd/array.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/array.h'}} +#include <__fwd/fstream.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/fstream.h'}} #include <__fwd/get.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/get.h'}} #include <__fwd/hash.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/hash.h'}} +#include <__fwd/ios.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/ios.h'}} +#include <__fwd/istream.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/istream.h'}} #include <__fwd/memory_resource.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/memory_resource.h'}} +#include <__fwd/ostream.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/ostream.h'}} #include <__fwd/pair.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/pair.h'}} #include <__fwd/span.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/span.h'}} +#include <__fwd/sstream.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/sstream.h'}} +#include <__fwd/streambuf.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/streambuf.h'}} #include <__fwd/string.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/string.h'}} #include <__fwd/string_view.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/string_view.h'}} #include <__fwd/subrange.h> // expected-error@*:* {{use of private header from outside its module: '__fwd/subrange.h'}} diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt --- a/libcxx/utils/data/ignore_format.txt +++ b/libcxx/utils/data/ignore_format.txt @@ -398,8 +398,14 @@ libcxx/include/__functional/unwrap_ref.h libcxx/include/__functional/weak_result_type.h libcxx/include/future +libcxx/include/__fwd/fstream.h libcxx/include/__fwd/get.h +libcxx/include/__fwd/ios.h +libcxx/include/__fwd/istream.h +libcxx/include/__fwd/ostream.h libcxx/include/__fwd/span.h +libcxx/include/__fwd/sstream.h +libcxx/include/__fwd/streambuf.h libcxx/include/__fwd/string_view.h libcxx/include/__fwd/subrange.h libcxx/include/__hash_table