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

    <tr>
        <th>Summary</th>
        <td>
            "In file included from" diagnostic prelude omitted incorrectly if preceding note from the same file
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:diagnostics
      </td>
    </tr>

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

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

<pre>
    a.cpp:
```
#include "b.h"
#include "c.h"
```

b.h:
```
void b1();
template <class T> void b2(T x, T y) { x + y; }
```

c.h:
```
void c() {
    b1(0);
    b2("0", "0");
}
```

Run the following:
```
$ clang -fsyntax-only a.cpp
In file included from a.cpp:2:
./c.h:2:5: error: no matching function for call to 'b1'
    b1(0);
    ^~
./b.h:1:6: note: candidate function not viable: requires 0 arguments, but 1 was provided
void b1();
     ^
./b.h:2:42: error: invalid operands to binary expression ('const char *' and 'const char *')
template <class T> void b2(T x, T y) { x + y; }
                                       ~ ^ ~
./c.h:3:5: note: in instantiation of function template specialization 'b2<const char *>' requested here
    b2("0", "0");
    ^
2 errors generated.
```

Note that the `./b.h:2:42: error:` line is missing the `In file included from` prelude indicating the source of the include. This seems to occur when the previously generated note was from the same file the error is being generated from; if I change the `b1(0)` line to `b3()` instead, so that the first error doesn't have a note from `b.h`, then the second error does get the expected prelude.

I discovered this while debugging a script to parse Clang error output. I imagine that SARIF output will be a better option for that sort of work once it's stabilized, but it doesn't currently seem to include the "In file included from" information, which is useful for my purposes.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVstu47gS_Rp6U4ggU34uvHCSNpDNXfTND1BkSaoZitSQlB33or99UJQdJ0E6PQOMYVgSWY9z6lRRVjFS6xB3Ynkvlo8zNabOh13sEZ2iWe3NeacKPQyi2ovyUZR7sSov3-lRVuS0HQ2CkLIuOiHlZzv67c6HEPmXXX-R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