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

    <tr>
        <th>Summary</th>
        <td>
            run-clang-tidy.py and absolute paths in compile_commands.json
        </td>
    </tr>

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

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

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

<pre>
    In my cmake build system, compile_commands.json contains absolute paths both for "directory" and "source". So the script run-clang-tidy.py doesn't work [here](https://github.com/llvm/llvm-project/blob/07fa6d1d90c714fa269529c3e5004a063d814c4a/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py#L526), when tries to calculates the absolute path of a source file joining "directory" and "file" paths.

I think the script assumes "file" path is always relative to "directory" path, but it isn't true in general.

One fix could be:

`files = {e["file"] if os.path.isabs(e["file"]) else os.path.abspath(os.path.join(e["directory"], e["file"])) for e in database}`

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUU01v5CgQ_TXlSykWjbHbPviQTMvSSCvtYX_ACkO5TYKhReFken79ik5mJpvMHvaEKOrjvccrzezOgWiE9gHaU6X3vMY0XuL37_s5xGqO9jp-Dbhd0Wz6iXDenbfIV860gfyCJm4X5-lvE7dNB8v1I8eAJoasXWDUM0e_Z8KLzivjHPOKS0wIUlqXyOSYriAl6mBLjOOeDIGUNf4VMa-EbJK7ZEx7uDNeh_NddvZaX65oI3EAecz4EtMTQvuwUiJoTyD7NecLQ3MPcgI5nV1e97k2cQM5ef_847i7pPhIJoOcZh9nkJM4LrqzBzsIczyoRctuaOVgGmqFUFp0je0PyigNcnoDE6PnO_qW07uYs1eQU3kCOX0CDrL5o5UdyKHI97JSwJwcMeaIRnuze53LbaV_i4dxQY2vAuHiPOFjdMGF839pWXLK9aZ8DeIexP1XzKsLT--V1cz7RvyxAh2j9i_6ypjI6-yeqSD8OKukFh7zntFldG9fktNO6AKeKVDS_m36n6Eg_4Ym7t7iTOWHbg_QiTKbEZoTwvGBiht_4oH2hG7ByHWZVjvWM4PsPyWBHJA8089MPfMrvv5HpEj2q_Q9k1v9F_xd09K3ePbGyOqsZ80ExxN0AsR9ZcfGDs2gKxoPRzX0veoPbbWObbtoc1gOjWy6fiaz0ECk-0EJNYuhVZUbpZCt6A5KHEXXtvXSL7Yj2w5WCWmUAiVo087Xxa11TOfKMe80HpSSYqi8nsnz-Ir4vfcK7iqNN4_P-5lBCe84868-2WVP4-elKtb5sLIu_H7Hqz358X8v2o0Ag5zeODyP8p8AAAD__yq9ddc">