Ide/Builders: U++ builder for clang-tidy
|Status:||Patch ready||Start date:||10/15/2019|
|Assignee:||Miroslav Fidler||% Done:|
There is clang-tidy tool available as part of LLVM/Clang.
The clang-tidy has following usage format (for advanced use):
clang-tidy [options] <source0> [... <sourceN>] [-- [compiler options]]
Where "options" is clang-tidy options, "source0" is some C/C++ source code file(s), "--" is some delimiter between clang-tidy and compiler options, such as includes (-I) and defines (-D).
clang-tidy --quiet -header-filter=".*" -checks="-*,modernize-use-override" test.cpp
may use modernize-use-override checker for test.cpp file.
Possible to apply available fixes with using "-fix" clang-tidy option:
clang-tidy --quiet -header-filter=".*" -checks="-*,modernize-use-override" -fix test.cpp
Some command to get list of available checkers:
clang-tidy -list-checks -checks="*"
Possible to use SCRIPT builder for some build method for clang-tidy.
But also possible to implement this as some kind of U++ builder (which also may support BLITZ build).
Therefore, I propose to create U++ builder for clang-tidy.
Some patch attached. Based on GccBuilder::BuildPackage method.
The clang-tidy options possible to use as part of "Compiler name" for build method. So, I also extended width of EditString for compiler variable in BuildMethodsDefaultBuilderSetupLayout layout for uppsrc/ide/ide.lay file.
#1 Updated by Sender Ghost 3 months ago
I noticed, that for proper usage there is also a need to specify default include compiler path(s) for "INCLUDE directories" or as "-isystem path" for "Common options" in build method.
Possible to get list of default compiler paths with using following command (replace /dev/null for other empty file on Windows):
clang++ -v -fsyntax-only -x c++ /dev/null
and search between "#include <...> search starts here:" and "End of search list.".
Maybe this is some kind of feature, if use compiler options after "--" delimiter.
Overall, this may be simple to configure, based on error(s) output.
#2 Updated by Sender Ghost 3 months ago
#3 Updated by Sender Ghost 3 months ago
Also need to note, that I used 1 HYDRA thread for IDE settings, when using "-fix" option for clang-tidy command.
There is possibility to use --export-fixes=<filename> option for clang-tidy command, which may be used for clang-apply-replacements tool. But path for <filename> should be unique, otherwise its contents may be overwritten after new fixes (e.g. if use "Build package" for some U++ package, instead of "Compile" for some file).