Feature #1993

Ide/Builders: U++ builder for clang-tidy

Added by Sender Ghost over 4 years ago. Updated about 4 years ago.

Status:Patch readyStart date:10/15/2019
Priority:NormalDue date:
Assignee:Miroslav Fidler% Done:

0%

Category:IDESpent time:-
Target version:-

Description

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).

For example:

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.

modernize-use-override_output.txt Magnifier - The example of output for modernize-use-override checker (120 KB) Sender Ghost, 10/15/2019 02:08 PM

modernize-use-override_fixes.diff Magnifier - The example of applied modernize-use-override fixes (33.7 KB) Sender Ghost, 10/15/2019 02:08 PM

uppsrc_ide_r14075.diff Magnifier - Proposed patch for uppsrc/ide directory (since 14075 revision) (6.7 KB) Sender Ghost, 02/24/2020 09:17 PM

History

#1 Updated by Sender Ghost over 4 years 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 over 4 years ago

Attached some example for clang-tidy's modernize-use-override checker and applied fixes for uppsrc/Core directory (at 13636 revision).

Used following "Compiler name" for this build method:

clang-tidy --quiet -header-filter=".*" -checks="-*,modernize-use-override" -fix

#3 Updated by Sender Ghost over 4 years 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).

#4 Updated by Sender Ghost over 4 years ago

  • Status changed from New to Patch ready

#5 Updated by Sender Ghost about 4 years ago

  • File deleted (uppsrc_ide.diff)

#6 Updated by Sender Ghost about 4 years ago

  • File uppsrc_ide_r13969.diff added

Updated patch after 13968 revision changes.

#7 Updated by Sender Ghost about 4 years ago

  • File deleted (uppsrc_ide_r13969.diff)

#8 Updated by Sender Ghost about 4 years ago

Updated patch after 14075 revision changes. Removed previously proposed changes for uppsrc/ide/ide.lay file.

Also available in: Atom PDF