|
1 | 1 | ---
|
2 | 2 | title: Using Clang-Tidy in Visual Studio
|
3 | 3 | description: "How to use Clang-Tidy in Visual Studio for Microsoft C++ code analysis."
|
4 |
| -ms.date: 02/22/2022 |
| 4 | +ms.date: 03/1/2022 |
5 | 5 | ms.topic: "conceptual"
|
6 | 6 | f1_keywords: ["vs.codeanalysis.clangtidy"]
|
7 | 7 | ---
|
8 | 8 | # Using Clang-Tidy in Visual Studio
|
9 | 9 |
|
10 | 10 | ::: moniker range="<=msvc-150"
|
11 | 11 |
|
12 |
| -Support for Clang-Tidy requires Visual Studio 2019 version 16.4 or later. To see the documentation for this version, set the Visual Studio **Version** selector control for this article to Visual Studio 2019 or later. It's found at the top of the table of contents on this page. |
| 12 | +Support for Clang-Tidy requires Visual Studio 2019 version 16.4 or later. To see the documentation for this version, set the Visual Studio **Version** selector control for this article to Visual Studio 2019 or later. It's at the top of the table of contents on this page. |
13 | 13 |
|
14 | 14 | ::: moniker-end
|
15 | 15 |
|
@@ -37,13 +37,13 @@ Clang-Tidy recognizes the following keys:
|
37 | 37 |
|
38 | 38 | - `enableMicrosoftCodeAnalysis`: Enables Microsoft Code Analysis
|
39 | 39 | - `enableClangTidyCodeAnalysis`: Enables Clang-Tidy analysis
|
40 |
| -- `clangTidyChecks`: Clang-Tidy configuration. A comma-separated list of checks to enable or disable. A leading `-` disables the check. For example, "cert-oop58-cpp, -cppcoreguidelines-no-malloc, google-runtime-int" enables `cert-oop58-cpp` and `google-runtime-int`, but disables `cppcoreguidelines-no-malloc`. |
| 40 | +- `clangTidyChecks`: Clang-Tidy configuration. A comma-separated list of checks to enable or disable. A leading `-` disables the check. For example, `cert-oop58-cpp, -cppcoreguidelines-no-malloc, google-runtime-int` enables `cert-oop58-cpp` and `google-runtime-int`, but disables `cppcoreguidelines-no-malloc`. For a list of Clang-Tidy checks, see the [Clang-Tidy documentation](https://clang.llvm.org/extra/clang-tidy/checks/list.html). |
41 | 41 |
|
42 |
| -If neither of the "enable" options are specified, Visual Studio will select the analysis tool matching the Platform Toolset used. |
| 42 | +If neither of the "enable" options are specified, Visual Studio selects the analysis tool matching the Platform Toolset used. |
43 | 43 |
|
44 | 44 | ### CMake settings
|
45 | 45 |
|
46 |
| -To edit your Clang-Tidy settings, open your CMake settings, and select **Edit JSON** in the CMake Project Settings Editor. You can use the keys above to fill out your Clang-Tidy specifications in the CMake Settings json file. |
| 46 | +To edit your Clang-Tidy settings, open your CMake settings, and select **Edit JSON** in the CMake Project Settings Editor. You can use the keys above to fill out your Clang-Tidy specifications in the CMake Settings JSON file. |
47 | 47 |
|
48 | 48 | An example CMake settings implementation looks like this:
|
49 | 49 |
|
@@ -82,18 +82,17 @@ An example CMake preset implementation looks like this:
|
82 | 82 | }
|
83 | 83 | ]
|
84 | 84 | ```
|
85 |
| - |
86 | 85 | ## Warning display
|
87 | 86 |
|
88 |
| -Clang-Tidy runs result in warnings displayed in the Error List, and as in-editor squiggles underneath relevant sections of code. Use the "Category" column in the Error List to sort and organize Clang-Tidy warnings. You can configure in-editor warnings by toggling the "Disable Code Analysis Squiggles" setting under **Tools** > **Options**. |
| 87 | +Clang-Tidy runs result in warnings displayed in the Error List, and as in-editor squiggles underneath relevant sections of code. To sort and organize Clang-Tidy warnings, use the **Category** column in the **Error List** window. You can configure in-editor warnings by toggling the **Disable Code Analysis Squiggles** setting under **Tools** > **Options**. |
89 | 88 |
|
90 | 89 | ## Clang-Tidy configuration
|
91 | 90 |
|
92 | 91 | By default, Clang-Tidy does not set any checks when enabled. To see the list of checks in the command-line version, run `clang-tidy -list-checks` in a developer command prompt. You can configure the checks that Clang-Tidy runs inside Visual Studio. In the project Property Pages dialog, open the **Configuration Properties** > **Code Analysis** > **Clang-Tidy** page. Enter checks to run in the **Clang-Tidy Checks** property. A good default set is `clang-analyzer-*`. This property value is provided to the **`--checks`** argument of the tool. Any further configuration can be included in custom *`.clang-tidy`* files. For more information, see the [Clang-Tidy documentation on LLVM.org](https://clang.llvm.org/extra/clang-tidy/).
|
93 | 92 |
|
94 | 93 | ## See also
|
95 | 94 |
|
96 |
| -- [Clang/LLVM support for MSBuild projects](https://devblogs.microsoft.com/cppblog/clang-llvm-support-for-msbuild-projects/) |
97 |
| -- [Clang/LLVM support for CMake projects](https://devblogs.microsoft.com/cppblog/visual-studio-cmake-support-clang-llvm-cmake-3-14-vcpkg-and-performance-improvements/) |
| 95 | +[Clang/LLVM support for MSBuild projects](https://devblogs.microsoft.com/cppblog/clang-llvm-support-for-msbuild-projects/)\ |
| 96 | +[Clang/LLVM support for CMake projects](https://devblogs.microsoft.com/cppblog/visual-studio-cmake-support-clang-llvm-cmake-3-14-vcpkg-and-performance-improvements/) |
98 | 97 |
|
99 | 98 | ::: moniker-end
|
0 commit comments