Search code examples
clang-tidy

clang-tidy -fix does not apply any changes


I'm running clang-tidy with the following command:

run-clang-tidy.py -checks="-*,cppcoreguidelines-*,hicpps-*" -header-filter=".*" -fix"

(or clang-tidy -checks="-*,cppcoreguidelines-*,hicpps-*" -header-filter=".*" -fix" also works)

This returns a lot of errors. It also says applying fixes... in the terminal since I added the -fix option.

My problem is that for the cppcoreguidelines-* and hicpps-* fixes are not applied, only shown. Does the checks that I have choose not to support fixing my 1000 problems?


Solution

  • You should use the -fix-errors option instead of just -fix. The latter will not apply any fixes if compiler errors are present. See the clang-tidy documentation:

      -fix                          -
                                      Apply suggested fixes. Without -fix-errors
                                      clang-tidy will bail out if any compilation
                                      errors were found.
      -fix-errors                   -
                                      Apply suggested fixes even if compilation
                                      errors were found. If compiler errors have
                                      attached fix-its, clang-tidy will apply them as
                                      well.