Clang-Tidy is a Clang-based tool for static code analysis. CLion shows Clang-Tidy checks the same way as its own code inspections, with quick-fixes available via the -button or Alt+Enter:
General Clang-Tidy settings
Clang-Tidy checks are enabled by default, and you can see them as warnings (or messages of another severity level) in the editor.
Note that not all the checks are enabled by default. Here you can find details of the Clang-Tidy default configuration in CLion.
To change the Clang-Tidy configuration, go to, :
If you need to enable/disable some particular checks, use the Clang-Tidy command line format. It specifies a comma-separated list of positive and negative globs: positive globs add subsets of checks, while negative globs (prefixed with
"-") remove them.
For example, the following command line will disable all default checks
-* and enable all the
clang-analyzer-* checks except for the
Also, you can set the desired severity level and scope for Clang-Tidy checks by selecting from the drop-down lists.
Options for particular checks
Some Clang-Tidy checks have options, which are either additional or substantial for the check (like those for readability-identifier-naming).
To configure options for a particular check, use the Configure Clang-Tidy Checks Options dialog. For example, you can force the
modernize-use-nullptr check to replace any
NULL-like macros with
Tuning checks in the editor
In addition to the Inspections Settings dialog, you can disable a single check, a group of checks, or the entire Clang-Tidy inspection from the editor. These actions respectively update the Clang-Tidy command line.
To suppress a Clang-Tidy check for a particular line, use the Suppress "check_name" for line option. CLion will add a
// NOLINT comment at the end of the selected line.
With .clang-tidy files, you can set per-directory configurations: for each source file, Clang-Tidy will attempt to read configuration from .clang-tidy in the closest parent directory.
.clang-tidy files are in the YAML format. For a syntax example, let's enable all of the Clang-Tidy checks and provide the additional option to
By default, .clang-tidy files take precedence over the IDE settings. When analyzing a source file, CLion uses the settings from a reachable configuration file (located in the current directory or in one of the parent directories). If there is no such file, CLion relies on its own settings.
To change this behavior, clear the Prefer .clang-tidy files over IDE settings checkbox in , .
Custom Clang-Tidy executable
You can work with your own Clang-Tidy executable instead of the bundled one (for example, when you want to create custom checks and use them in CLion).
Provide the path to your custom Clang-Tidy binary in Specify Clang-Tidy executable in the Inspections Settings dialog).(or click
This setting is IDE-wide: your custom Clang-Tidy binary will be used for all projects.