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

    <tr>
        <th>Summary</th>
        <td>
            Add a way for clang-tidy to generate depfile
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    Hello, I'm trying to integrate clang-tidy in my CMake with custom commands to have more control over whats going on.

I wanted to use the depfile feature of CMake for `add_custom_command`, but after a lot of head-scratching realized that clang-tidy is purposely filtering out any "dependency" flag (starting with `M`) ! 

See [here](https://github.com/llvm/llvm-project/blob/0c35b6165ccc4fc3c5c1286236a02ea6f7894d00/clang/lib/Tooling/ArgumentsAdjusters.cpp#L89) for the relevant function.

I think we should add a way to force clang-tidy to honor those flags, or just always allow them because the compile-commands doesn't have those anyway (at least with CMake) ?

NOTE: There is an ugly workaround, `--write-dependencies` (alias of `-MD`) is not filtered.  So you can make clang-tidy generate a dependency file, but there is no way to specify the output directory nor the main target.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVU02PnDgQ_TVwKXULzEfTBw69mR1tpJ3kkLlHxi7AGWMj2wwhvz5lunsyoz1tCzWycdV79d5zZ-XW_oNa24R9gs8JO00Q3KbMAMGCMgEHxwOC0NwMh6DkRpswbfDpib8grCqMIBYf7ATCThM30sfCkb8iTNZRoTXBWQ32FR2sIw8eBhvbW3NMsocku1z_P8PKCU3G6sUjhBFB4twrjdAjDwv1sv0NtrcOkjrjUn6_gn-_gdNmnKNbAvA-ECIHbUMsHJHLgxc0jBgjvEOu1a-IR5w-jOdhXtxsPeoNCJ667HRjS7NBwhjRQiPRiI0W0Gs-0G7jA3chntw1ISJPO5kzfcvh_aTfECGp_hrRYVI9UOUYwuyT4pKwR3oGKl-6Iw1EC61f76_D7OwPFIGWnbYdvTJRVF2d15UQouxFISqRs6ZmRc0zhrzuT825lBmReNzni41ULHy2Vqt9fXHDMqEJ_iJ_kJDo_FHMc8KKf5tz5B6Fjk441PhK_kC_GBHUf7wLpOkLrAh-tIuWQM6Q9Cvfop3URHxIUAyINXtrknlX0EfbaCeyAK6p0tNL2zXCT9Ch4PdUkDIzpeLwljdp0RtKbrjG7tqUvIrwJC_Zq5FT292YPUC7LcXj-xm-fH3-mzyA5-hLDAE3sAwUgdW6F-7sQuEiiuTp4bA6FfDwFgOFnrZ3KK24j2mLx54ebgGgZoZCeM0SyiPANwubXUAQxhTz_E6bAQ3uN47Dn5zFWrwHO9wZGntX2M8oVL_t8lBQZzollaOwWLeBuXk4cbq5FNIBwzHFNq_pVzZZkaeyLeS5OPM0qKCxvbyZF-3_6NsbvdvdTBen2_8dYOX9QqKxx6qpTqd0bJuyropc8FNTZhU7VSXrBBZVc-Z9fT51fap5h9q3dG_ozqSqZRljecZKlpenPD-ypm-6jPWSFVUhSkzKDGlefYzAR-uG1LU7h26hqJWZVj74Px-592owiPf-fKEQufZFrernr3Rn2-5UfwNVeLlK">