Use clangd to get instances of a specific warning in a big project and apply it's fix from the command-line

56 Views Asked by At

I'm working on a big c++ project, using cmake/QtCreator.

The code has been around for a long time and so build times are slow.

I believe removing unused includes would reduce this build time significantly.

In my IDE (QtCreator), the most common warning relating to includes is the following :

Included header something.h is not used directly (fix available)

Calling the fix on all instances using the QtCreator's GUI would be painfully slow, which makes me wonder :

Is there a way to script this ?

  1. call clangd on my compile_commands.json

  2. ask it to only log the specific warning (Diagnostics.UnusedIncludes),

  3. apply the suggested quick fix using clang-tidy

I tried to call clangd with my path to compile-commands as well as clang-tidy but it neither wrote the checks nor applied the fixes, simply telling me that I should not call clangd from the command-line :/ source for the warning name: https://clangd.llvm.org/config#unusedincludes

0

There are 0 best solutions below