CLion 2017.2 Help

Clang-Tidy Integration

Basics

Clang-Tidy is a popular clang-based tool for static code analysis. CLion supports Clang-Tidy in the same way as its own code analysis tool.

Settings and customization

Clang-Tidy checks are enabled by default in CLion and you can see them as the warnings or messages of other severity levels in the editor. Here you can find the details on the Clang-Tidy default configuration in CLion. Note, that not all the checks are enabled by default. You can change the Clang-Tidy configuration in Inspections Settings dialog (File | Settings | Editor | Inspections (or CLion | Preferences | Editor | Inspections for macOS users), select C/C++ | General | Clang-Tidy.
If you need to switch Clang-Tidy checks off completely, unselect the corresponding check-box (the right column) or select this check-box to enable Clang-Tidy checks support again. To set up the desired severity level and scope for all the checks select the values from the drop-down lists. You can configure the list of checks to enable / disable in text form, by using the Clang-Tidy command line format.

Example

Let's run the C++ Core Guidelines checks on the project. To do that, open the Settings dialog (see above) and pass the following line -*,cppcoreguidelines-*:

cl ClangTidySettings
As the result, only C++ Core Guidelines checks are running on the project:
The same, pass -*,clang-analyzer-* line to run the Clang Static Analyzer checks or -*,modernize-* for modernize checks.

Last modified: 15 December 2017

See Also

External Links: