LinuxCommandLibrary

clang-tidy

Clang-based C++ linter and static analyzer

TLDR

Run checks on file

$ clang-tidy [file.cpp] -- -I[include/path]
copy
List enabled checks
$ clang-tidy --list-checks
copy
List all available checks
$ clang-tidy --list-checks -checks='*'
copy
Run specific checks
$ clang-tidy -checks='-*,modernize-*' [file.cpp]
copy
Apply automatic fixes
$ clang-tidy --fix [file.cpp]
copy
Export fixes to file
$ clang-tidy --export-fixes=[fixes.yaml] [file.cpp]
copy
Dump configuration
$ clang-tidy --dump-config
copy

SYNOPSIS

clang-tidy [options] file [-- compileoptions_]

DESCRIPTION

clang-tidy is a clang-based C++ linter tool for diagnosing and fixing typical programming errors including style violations, interface misuse, and bugs detectable via static analysis. It is part of the LLVM/Clang extra tools.
The tool provides hundreds of checks organized into categories such as bugprone, modernize, performance, readability, and cppcoreguidelines. Many checks can automatically apply fixes to source code, making it useful for large-scale code modernization (e.g., migrating to modern C++ idioms).
clang-tidy uses a .clang-tidy configuration file for project-level settings and supports inline suppression with NOLINT comments. For large projects, run-clang-tidy.py provides parallel execution across multiple files.

PARAMETERS

-checks=list

Comma-separated list of checks (+/- prefixed globs)
--list-checks
List enabled checks
--fix
Apply suggested fixes
--fix-errors
Apply fixes even if errors occur
--export-fixes=file
Write fixes to YAML file
--dump-config
Dump configuration to stdout
--warnings-as-errors=list
Treat specified warnings as errors
-p path
Path to compilation database
--config-file=file
Path to .clang-tidy config

CONFIGURATION

Create .clang-tidy in project root:

$ Checks: '-*,modernize-*,bugprone-*'
WarningsAsErrors: '*'
copy

CHECK CATEGORIES

bugprone-*

Bug-prone patterns
modernize-*
C++ modernization
performance-*
Performance issues
readability-*
Code readability
cppcoreguidelines-*
C++ Core Guidelines

SUPPRESSION

Use comments: NOLINT, NOLINTNEXTLINE, NOLINTBEGIN/NOLINTEND

CAVEATS

Requires compilation database for complex projects. Use run-clang-tidy.py for parallel execution.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99
nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99