clang-tidy
What it is
clang-tidy is a free, open-source C++ linter from the LLVM project. It looks for typical programming errors, style violations, interface misuse, and bugs that static analysis can detect. Its checks cover bug-prone code, CERT secure coding, the C++ Core Guidelines, performance, portability, and readability; it can also run Clang Static Analyzer checks. Select checks with the `-checks=` option, which accepts comma-separated positive and negative patterns. The `-fix` flag applies corrections where a check supports them. Settings can be stored in `.clang-tidy` files, including check choices, check-specific options, and custom checks. clang-tidy works with a compilation database such as `compile_commands.json`, or with compiler options supplied on the command line. The included `run-clang-tidy.py` script analyzes files concurrently. A separate diff script filters diagnostics to changed lines, though it still analyzes the whole file. Developers can also create checks using preprocessor callbacks or AST matchers. The tool runs on Linux and lists integrations for several IDEs and editors.
For and against
For
- Free and open source
- Checks cover security, performance, portability, and readability
- Supported findings can receive automatic fixes
- Custom checks can use AST matchers
- Concurrent analysis is included
Against
- Listed platform support is Linux
- Changed-line filtering still analyzes the whole file
- Some builds omit analyzer and MPI checks
The verdict
clang-tidy offers configurable C++ diagnostics, with automatic fixes where checks support them. Its changed-line tool filters reported diagnostics but does not reduce the analysis to changed code.
Who it suits
It suits C++ developers who want configurable static checks, supported automatic fixes, or custom checks in their workflow. It can also suit teams using a compilation database or listed IDE and editor integrations.
Plans and prices
clang-tidy
No paid plans or usage limits stated
Read 11 Oct 2026 · clang.llvm.org
On the record
- Automatic fixes
- The -fix option applies suggested fixes when supported by the corresponding checks.clang.llvm.org · read 11 Oct 2026
- Build integration
- clang-tidy can use a compile command database, which CMake can generate with CMAKE_EXPORT_COMPILE_COMMANDS=ON.clang.llvm.org · read 11 Oct 2026
- Build options
- If built with `CLANG_TIDY_ENABLE_STATIC_ANALYZER=NO`, clang-tidy does not include support for `clang-analyzer-*` or `mpi-*` checks.clang.llvm.org · read 11 Oct 2026
- Changed-line analysis
- `clang-tidy-diff.py` filters reported diagnostics to changed lines, but still analyzes the entire file and does not improve analysis performance.clang.llvm.org · read 11 Oct 2026
- Check categories
- Its check groups include bug-prone code, CERT guidelines, C++ Core Guidelines, performance, portability, and readability checks.clang.llvm.org · read 11 Oct 2026
- Checks
- It provides its own checks and can also run Clang Static Analyzer checks.clang.llvm.org · read 11 Oct 2026
- Check selection
- Checks can be selected with the `-checks=` option, which accepts comma-separated positive and negative globs.clang.llvm.org · read 11 Oct 2026
- clangd support
- The Clang team recommends clangd, which integrates clang-tidy and is available in major editors through plugins including Vim, Emacs, Visual Studio Code, and Sublime Text.clang.llvm.org · read 11 Oct 2026
- Configuration
- Checks can be selected with comma-separated positive and negative globs, and configuration can be read from a .clang-tidy file.clang.llvm.org · read 11 Oct 2026
- CUDA support
- clang-tidy supports CUDA source analysis, with the CUDA toolkit path specified using --cuda-path for correct header resolution.clang.llvm.org · read 11 Oct 2026
- Custom checks
- The tool provides an interface for writing custom checks, which can use preprocessor callbacks or AST matchers and attach fix-it hints to diagnostics.clang.llvm.org · read 11 Oct 2026
- Diff workflow
- clang-tidy-diff.py filters diagnostics to changed lines, but still analyzes the entire file and may miss issues reported outside those lines.clang.llvm.org · read 11 Oct 2026
- Extensible checks
- The tool is modular and provides a framework for writing new checks.clang.llvm.org · read 11 Oct 2026
- IDE/editor integrations
- The documentation links to a Clang-tidy IDE/Editor Integrations page.clang.llvm.org · read 11 Oct 2026
- IDE integrations
- The documentation lists integrations including clangd, CLion, KDevelop, Qt Creator, Visual Studio tools, Vim plugins, and Emacs Flycheck.clang.llvm.org · read 11 Oct 2026
- License
- The LLVM project states that its code is licensed under the Apache 2.0 License with LLVM exceptions.llvm.org · read 11 Oct 2026
- Maker
- LLVM describes itself as a collection of modular and reusable compiler and toolchain technologies, and identifies clang-tidy as an LLVM project tool.llvm.org · read 11 Oct 2026
- Parallel analysis
- The included `run-clang-tidy.py` script runs analysis over files in a compilation database concurrently.clang.llvm.org · read 11 Oct 2026
The review
clang-tidy is a configurable C++ linting and static-analysis tool built on Clang. It is best suited to developers and teams who can provide accurate build settings and want to tailor checks to their codebase. Its main strength is the breadth and extensibility of its checks; its changed-line workflow still analyzes whole files.
Overview
The tool combines its own diagnostics with checks from the Clang Static Analyzer. Its check groups cover bug-prone code, CERT secure coding, the C++ Core Guidelines, performance, portability, and readability. That range supports a shared code policy across several concerns, while check selection lets teams avoid enabling every rule indiscriminately.
Checks are selected with -checks=, using comma-separated positive and negative globs. A .clang-tidy file can hold those selections, check-specific options, and custom checks written with Clang-Query syntax. The -fix flag applies fixes for findings whose checks support them, so it can reduce routine cleanup but does not automate every reported issue.
Key features
Build-aware analysis
clang-tidy uses LibTooling and works with a compilation database such as compile_commands.json; compiler options can also be supplied on the command line. CMake can generate that database with CMAKE_EXPORT_COMPILE_COMMANDS=ON. This makes it a natural fit for projects that can expose their actual compile commands, while projects without reliable compiler settings face more setup work.
Parallel and changed-line workflows
The included run-clang-tidy.py script analyzes files concurrently from a compilation database or specified path. That helps spread analysis across a project. clang-tidy-diff.py filters diagnostics to changed lines, which can make review output more focused, but it still analyzes the entire file and does not improve analysis performance. It can also miss findings reported outside the changed lines.
Custom checks and editor support
Teams can write custom checks using preprocessor callbacks or AST matchers and attach fix-it hints to diagnostics. That flexibility is useful when a project needs rules beyond the supplied check groups, though it calls for C++ tooling expertise to implement and maintain those rules.
Integrations include clangd, CLion, KDevelop, Qt Creator, Visual Studio tools, Vim plugins, and Emacs Flycheck. The Clang team recommends clangd, which brings clang-tidy into major editors through plugins including Vim, Emacs, Visual Studio Code, and Sublime Text. This gives editor users an integration path as well as command-line and build workflows.
CUDA and analyzer checks
clang-tidy can analyze CUDA source when the CUDA toolkit path is supplied with --cuda-path, helping resolve the needed headers. CERT checks and Clang Static Analyzer checks are among its security-related options. Builds configured with CLANG_TIDY_ENABLE_STATIC_ANALYZER=NO omit clang-analyzer-* and mpi-* checks, so those groups depend on how the tool is built.
Pricing
clang-tidy is open source and free: the plan costs nothing, with no paid plans or usage limits stated. There is no free trial because the software is free to use. LLVM code is licensed under Apache 2.0 with LLVM exceptions.
Platforms
Linux is the listed platform. The documentation also describes integrations with multiple editors and IDEs, but the platform listing is Linux.
Who it's for
clang-tidy is a strong choice for C++ developers and teams who want configurable diagnostics in a build or editor workflow, especially when they can provide a compilation database and benefit from custom rules or analyzer checks. Its free, open-source model also suits teams that want to adopt project-wide checks without a software subscription.
It is a less direct fit for readers seeking a changed-code-only analysis pass: the diff tool narrows which diagnostics are shown, not which code is analyzed. Teams that need rules tailored to a project should also account for the effort of writing and maintaining custom checks.
Pros and cons
- Broad, selectable checks: Covers several C++ quality and security categories, with positive and negative globs for tuning the selection.
- Fixes where supported: The -fix option can apply check-provided fixes, but coverage depends on each check.
- Extensible and scriptable: Custom checks, compilation databases, and concurrent runs support project-specific and build-integrated workflows.
- Changed-line output has a limit: The diff script still analyzes whole files, does not speed up analysis, and may omit diagnostics outside changed lines.
- Build configuration matters: Accurate compile commands help analysis match the project, and some analyzer groups depend on build options.
Alternatives
Cppcheck is worth considering for readers who want a freemium static analyzer with Linux, macOS, self-hosted, and Windows platforms; its open-source plan is free, with a separate Project plan at custom pricing.
PMD is a free downloadable static code analyzer for readers whose needs fit its BSD-style licensed offering. Reek is a free Linux option for Ruby code smell detection, installed via RubyGems. SwiftLint is the alternative for open-source Swift linting under an MIT license.
Astral suits readers looking for its open-source, permissively licensed tools Ruff, uv, and ty, available free forever. Biome offers an open-source toolchain for web projects. Checkstyle is a free option for Java source analysis with configurable checks, while Credo is an open-source Elixir static-analysis tool. For more options, browse Linters.
Verdict
Choose clang-tidy if you work in C++ and want a free, adaptable set of checks that can join your build and editor workflows. Its strongest case is the combination of selectable diagnostics, supported automatic fixes, and custom-check support. Look elsewhere if you need changed-line-only analysis or do not have a reliable way to supply project compile settings.