Skip to content

Commit 58e476f

Browse files
authored
[libc++] Map forward declaration headers for iostreams to <iosfwd> (#83327)
This seems more appropriate than mapping them to the headers that contain actual definitions.
1 parent c66f2d0 commit 58e476f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

libcxx/include/libcxx.imp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,17 +425,17 @@
425425
{ include: [ "<__fwd/bit_reference.h>", "private", "<bitset>", "public" ] },
426426
{ include: [ "<__fwd/bit_reference.h>", "private", "<vector>", "public" ] },
427427
{ include: [ "<__fwd/complex.h>", "private", "<complex>", "public" ] },
428-
{ include: [ "<__fwd/fstream.h>", "private", "<fstream>", "public" ] },
428+
{ include: [ "<__fwd/fstream.h>", "private", "<iosfwd>", "public" ] },
429429
{ include: [ "<__fwd/hash.h>", "private", "<functional>", "public" ] },
430-
{ include: [ "<__fwd/ios.h>", "private", "<ios>", "public" ] },
431-
{ include: [ "<__fwd/istream.h>", "private", "<istream>", "public" ] },
430+
{ include: [ "<__fwd/ios.h>", "private", "<iosfwd>", "public" ] },
431+
{ include: [ "<__fwd/istream.h>", "private", "<iosfwd>", "public" ] },
432432
{ include: [ "<__fwd/mdspan.h>", "private", "<mdspan>", "public" ] },
433433
{ include: [ "<__fwd/memory_resource.h>", "private", "<memory_resource>", "public" ] },
434-
{ include: [ "<__fwd/ostream.h>", "private", "<ostream>", "public" ] },
434+
{ include: [ "<__fwd/ostream.h>", "private", "<iosfwd>", "public" ] },
435435
{ include: [ "<__fwd/pair.h>", "private", "<utility>", "public" ] },
436436
{ include: [ "<__fwd/span.h>", "private", "<span>", "public" ] },
437-
{ include: [ "<__fwd/sstream.h>", "private", "<sstream>", "public" ] },
438-
{ include: [ "<__fwd/streambuf.h>", "private", "<streambuf>", "public" ] },
437+
{ include: [ "<__fwd/sstream.h>", "private", "<iosfwd>", "public" ] },
438+
{ include: [ "<__fwd/streambuf.h>", "private", "<iosfwd>", "public" ] },
439439
{ include: [ "<__fwd/string.h>", "private", "<string>", "public" ] },
440440
{ include: [ "<__fwd/string_view.h>", "private", "<string_view>", "public" ] },
441441
{ include: [ "<__fwd/subrange.h>", "private", "<ranges>", "public" ] },

libcxx/utils/generate_iwyu_mapping.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def IWYU_mapping(header: str) -> typing.Optional[typing.List[str]]:
4040
return ["utility"]
4141
elif header == "__fwd/subrange.h":
4242
return ["ranges"]
43+
elif re.match("__fwd/(fstream|ios|istream|ostream|sstream|streambuf)[.]h", header):
44+
return ["iosfwd"]
4345
# Handle remaining forward declaration headers
4446
elif re.match("__fwd/(.+)[.]h", header):
4547
return [re.match("__fwd/(.+)[.]h", header).group(1)]

0 commit comments

Comments
 (0)