Skip to content

run-clang-tidy processes files from compilation database in random order #73357

@firewave

Description

@firewave

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:

[
{
  "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

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions