<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54385>54385</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            make clang suggest adding <ostream> include when trying to stream without having the full ostream definition
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zmodem
      </td>
    </tr>
</table>

<pre>
    Consider:

```
$ cat /tmp/a.cc
#include <iosfwd>

extern std::ostream stream;

void f() {
  stream << "hello!";
}

$ clang++ -c /tmp/a.cc
/tmp/a.cc:6:10: error: invalid operands to binary expression ('std::ostream' (aka 'basic_ostream<char>') and 'const char[7]')
  stream << "hello!";
  ~~~~~~ ^  ~~~~~~~~
1 error generated.
```

It would be helpful if the error could include a fixit note about including <ostream>, similarly to how Clang sometimes makes other suggestions for missing includes, such as:


```
$ echo 'void f() { printf("hello"); }' | build.release/bin/clang -x c -c -
<stdin>:1:12: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration]
void f() { printf("hello"); }
           ^
<stdin>:1:12: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVlM1y4ygQgJ9GvnRZZYNl2QcdYiep2ifY4xYCJLGDwAXIjvfpt1s_iSeTmalRISRo6N8Paq_u1dm7aJQOGX_KNs_ZZun3m7lNQ7YDKRJk7DX1F-xFLuUi4sZJOygNGT8bH5ubyvjLozL9lnRwEJMiK_zJxxS06GH6ZPz0uPjqjYImY4eMHSErZxnMi8kGNnSEddpan7Et_n6oKJ-_i4LctsK1GTthg7X8OoLHKf60x3e7wQ50CJ4yA8ZdhUW__EUH4VSE5KE2ToQ76LdL0DEa72B0uvwcJk6RRHwT-ClrEY38ZxHxs-xEoHSxkuJF3bRIYlESjK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