This Homebrew tap installs clang-format, clang-tidy and other LLVM tools on macOS from pre-built static binaries, without building LLVM.
Website · Get started · Discussions
brew install cpp-linter/tap/clang-format@21
Install with the full cpp-linter/tap/<formula> name. Homebrew adds the tap and
trusts the formula you named, so no other step is needed.
Important
Short names such as brew install clang-tidy need brew tap cpp-linter/tap
and brew trust cpp-linter/tap first: since Homebrew 6, formulae from
third-party taps are not loaded until they are trusted. clang-format is also
a Homebrew core formula, so brew install clang-format installs that one
instead of this tap's. Write cpp-linter/tap/clang-format.
All 9 tools are bundled in the clang-tools formula, or can be installed individually:
brew install cpp-linter/tap/clang-tools # all 9 tools below brew install cpp-linter/tap/clang-format # code formatter brew install cpp-linter/tap/clang-tidy # linter / static analyzer brew install cpp-linter/tap/clang-query # AST query tool brew install cpp-linter/tap/clang-apply-replacements # apply clang-tidy fixes brew install cpp-linter/tap/clang-include-cleaner # remove unused headers brew install cpp-linter/tap/clang-scan-deps # dependency scanner for modules brew install cpp-linter/tap/llvm-cov # code coverage reporting brew install cpp-linter/tap/llvm-profdata # profile data tool brew install cpp-linter/tap/llvm-symbolizer # symbolizer for sanitizers / logs
Append @<version> for a specific LLVM version, for example cpp-linter/tap/clang-tools@21.
clang-tidy, clang-query and clang-include-cleaner read your code the way the compiler
does, so they need two more things than the other tools:
- clang's builtin headers (
stddef.h,stdarg.h, ...). The formulae install them next to the tool, in the place where clang looks for them. - The macOS SDK, which holds the C and C++ standard headers. Apple's clang finds it by
itself; clang built from upstream LLVM does not. The formulae install a small script as
clang-tidy(and the other two) that setsSDKROOTto the output ofxcrun --show-sdk-pathand then runs the tool. AnSDKROOTthat you set yourself is kept.
The SDK belongs to the Xcode version on your Mac, and an old LLVM version cannot always parse
the C++ headers of a new SDK. If clang-tidy@19 reports errors inside the SDK's own headers,
use a newer LLVM version.
brew update brew upgrade cpp-linter/tap/clang-tools
To update a single tool:
brew upgrade cpp-linter/tap/clang-format
A formula without @<version> moves to the next LLVM major version when this tap adds one,
so brew upgrade can change its major version. @<version> formulae stay on theirs.
The formulae cover LLVM 19 to 23, for macOS only. Formulae without a version suffix install
LLVM 23; @22, @21, @20 and @19 install those versions.
Each formula downloads the pre-built static binaries from the cpp-linter/clang-tools-static-binaries GitHub Releases matching your macOS architecture (ARM64 or x86_64).
The SHA-256 checksums are verified during installation.
Every formula installs its tools under their plain names, such as clang-format, and Homebrew
links only one formula's clang-format into its bin directory. If another formula already
links it (another @<version>, clang-tools, or Homebrew core's clang-format), the new one is
installed but not linked. Switch with brew unlink on the other formula and brew link on this
one, or run the one that is not linked by its full path:
"$(brew --prefix cpp-linter/tap/clang-format@21)/bin/clang-format" --versioncpp-linter/tap/clang-format and Homebrew core's clang-format cannot be installed at the same
time, because they have the same name.
The Update Formula workflow runs daily and opens a pull request when the clang-tools-static-binaries index changes the formulae. The index lists one release per LLVM version, so each formula points at its own version's release. To update them by hand:
bash scripts/update-formula.sh
This will regenerate all Formula/*.rb files (both bundle and individual tool
formulae) with the correct URLs and SHA-256 checksums, after checking each binary
against the SHA-512 in the index.
Every LLVM version in the index from MIN_VERSION in scripts/update-formula.py up gets a
formula, and the newest one gets the unversioned name. The script never deletes formulae, so
remove the files of a version that leaves the index.
See the contributing guide and report problems in issues.
The formulae and scripts in this repository are released under the MIT License. The tools they install are built from LLVM, which is under the Apache License v2.0 with LLVM Exceptions.