A faster alternative to clang-tidy
Low maintenance activity. Last release 10 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and issue handling.
Consider insteadclang-tidyPythie’s Index: 77884.9K downloads/moCompare →
pip install clangd-tidyclangd-tidy: A Faster Alternative to clang-tidy
Motivation
clang-tidy is a powerful tool for static analysis of C++ code. However, it's widely acknowledged that clang-tidy takes a significant amount of time to run on large codebases, particularly when enabling numerous checks. This often leads to the dilemma of disabling valuable checks to expedite clang-tidy execution.
In contrast, clangd, the language server with built-in support for clang-tidy, has been observed to be significantly faster than clang-tidy when running the same checks. It provides diagnostics almost instantly upon opening a file in your editor. The key distinction lies in the fact that clang-tidy checks the codes from all headers (although it suppresses the warnings from them by default), whereas clangd only builds AST from these headers.
Unfortunately, there seems to be no plan within LLVM to accelerate the standalone version of clang-tidy. This project addresses this by offering a faster alternative to clang-tidy, leveraging the speed of clangd. It acts as a wrapper for clangd, running it in the background and collecting diagnostics. Designed as a drop-in replacement for clang-tidy, it seamlessly integrates with existing build systems and CI scripts.
Comparison with clang-tidy
Pros:
- clangd-tidy is significantly faster than clang-tidy (over 10x in my experience).
- clangd-tidy can check header files individually, even if they are not included in the compilation database.
- clangd-tidy groups diagnostics by files -- no more duplicated diagnostics from the same header!
- clangd-tidy provides an optional code format checking feature, eliminating the need to run clang-format separately.
- clangd-tidy supports
.clangdconfiguration files, offering features not supported by clang-tidy.- Example: Removing unknown compiler flags from the compilation database.
CompileFlags: Remove: -fabi* - Example: Adding IWYU include checks.
Diagnostics: # Available in clangd-14 UnusedIncludes: Strict # Require clangd-17 MissingIncludes: Strict
- Example: Removing unknown compiler flags from the compilation database.
- Hyperlinks on diagnostic check names in supported terminals.