Skip to content

Commit 9d16cbc

Browse files
committed
[libc++] Adds more forward declaration headers.
The module validation script of D144994 validate whether the contents of an include match its module. An include is the set of files matching the pattern: - foo - foo/*. - __fwd/foo.h Several declarations of the stream headers are in the header iosfwd. This gives issue using the validation script. Adding iosfwd to the set of matching files gives too many declarations. For example when validating the fstream header it will pull in declarations of the istream header. Instead if writing a set of filters the headers are granularized into smaller headers containing the expected declarations. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D148927
1 parent 77ac365 commit 9d16cbc

File tree

17 files changed

+303
-108
lines changed

17 files changed

+303
-108
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,17 @@ set(files
385385
__functional/unwrap_ref.h
386386
__functional/weak_result_type.h
387387
__fwd/array.h
388+
__fwd/fstream.h
388389
__fwd/get.h
389390
__fwd/hash.h
391+
__fwd/ios.h
392+
__fwd/istream.h
390393
__fwd/memory_resource.h
394+
__fwd/ostream.h
391395
__fwd/pair.h
392396
__fwd/span.h
397+
__fwd/sstream.h
398+
__fwd/streambuf.h
393399
__fwd/string.h
394400
__fwd/string_view.h
395401
__fwd/subrange.h

libcxx/include/__fwd/fstream.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___FWD_FSTREAM_H
10+
#define _LIBCPP___FWD_FSTREAM_H
11+
12+
#include <__config>
13+
#include <__fwd/string.h>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
template <class _CharT, class _Traits = char_traits<_CharT> >
22+
class _LIBCPP_TEMPLATE_VIS basic_filebuf;
23+
template <class _CharT, class _Traits = char_traits<_CharT> >
24+
class _LIBCPP_TEMPLATE_VIS basic_ifstream;
25+
template <class _CharT, class _Traits = char_traits<_CharT> >
26+
class _LIBCPP_TEMPLATE_VIS basic_ofstream;
27+
template <class _CharT, class _Traits = char_traits<_CharT> >
28+
class _LIBCPP_TEMPLATE_VIS basic_fstream;
29+
30+
typedef basic_filebuf<char> filebuf;
31+
typedef basic_ifstream<char> ifstream;
32+
typedef basic_ofstream<char> ofstream;
33+
typedef basic_fstream<char> fstream;
34+
35+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
36+
typedef basic_filebuf<wchar_t> wfilebuf;
37+
typedef basic_ifstream<wchar_t> wifstream;
38+
typedef basic_ofstream<wchar_t> wofstream;
39+
typedef basic_fstream<wchar_t> wfstream;
40+
#endif
41+
42+
template <class _CharT, class _Traits>
43+
class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfilebuf)) basic_filebuf;
44+
template <class _CharT, class _Traits>
45+
class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wifstream)) basic_ifstream;
46+
template <class _CharT, class _Traits>
47+
class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wofstream)) basic_ofstream;
48+
template <class _CharT, class _Traits>
49+
class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfstream)) basic_fstream;
50+
51+
_LIBCPP_END_NAMESPACE_STD
52+
53+
#endif // _LIBCPP___FWD_FSTREAM_H

libcxx/include/__fwd/ios.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___FWD_IOS_H
10+
#define _LIBCPP___FWD_IOS_H
11+
12+
#include <__config>
13+
#include <__fwd/string.h>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
template <class _CharT, class _Traits = char_traits<_CharT> >
22+
class _LIBCPP_TEMPLATE_VIS basic_ios;
23+
24+
typedef basic_ios<char> ios;
25+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
26+
typedef basic_ios<wchar_t> wios;
27+
#endif
28+
29+
template <class _CharT, class _Traits>
30+
class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios;
31+
32+
#if defined(_NEWLIB_VERSION)
33+
// On newlib, off_t is 'long int'
34+
typedef long int streamoff; // for char_traits in <string>
35+
#else
36+
typedef long long streamoff; // for char_traits in <string>
37+
#endif
38+
39+
_LIBCPP_END_NAMESPACE_STD
40+
41+
#endif // _LIBCPP___FWD_IOS_H

libcxx/include/__fwd/istream.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___FWD_ISTREAM_H
10+
#define _LIBCPP___FWD_ISTREAM_H
11+
12+
#include <__config>
13+
#include <__fwd/string.h>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
template <class _CharT, class _Traits = char_traits<_CharT> >
22+
class _LIBCPP_TEMPLATE_VIS basic_istream;
23+
24+
template <class _CharT, class _Traits = char_traits<_CharT> >
25+
class _LIBCPP_TEMPLATE_VIS basic_iostream;
26+
27+
typedef basic_istream<char> istream;
28+
typedef basic_iostream<char> iostream;
29+
30+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
31+
typedef basic_istream<wchar_t> wistream;
32+
typedef basic_iostream<wchar_t> wiostream;
33+
#endif
34+
35+
template <class _CharT, class _Traits>
36+
class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistream)) basic_istream;
37+
38+
template <class _CharT, class _Traits>
39+
class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wiostream)) basic_iostream;
40+
41+
_LIBCPP_END_NAMESPACE_STD
42+
43+
#endif // _LIBCPP___FWD_ISTREAM_H

libcxx/include/__fwd/ostream.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___FWD_OSTREAM_H
10+
#define _LIBCPP___FWD_OSTREAM_H
11+
12+
#include <__config>
13+
#include <__fwd/string.h>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
template <class _CharT, class _Traits = char_traits<_CharT> >
22+
class _LIBCPP_TEMPLATE_VIS basic_ostream;
23+
24+
typedef basic_ostream<char> ostream;
25+
26+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
27+
typedef basic_ostream<wchar_t> wostream;
28+
#endif
29+
30+
template <class _CharT, class _Traits>
31+
class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostream)) basic_ostream;
32+
33+
_LIBCPP_END_NAMESPACE_STD
34+
35+
#endif // _LIBCPP___FWD_OSTREAM_H

libcxx/include/__fwd/sstream.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___FWD_SSTREAM_H
10+
#define _LIBCPP___FWD_SSTREAM_H
11+
12+
#include <__config>
13+
#include <__fwd/string.h>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
template <class _CharT, class _Traits = char_traits<_CharT>,
22+
class _Allocator = allocator<_CharT> >
23+
class _LIBCPP_TEMPLATE_VIS basic_stringbuf;
24+
25+
template <class _CharT, class _Traits = char_traits<_CharT>,
26+
class _Allocator = allocator<_CharT> >
27+
class _LIBCPP_TEMPLATE_VIS basic_istringstream;
28+
template <class _CharT, class _Traits = char_traits<_CharT>,
29+
class _Allocator = allocator<_CharT> >
30+
class _LIBCPP_TEMPLATE_VIS basic_ostringstream;
31+
template <class _CharT, class _Traits = char_traits<_CharT>,
32+
class _Allocator = allocator<_CharT> >
33+
class _LIBCPP_TEMPLATE_VIS basic_stringstream;
34+
35+
typedef basic_stringbuf<char> stringbuf;
36+
typedef basic_istringstream<char> istringstream;
37+
typedef basic_ostringstream<char> ostringstream;
38+
typedef basic_stringstream<char> stringstream;
39+
40+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
41+
typedef basic_stringbuf<wchar_t> wstringbuf;
42+
typedef basic_istringstream<wchar_t> wistringstream;
43+
typedef basic_ostringstream<wchar_t> wostringstream;
44+
typedef basic_stringstream<wchar_t> wstringstream;
45+
#endif
46+
47+
template <class _CharT, class _Traits, class _Allocator>
48+
class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringbuf)) basic_stringbuf;
49+
template <class _CharT, class _Traits, class _Allocator>
50+
class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistringstream)) basic_istringstream;
51+
template <class _CharT, class _Traits, class _Allocator>
52+
class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostringstream)) basic_ostringstream;
53+
template <class _CharT, class _Traits, class _Allocator>
54+
class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringstream)) basic_stringstream;
55+
56+
_LIBCPP_END_NAMESPACE_STD
57+
58+
#endif // _LIBCPP___FWD_SSTREAM_H

libcxx/include/__fwd/streambuf.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___FWD_STREAMBUF_H
10+
#define _LIBCPP___FWD_STREAMBUF_H
11+
12+
#include <__config>
13+
#include <__fwd/string.h>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
template <class _CharT, class _Traits = char_traits<_CharT> >
22+
class _LIBCPP_TEMPLATE_VIS basic_streambuf;
23+
24+
typedef basic_streambuf<char> streambuf;
25+
26+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
27+
typedef basic_streambuf<wchar_t> wstreambuf;
28+
#endif
29+
30+
template <class _CharT, class _Traits>
31+
class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstreambuf)) basic_streambuf;
32+
33+
_LIBCPP_END_NAMESPACE_STD
34+
35+
#endif // _LIBCPP___FWD_STREAMBUF_H

libcxx/include/fstream

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ typedef basic_fstream<wchar_t> wfstream;
183183
#include <__assert> // all public C++ headers provide the assertion handler
184184
#include <__availability>
185185
#include <__config>
186+
#include <__fwd/fstream.h>
186187
#include <__locale>
187188
#include <__utility/move.h>
188189
#include <__utility/swap.h>

libcxx/include/ios

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ storage-class-specifier const error_category& iostream_category() noexcept;
217217
#endif
218218

219219
#include <__assert> // all public C++ headers provide the assertion handler
220+
#include <__fwd/ios.h>
220221
#include <__ios/fpos.h>
221222
#include <__locale>
222223
#include <__system_error/error_category.h>

0 commit comments

Comments
 (0)