1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
http://clang.llvm.org/extra/clang-tidy/
To use clang-tidy:
* add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to cmake (for example in compile-clang)
* cd src && ln -s ../build-clang/compile_commands.json compile_commands.json
* execute clang-tidy
To list all available checks:
* clang-tidy --list-checks -checks='*' | grep "modernize"
E.g., use override for virtual funcsion:
* clang-tidy my_file.cpp -checks='modernize-use-override'
clan-tidy can also execute clang-analyzer checks, e.g.
* clang-tidy my_file.cpp -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*
To apply the fixes direcly on the file, add 'fix' parameter:
* clang-tidy.py my_file.cpp -header-filter='.*' -checks='-*,modernize-use-nullptr' -fix
To apply clang-tidy to many files, use the run-clang-tidy.py script in this folder (current version under run-clang-tidy.py -header-filter='.*' -checks='-*,modernize-use-nullptr' -fix), execute in src/:
* python3 ../admin/run-clang-tidy.py backend/ -header-filter='.*' -checks='-*,modernize-use-override' -fix
* python3 ../admin/run-clang-tidy.py backend/ -header-filter='.*' -checks='-*,modernize-use-nullptr' -fix
* etc.
|