Home

ClangTidy

Clang-Tidy is a clang-based C/C++ linter and static analysis tool that is part of the LLVM project. It analyzes source code using Clang's libTooling and AST matchers to find bugs, coding style violations, and potential performance issues, and it can propose automatic fixes (fix-its).

The checks are grouped into modules such as readability, modernize, performance, portability, bugprone, and misc, and

Clang-Tidy operates on a compilation database, typically compile_commands.json, and can read an inline .clang-tidy configuration file

The checks are implemented as plugins within the clang-tidy framework and rely on Clang's AST to reason

can
be
enabled
or
disabled
selectively.
or
be
driven
entirely
by
command-line
options.
It
supports
the
-checks
flag
to
enable
or
disable
checks,
-warnings-as-errors
to
treat
certain
checks
as
failures,
and
-fix
to
emit
edits
directly
to
the
source.
It
can
be
run
as
a
standalone
tool
or
integrated
into
build
systems
(for
example
via
a
CMake
script)
and
into
continuous
integration
pipelines.
It
also
supports
diff
generation
with
clang-tidy-diff
and
can
be
used
with
-format
to
apply
formatting
changes.
about
code
semantics.
While
powerful,
some
checks
may
produce
false
positives
or
require
accurate
compilation
databases;
developers
should
review
fixes
before
committing.
Clang-Tidy
is
commonly
used
to
enforce
coding
standards,
modernize
legacy
code,
and
improve
code
quality
across
large
C++
codebases.