xref: /llvm-project/clang-tools-extra/docs/clang-tidy/Integrations.rst (revision 9322216021f1d8241b87a81c12321b05aa6d1cfb)
1==================================
2Clang-tidy IDE/Editor Integrations
3==================================
4
5.. _clangd: http://clangd.llvm.org/
6.. _is available: https://clangd.llvm.org/installation.html#editor-plugins
7.. _more: https://langserver.org/#implementations-client
8
9Apart from being a standalone tool, :program:`clang-tidy` is integrated into
10various IDEs, code analyzers, and editors. We recommend using clangd_ which
11integrates :program:`clang-tidy` and `is available`_ in most major editors
12through plugins (Vim, Emacs, Visual Studio Code, Sublime Text and more_).
13
14The following table shows the most well-known :program:`clang-tidy`
15integrations in detail.
16
17+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
18|                                      |        Feature         |                                 |                          |                                         |                          |
19+======================================+========================+=================================+==========================+=========================================+==========================+
20|  **Tool**                            | On-the-fly inspection  | Check list configuration (GUI)  | Options to checks (GUI)  | Configuration via ``.clang-tidy`` files | Custom clang-tidy binary |
21+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
22|A.L.E. for Vim                        |         \+\            |               \-\               |           \-\            |                 \-\                     |           \+\            |
23+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
24|Clang Power Tools for Visual Studio   |         \-\            |               \+\               |           \-\            |                 \+\                     |           \-\            |
25+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
26|Clangd                                |         \+\            |               \-\               |           \-\            |                 \+\                     |           \-\            |
27+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
28|CLion IDE                             |         \+\            |               \+\               |           \+\            |                 \+\                     |           \+\            |
29+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
30|CodeChecker                           |         \-\            |               \-\               |           \-\            |                 \-\                     |           \+\            |
31+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
32|CPPCheck                              |         \-\            |               \-\               |           \-\            |                 \-\                     |           \-\            |
33+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
34|CPPDepend                             |         \-\            |               \-\               |           \-\            |                 \-\                     |           \-\            |
35+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
36|Flycheck for Emacs                    |         \+\            |               \-\               |           \-\            |                 \+\                     |           \+\            |
37+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
38|KDevelop IDE                          |         \-\            |               \+\               |           \+\            |                 \+\                     |           \+\            |
39+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
40|Qt Creator IDE                        |         \+\            |               \+\               |           \-\            |                 \+\                     |           \+\            |
41+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
42|ReSharper C++ for Visual Studio       |         \+\            |               \+\               |           \-\            |                 \+\                     |           \+\            |
43+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
44|Syntastic for Vim                     |         \+\            |               \-\               |           \-\            |                 \-\                     |           \+\            |
45+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
46|Visual Assist for Visual Studio       |         \+\            |               \+\               |           \-\            |                 \-\                     |           \-\            |
47+--------------------------------------+------------------------+---------------------------------+--------------------------+-----------------------------------------+--------------------------+
48
49**IDEs**
50
51.. _CLion: https://www.jetbrains.com/clion/
52.. _integrates clang-tidy: https://www.jetbrains.com/help/clion/clang-tidy-checks-support.html
53
54CLion_ 2017.2 and later `integrates clang-tidy`_ as an extension to the
55built-in code analyzer. Starting from 2018.2 EAP, CLion allows using
56:program:`clang-tidy` via Clangd. Inspections and applicable quick-fixes are
57performed on the fly, and checks can be configured in standard command line
58format. In this integration, you can switch to the :program:`clang-tidy`
59binary different from the bundled one, pass the configuration in
60``.clang-tidy`` files instead of using the IDE settings, and configure
61options for particular checks.
62
63.. _KDevelop: https://www.kdevelop.org/
64.. _kdev-clang-tidy: https://github.com/KDE/kdev-clang-tidy/
65
66KDevelop_ with the kdev-clang-tidy_ plugin, starting from version 5.1, performs
67static analysis using :program:`clang-tidy`. The plugin launches the
68:program:`clang-tidy` binary from the specified location and parses its
69output to provide a list of issues.
70
71.. _QtCreator: https://www.qt.io/
72.. _Clang Code Model: https://doc.qt.io/qtcreator/creator-clang-codemodel.html
73.. _Clang Tools: https://doc.qt.io/qtcreator/creator-clang-tools.html
74
75QtCreator_ 4.6 integrates :program:`clang-tidy` warnings into the editor
76diagnostics under the `Clang Code Model`_. To employ :program:`clang-tidy`
77inspection in QtCreator, you need to create a copy of one of the presets and
78choose the checks to be performed. Since QtCreator 4.7 project-wide analysis is
79possible with the `Clang Tools`_ analyzer.
80
81.. _MS Visual Studio: https://visualstudio.microsoft.com/
82.. _ReSharper C++: https://www.jetbrains.com/help/resharper/Clang_Tidy_Integration.html
83.. _Visual Assist: https://docs.wholetomato.com/default.asp?W761
84.. _Clang Power Tools: https://marketplace.visualstudio.com/items?itemName=caphyon.ClangPowerTools
85
86`MS Visual Studio`_  can integrate :program:`clang-tidy` by means of three different tools.
87The `ReSharper C++`_ extension, version 2017.3 and later, provides seamless
88:program:`clang-tidy` integration: checks and quick-fixes run alongside native inspections.
89Apart from that, ReSharper C++ incorporates :program:`clang-tidy` as a separate
90step of its code clean-up process. `Visual Assist`_ build 2210 includes a
91subset of :program:`clang-tidy` checklist to inspect the code as you edit.
92Another way to bring :program:`clang-tidy` functionality to Visual Studio is
93the `Clang Power Tools`_ plugin, which includes most of the
94:program:`clang-tidy` checks and runs them during compilation or as a separate
95step of code analysis.
96
97**Editors**
98
99.. _Flycheck: https://github.com/ch1bo/flycheck-clang-tidy
100.. _Syntastic: https://github.com/vim-syntastic/syntastic
101.. _A.L.E.: https://github.com/w0rp/ale
102.. _Emacs24: https://www.gnu.org/s/emacs/
103.. _Vim: https://www.vim.org/
104
105Emacs24_, when expanded with the Flycheck_ plugin, incorporates the
106:program:`clang-tidy` inspection into the syntax analyzer. For Vim_, you can
107use Syntastic_, which includes :program:`clang-tidy`, or `A.L.E.`_,
108a lint engine that applies :program:`clang-tidy` along with other linters.
109
110**Analyzers**
111
112.. _CPPDepend: https://www.cppdepend.com/cppdependv2018
113.. _CPPCheck: https://sourceforge.net/p/cppcheck/news/
114.. _CodeChecker: https://github.com/Ericsson/codechecker
115.. _plugin: https://github.com/Ericsson/CodeCheckerEclipsePlugin
116
117:program:`clang-tidy` is integrated in CPPDepend_ starting from version 2018.1
118and CPPCheck_ 1.82. CPPCheck integration lets you import Visual Studio
119solutions and run the :program:`clang-tidy` inspection on them. The
120CodeChecker_ application of version 5.3 or later, which also comes as a plugin_
121for Eclipse, supports :program:`clang-tidy` as a static analysis instrument and
122allows to use a custom :program:`clang-tidy` binary.
123