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

    <tr>
        <th>Summary</th>
        <td>
            `run-clang-tidy` processes files from compilation database in random order
        </td>
    </tr>

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

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

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

<pre>
    A compilation database contains a JSON array of compilation commands thus has a fixed order. Such a file can be generated from CMake or a make command (via `bear`) and reflects the order of the commands as they are executed by the build system. The order might be intentional to process long-running files first so in a multi-threaded environment to reduce the build time as you will have better parallelism. The same might is most likely true for the `clang-tidy` invocation.

Unfortunately `run-clang-tidy` (which takes a compilation database via `-p`) processes the files in a random order. The files should be processed in the order provided by the input file.

Example:
```json
[
{
  "directory": "/home/sshuser",
  "command": "/usr/bin/clang++-18 -o big1.cpp.o -c big1.cpp",
  "file": "/home/sshuser/big1.cpp"
},
{
 "directory": "/home/sshuser",
  "command": "/usr/bin/clang++-18 -o big2.cpp.o -c big2.cpp",
  "file": "/home/sshuser/big2.cpp"
},
{
  "directory": "/home/sshuser",
  "command": "/usr/bin/clang++-18 -o c.cpp.o -c c.cpp",
  "file": "/home/sshuser/c.cpp"
},
{
 "directory": "/home/sshuser",
  "command": "/usr/bin/clang++-18 -o d.cpp.o -c d.cpp",
  "file": "/home/sshuser/d.cpp"
}
]
```

```
clang-tidy-18 -p=. /home/sshuser/d.cpp
clang-tidy-18 -p=. /home/sshuser/big1.cpp
clang-tidy-18 -p=. /home/sshuser/c.cpp
clang-tidy-18 -p=. /home/sshuser/big2.cpp
```

```
clang-tidy-18 -p=. /home/sshuser/d.cpp
clang-tidy-18 -p=. /home/sshuser/big1.cpp
clang-tidy-18 -p=. /home/sshuser/big2.cpp
clang-tidy-18 -p=. /home/sshuser/c.cpp
```
</pre>
<img width="1px" height="1px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