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.
How to configure Clang-Tidy profile
General configuration
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 ( (or for macOS users), select C/C++ | General | Clang-Tidy: To configure the list of checks that you want to enable / disable, use the Clang-Tidy command line format (see example below).
To set up the desired severity level and scope for all the checks select the values from the drop-down lists of the Inspections Settings dialog.
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.
Per check configurations
You can disable a particular Clang-Tidy check from the CLion context menu, as follows: This action will update the list of enabled/disable checks in // NOLINT
.
Clang-Tidy executable
You can use bundled or your own Clang-Tidy in CLion, at your choice. If you prefer the latter you shall provide a path to the Clang-Tidy binary in
(or if you are macOS user):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-*
: 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.