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

    <tr>
        <th>Summary</th>
        <td>
            [clang-tidy] misc-include-cleaner doesn't understand associated headers
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

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

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

<pre>
    Apologies if this is covered in documentation somewhere, but I ran into this issue while enabling the misc-include-cleaner check in clang-tidy, which was added in version 17.

The most pressing issue is that when `file.cpp` consists only of 
`#include "file.h"` 
The `misc-include-cleaner emits` a warning that `file.h` is unused. This construction is made specifically so that `file.h` is compiled on its own in at least one translation unit. The practice of doing so is recommended by John Lakos in his book and in his talks he has held. See https://github.com/Bloomberg/BDE/wiki/physical-code-organization#component-design-rules 

Additionally, the guideline appears to suggest that within a `file.h` + `file.cpp` pair, it is sufficient to include some header in only the header file.

Trying to follow the documentation, from https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/misc/include-cleaner.html it seems like this clang-tidy check is based on the corresponding functionality in clangd. Following that chain, the clangd documentation suggests that "Include What You Use"-pragmas are supported https://clangd.llvm.org/design/include-cleaner#iwyu-pragmas. And finally, the docmentation for these pragmas suggests that there exists a specific pragma that can be used to declare that a header file should be treated as associated with the main file of the translation unit. https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md#iwyu-pragma-associated I tried to apply this pragma in some instances, but it doesn't appear to have had any effect.

Without this sorted out, it seems like this check might be a bit too noisy for our use. However, the documentation suggests that this check only applies to main implementation files, so maybe this is working as intended so far?

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8Vk9v4z4O_TTKhUiQKH86PeTQ2W6wXexhgZ3BYI6yREfcyqIhys3k9-l_oJ20aefPpallieR7fI-yE6FjR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