Integrations.rst 10.5 KB

Clang-tidy IDE/Editor Integrations

Apart from being a standalone tool, :program:`clang-tidy` is integrated into various IDEs, code analyzers, and editors. We recommend using clangd which integrates :program:`clang-tidy` and is available in most major editors through plugins (Vim, Emacs, Visual Studio Code, Sublime Text and more).

The following table shows the most well-known :program:`clang-tidy` integrations in detail.

  Feature
Tool On-the-fly inspection Check list configuration (GUI) Options to checks (GUI) Configuration via .clang-tidy files Custom clang-tidy binary
A.L.E. for Vim + - - - +
Clang Power Tools for Visual Studio - + - + -
Clangd + - - + -
CLion IDE + + + + +
CodeChecker - - - - +
CPPCheck - - - - -
CPPDepend - - - - -
Flycheck for Emacs + - - + +
KDevelop IDE - + + + +
Qt Creator IDE + + - + +
ReSharper C++ for Visual Studio + + - + +
Syntastic for Vim + - - - +
Visual Assist for Visual Studio + + - - -

IDEs

CLion 2017.2 and later integrates clang-tidy as an extension to the built-in code analyzer. Starting from 2018.2 EAP, CLion allows using :program:`clang-tidy` via Clangd. Inspections and applicable quick-fixes are performed on the fly, and checks can be configured in standard command line format. In this integration, you can switch to the :program:`clang-tidy` binary different from the bundled one, pass the configuration in .clang-tidy files instead of using the IDE settings, and configure options for particular checks.

KDevelop with the kdev-clang-tidy plugin, starting from version 5.1, performs static analysis using :program:`clang-tidy`. The plugin launches the :program:`clang-tidy` binary from the specified location and parses its output to provide a list of issues.

QtCreator 4.6 integrates :program:`clang-tidy` warnings into the editor diagnostics under the Clang Code Model. To employ :program:`clang-tidy` inspection in QtCreator, you need to create a copy of one of the presets and choose the checks to be performed. Since QtCreator 4.7 project-wide analysis is possible with the Clang Tools analyzer.

MS Visual Studio has a native clang-tidy-vs plugin and also can integrate :program:`clang-tidy` by means of three other tools. The ReSharper C++ extension, version 2017.3 and later, provides seamless :program:`clang-tidy` integration: checks and quick-fixes run alongside native inspections. Apart from that, ReSharper C++ incorporates :program:`clang-tidy` as a separate step of its code clean-up process. Visual Assist build 2210 includes a subset of :program:`clang-tidy` checklist to inspect the code as you edit. Another way to bring :program:`clang-tidy` functionality to Visual Studio is the Clang Power Tools plugin, which includes most of the :program:`clang-tidy` checks and runs them during compilation or as a separate step of code analysis.

Editors

Emacs24, when expanded with the Flycheck plugin, incorporates the :program:`clang-tidy` inspection into the syntax analyzer. For Vim, you can use Syntastic, which includes :program:`clang-tidy`, or A.L.E., a lint engine that applies :program:`clang-tidy` along with other linters.

Analyzers

:program:`clang-tidy` is integrated in CPPDepend starting from version 2018.1 and CPPCheck 1.82. CPPCheck integration lets you import Visual Studio solutions and run the :program:`clang-tidy` inspection on them. The CodeChecker application of version 5.3 or later, which also comes as a plugin for Eclipse, supports :program:`clang-tidy` as a static analysis instrument and allows to use a custom :program:`clang-tidy` binary.