CLANG-TIDY(1)
π¦ CLANG-TIDY π¦
okay bestie, welcome to the manual page for clang-tidy 22 β she's the linter/static-analyzer bestie of the LLVM world and she is so iconic. let's get into it π
β¨ NAME β¨
clang-tidy β manual page for clang-tidy 22
πΈ DESCRIPTION πΈ
here's the vibe, the whole ~usage~ moment:
USAGE: clang-tidy [options] <source0> [... <sourceN>]
and then... the options π so many options. but we're gonna get through them together, no cap.
π Generic Options π
the basic-girl options. everyone needs them.
--helpβ shows you all the available options (--help-hiddengets you even more π)--help-listβ shows you the list of available options (--help-list-hiddenfor even more than that)--versionβ tells you which version of this program you're running
π clang-tidy options π
this is the main character section, fr fr.
--allow-no-checksβ lets you have an empty set of enabled checks. this suppresses the whole "no checks enabled" error that would otherwise pop off when you disable literally all of them.--checks=<string>β a comma-separated list of globs, each one optionally prefixed with-. globs get processed in the order they show up in the list. globs without the-prefix add checks with matching names into the set; globs with the-prefix remove checks with matching names from the set of enabled checks. and this option's value gets appended to whatever theChecksoption in your.clang-tidyfile says, if there is one.--config=<string>β specify a config in YAML/JSON format, like:
-config="{Checks: '*',
CheckOptions: {x: y}}"
when the value is empty, clang-tidy will try to find a file named .clang-tidy for each source file in its parent directories.
--config-file=<string>β point at the path of your.clang-tidyor custom config file, e.g.--config-file=/some/path/myTidyConfigFile. inside, this option works exactly the same way as the--configoption does, just after it reads the specified config file. and bestie β use either--config-fileor--config, never both π--dump-configβ dumps the configuration tostdoutin YAML format. you can use this along with a file name (and--if the file lives outside of a project with a configured compilation database). the configuration used for that file will be what gets printed. use it along with-checks=*to include the configuration of all the checks.--enable-check-profileβ turns on per-check timing profiles and prints a report tostderr.--enable-module-headers-parsingβ enables preprocessor-level module header parsing for C++20 and above, which empowers specific checks to detect macro definitions inside modules. heads up though: this feature may cause performance and parsing issues, so it's considered experimental π¬--exclude-header-filter=<string>β a regular expression matching the names of the headers to exclude diagnostics from. diagnostics from the main file of each translation unit are always displayed no matter what. must be used together with--header-filter. can be used together with-line-filter. this option overrides theExcludeHeaderFilterRegexoption in.clang-tidy, if there is one.--experimental-custom-checksβ enables experimental clang-query based custom checks. see https://clang.llvm.org/extra/clang-tidy/QueryBasedCustomChecks.html.--explain-configβ for each enabled check, explains where it's enabled β like in the clang-tidy binary, on the command line, or in a specific configuration file. she's giving receipts π--export-fixes=<filename>β a YAML file to store suggested fixes in. the stored fixes can be applied to the input source code withclang-apply-replacements.--extra-arg=<string>β an additional argument to append to the compiler command line--extra-arg-before=<string>β an additional argument to prepend to the compiler command line--fixβ apply the suggested fixes. without-fix-errors, clang-tidy will bail out if any compilation errors were found.--fix-errorsβ apply suggested fixes even if compilation errors were found. and if compiler errors have fix-its attached, clang-tidy will apply those too.--fix-notesβ if a warning has no fix, but a single fix can be found through an associated diagnostic note, apply that fix. specifying this flag implicitly enables the--fixflag.--format-style=<string>β the style used for formatting code around applied fixes:'none'(this is the default) turns formatting off'file'(literally the wordfile, not a placeholder) uses the.clang-formatfile in the closest parent directory'{ <json> }'specifies options inline, e.g.-format-style='{BasedOnStyle: llvm, IndentWidth: 8}''llvm','google','webkit','mozilla'β see the clang-format documentation for the up-to-date info about formatting styles and options. this option overrides theFormatStyleoption in.clang-tidy, if there is one.
--header-filter=<string>β a regular expression matching the names of the headers to output diagnostics from. the default value is'.*', meaning diagnostics from all non-system headers are displayed by default. diagnostics from the main file of each translation unit are always displayed. can be used together with-line-filter. this option overrides theHeaderFilterRegexoption in.clang-tidy, if there is one.--line-filter=<string>β a list of files and line ranges to output diagnostics from. the range is inclusive on both ends. can be used together with-header-filter. the format of the list is a JSON array of objects, like:
[ {"name":"file1.cpp","lines":[[1,3],[5,7]]}, {"name":"file2.h"}
]
this will output diagnostics from 'file1.cpp' only for the line ranges [1,3] and [5,7], plus everything from all of 'file2.h'.
--list-checksβ list all enabled checks and exit. use it with-checks=*to list all available checks.--load=<pluginfilename>β load the specified plugin π-p <string>β build path--quietβ run clang-tidy in quiet mode. this suppresses printing statistics about ignored warnings and about warnings treated as errors, if those respective options were specified.--removed-arg=<string>β a list of arguments to remove from the command line sent to the compiler. β οΈ please note: removing arguments might change the semantics of the analyzed code, possibly leading to compiler errors, false positives or false negatives. this option is applied before--extra-argand--extra-arg-before.--store-check-profile=<prefix>β by default reports are printed in tabulated format tostderr. when this option is passed, those per-TU profiles get stored as JSON instead.--system-headersβ display the errors from system headers. this option overrides theSystemHeadersoption in.clang-tidy, if there is one.--use-colorβ use colors in diagnostics. if it's not set, colors will be used if the terminal connected to standard output supports colors. this option overrides theUseColoroption in.clang-tidy, if there is one. π--verify-configβ check the config files to make sure each check and option is recognized, without running any checks at all.--vfsoverlay=<filename>β overlay the virtual filesystem described by file on top of the real file system.--warnings-as-errors=<string>β upgrades warnings to errors. same format as'-checks'. this option's value gets appended to the value of theWarningsAsErrorsoption in.clang-tidy, if there is one.
-p <build-path> is used to read a compile command database.
for example, it can be a CMake build directory that has a file named compile_commands.json in it (use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option to get this output). when no build path is specified, a search for compile_commands.json will be attempted through all parent paths of the first input file. see: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for an example of setting up Clang Tooling on a source tree.
<source0> ... specifies the paths of source files. these paths get looked up in the compile command database. if the path of a file is absolute, it needs to point into CMake's source tree. if the path is relative, the current working directory needs to be in the CMake source tree and the file must be in a subdirectory of the current working directory. "./" prefixes in the relative files get removed automatically, but the rest of a relative path must be a suffix of a path in the compile command database.
π§ Parameters files π§
a large number of options or source files can be passed as parameter files by using '@parameter-file' in the command line. slay, batch it up.
π Configuration files π
clang-tidy tries to read configuration for each source file from a .clang-tidy file located in the closest parent directory of the source file. the .clang-tidy file is specified in YAML format. and important: if any configuration options have a corresponding command-line option, the command-line option takes precedence π
the following configuration options may be used in a .clang-tidy file:
CheckOptionsβ list of key-value pairs defining check-specific options. example:
CheckOptions:
some-check.SomeOption: 'some value'
Checksβ same as'--checks'. additionally, the list of globs can be specified as a list instead of a string.CustomChecksβ array of user defined checks based on Clang-Query syntax.ExcludeHeaderFilterRegexβ same as'--exclude-header-filter'.ExtraArgsβ same as'--extra-arg'.ExtraArgsBeforeβ same as'--extra-arg-before'.FormatStyleβ same as'--format-style'.HeaderFileExtensionsβ file extensions to consider when determining if a given diagnostic is located in a header file.HeaderFilterRegexβ same as'--header-filter'.ImplementationFileExtensionsβ file extensions to consider when determining if a given diagnostic is located in an implementation file.InheritParentConfigβ if this option is true in a config file, the configuration file in the parent directory (if one exists) will be taken, and the current config file will be applied on top of the parent one. iconic inheritance moment πRemovedArgsβ same as'--removed-arg'.SystemHeadersβ literally the same thing as--system-headers. Same energy, different outfit. β¨UseColorβ same as--use-color. Yeah bestie, it's a vibe match. πUserβ here you put the name or the e-mail of the user running clang-tidy. What's it for, you ask? It's used, for example, to drop the correct user name intoTODO()comments in the relevant check. So the checks can leave little notes addressed to you. Cute, honestly. πWarningsAsErrorsβ same as--warnings-as-errors. No cap. π₯
And if you wanna see what your config actually ended up being (because vibes can deceive), the effective configuration can be inspected using --dump-config:
$ clang-tidy --dump-config
which gives you something like:
Checks:
'-*,some-check'
WarningsAsErrors:
''
HeaderFileExtensions:
['', 'h','hh','hpp','hxx']
ImplementationFileExtensions: ['c','cc','cpp','cxx']
HeaderFilterRegex: '.*'
FormatStyle: none
InheritParentConfig: true
User: user
CheckOptions:
some-check.SomeOption: 'some value'
...
Look at her. All your settings, laid bare, alphabetically-ish, no secrets between you two. π«Ά
And that's the whole page, bestie!! π This lil' masterpiece is from clang-tidy 22, dated September 2026, and it's filed under CLANG-TIDY(1) in the man pages, exactly where it belongs. Go forth and tidy your C++ β not me being the most organized girl in the terminal fr fr. β¨ππ¦π
π¦ where this page comes from
- ubuntu stonking: clang-tidy-22 1:22.1.8-1ubuntu1 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms