Debian Codegraph @

llvm-project/clang-tools-extra/docs/clang-tidy/Integrations.rst

raw
1 ==================================
2 Clang-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
9 Apart from being a standalone tool, :program:`clang-tidy` is integrated into
10 various IDEs, code analyzers, and editors. We recommend using clangd_ which
11 integrates :program:`clang-tidy` and `is available`_ in most major editors
12 through plugins (Vim, Emacs, Visual Studio Code, Sublime Text and more_).
13
14 The following table shows the most well-known :program:`clang-tidy`
15 integrations 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
54 CLion_ 2017.2 and later `integrates clang-tidy`_ as an extension to the
55 built-in code analyzer. Starting from 2018.2 EAP, CLion allows using
56 :program:`clang-tidy` via Clangd. Inspections and applicable quick-fixes are
57 performed on the fly, and checks can be configured in standard command line
58 format. In this integration, you can switch to the :program:`clang-tidy`
59 binary different from the bundled one, pass the configuration in
60 ``.clang-tidy`` files instead of using the IDE settings, and configure
61 options for particular checks.
62
63 .. _KDevelop: https://www.kdevelop.org/
64 .. _kdev-clang-tidy: https://github.com/KDE/kdev-clang-tidy/
65
66 KDevelop_ with the kdev-clang-tidy_ plugin, starting from version 5.1, performs
67 static analysis using :program:`clang-tidy`. The plugin launches the
68 :program:`clang-tidy` binary from the specified location and parses its
69 output 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
75 QtCreator_ 4.6 integrates :program:`clang-tidy` warnings into the editor
76 diagnostics under the `Clang Code Model`_. To employ :program:`clang-tidy`
77 inspection in QtCreator, you need to create a copy of one of the presets and
78 choose the checks to be performed. Since QtCreator 4.7 project-wide analysis is
79 possible 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 .. _clang-tidy-vs: https://github.com/llvm/llvm-project/tree/main/clang-tools-extra/clang-tidy-vs
86
87 `MS Visual Studio`_ has a native clang-tidy-vs_ plugin and also can integrate
88 :program:`clang-tidy` by means of three other tools. The `ReSharper C++`_
89 extension, version 2017.3 and later, provides seamless :program:`clang-tidy`
90 integration: checks and quick-fixes run alongside native inspections. Apart
91 from that, ReSharper C++ incorporates :program:`clang-tidy` as a separate
92 step of its code clean-up process. `Visual Assist`_ build 2210 includes a
93 subset of :program:`clang-tidy` checklist to inspect the code as you edit.
94 Another way to bring :program:`clang-tidy` functionality to Visual Studio is
95 the `Clang Power Tools`_ plugin, which includes most of the
96 :program:`clang-tidy` checks and runs them during compilation or as a separate
97 step of code analysis.
98
99 **Editors**
100
101 .. _Flycheck: https://github.com/ch1bo/flycheck-clang-tidy
102 .. _Syntastic: https://github.com/vim-syntastic/syntastic
103 .. _A.L.E.: https://github.com/w0rp/ale
104 .. _Emacs24: https://www.gnu.org/s/emacs/
105 .. _Vim: https://www.vim.org/
106
107 Emacs24_, when expanded with the Flycheck_ plugin, incorporates the
108 :program:`clang-tidy` inspection into the syntax analyzer. For Vim_, you can
109 use Syntastic_, which includes :program:`clang-tidy`, or `A.L.E.`_,
110 a lint engine that applies :program:`clang-tidy` along with other linters.
111
112 **Analyzers**
113
114 .. _CPPDepend: https://www.cppdepend.com/cppdependv2018
115 .. _CPPCheck: https://sourceforge.net/p/cppcheck/news/
116 .. _CodeChecker: https://github.com/Ericsson/codechecker
117 .. _plugin: https://github.com/Ericsson/CodeCheckerEclipsePlugin
118
119 :program:`clang-tidy` is integrated in CPPDepend_ starting from version 2018.1
120 and CPPCheck_ 1.82. CPPCheck integration lets you import Visual Studio
121 solutions and run the :program:`clang-tidy` inspection on them. The
122 CodeChecker_ application of version 5.3 or later, which also comes as a plugin_
123 for Eclipse, supports :program:`clang-tidy` as a static analysis instrument and
124 allows to use a custom :program:`clang-tidy` binary.