6

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?

Joel
  • 1,564
  • 7
  • 12
  • 20
Sharky
  • 323
  • 1
  • 3
  • 11
  • Have you tried it on a smaller number of files/checks or a single file and check? What are the errors it returns? – pablo285 Nov 09 '18 at 13:32
  • Sorry for my language, but when I wrote that the command returned a lot of errors I meant a list of rules that I'm breaking in my code (clang errors). The command behaves as it should returning this errors list but does not apply the fixes for the errors with the - fix option – Sharky Nov 11 '18 at 18:48

2 Answers2

3

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.
pablo285
  • 2,460
  • 4
  • 14
  • 38
0

I also ran into the same issue while I was trying to automatically apply clang-tidy fixes via LLVM's run-clang-tidy python script:

The Root of the problem for me was a mismatch of the run-clang-tidy.py script, clang-tidy and the version of clang-apply-replacements. The latter was version 10 instead of 11, so installing clang-tidy-11 and linking clang-apply-replacements to the clang-apply-replacements-11 fixed the issue for me. I also downloaded the run-clang-tidy script from LLVM's repository with the matching tag.

Is this also the cause of your problem? If the reported versions don't match, similar steps might also solve your problem.

clang++ --version
clang-tidy --version
clang-apply-replacements --version
mutableVoid
  • 1,284
  • 2
  • 11
  • 29