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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy has no way to conditionally apply checks to headers
        </td>
    </tr>

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

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

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

<pre>
    I have a project where I want to enable most of clang-tidy's `modernize-*` checks, including `modernize-use-nodiscard`.
However there seems to be a problem where Qt MOC cannot parse `[[nodiscard]]` when building this on older platforms like Ubuntu 18.04 and 20.04.

The Qt specific files in this project are all under `src/gui/` path, so I thought that I could place a `.clang-tidy` file there with contents:
```
Checks: '-modernize-use-nodiscard'
InheritParentConfig: true
```
To me this means that it should use all the other top-level-enabled checks *except* `modernize-use-nodiscard`.
But for whatever reason, headers don't seem to follow `.clang-tidy` settings (only the top level one though?)

I don't understand why a header filter exists but not a general filename filter.
Why is the interface for checking headers so obscure and difficult compared to the rest of source files?

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlFGP6yYQhX8NeRklsnHixA9-yO4qah6qttKt-oxhbOjFYMGwuemvr8De7q10K1WyElmGme-cOSBiNJND7NnphZ3ediKR9qEnjVq4uBu8evZ30OIdQcAS_J8oCR4aA8IdHsIRkAd0YrAIs48EfgRphZv2ZNST8XME1lazVxic-Qv3jF9ZW4HUKL9Gxl_BOGmTMm7697oUce-8MlGKoFhbHVj1xqrrT_6B7xiACkFEnGMGGDa6weK80f1G8PMvryCFc55gESFi7lBkvnxWPr3lp63yLgdDMrawkDYRvANvFQZYrKDRhzmCNV8Rfh-SowT15VAdQTgFvDpUx41w_f2iC0FcUJrRSBiNxQjGrYU_fBQBQVgLyeUurK1ikIzfpmQYv2WoRZDOJkUPdyDt06QJSAuCO0ifrMpoMovPFn3ne1uVlptPD0MapHeEjiJrNsbsxvqU19d1JM0VGD_v_2sS_LyuvjuNwdCvIqCjV-9GM-WtFBL-sPoXDzOu6mcULq4qDEHURUeKqxWkEXymBvLL3uI72v0aL7WFBhi_4jeJCzF-_V-heUkEow_w0IJKegKK6F02VqNQGCKo_HqmkqgcqNFb6x8_cDUikXFTprh4Z58FmPwCBRW8w21OrLkx3n2fifs_Xcq8I-XoPPQTxIaRR0YYAL-ZSBGGRJCzK2BCh0HYMlInZtwWbvL-0E8wsYAYRxjGnIist_iV0_yhMnrwQ5Qpx84pUGYcjUyWQPp5EQFVlp7rBFxPcvQpSFzTmwWVfjvVN6prOrHDvm7PVVsf68tpp_v23B2bqr6cOynby6Xm9XlQSrVSnAdxOl12pucV5zWvurrj3bE-YDMem6odO9Xwk2oadqxwFsYerH2fDz5MOxNjwv7UHflpZ8WANpabinOHDygfGef54gp93rMf0hTZsbLZwc8qZMhi_zlJ0CKC8_AQzyxZeqcMGe-EtU8Qy2KfH2Ej_-HeLgXba6KlnCB-ywfVkE7DQfqZ8Vtutv3ttwPO-K0gRsZvRcLfAQAA__-TJ8xb">