A Python wheel of clang-apply-replacements, the LLVM-based tool that applies serialized
clang-tidy fix-it replacements (YAML files) to source files.
Website · Get started · Discussions
pip install clang-apply-replacementsThe wheel bundles the clang-apply-replacements binary; no LLVM installation is required on
the host machine.
Tip
In CI, use pipx run clang-apply-replacements — no install needed.
GitHub-hosted runners
ship with pipx pre-installed.
Verify:
clang-apply-replacements --versionclang-tidy --export-fixes writes the fixes it suggests to a YAML file, and
clang-apply-replacements applies every .yaml file under the directory you give it. With a
compile_commands.json in build/:
mkdir -p fixes
clang-tidy -p build --export-fixes=fixes/main.yaml src/main.cpp
clang-apply-replacements --remove-change-desc-files fixes- clang-tidy does not create the
fixesdirectory, so create it first. --remove-change-desc-filesdeletes the YAML files after applying them. Applying the same file twice edits the source twice and breaks it.
Run clang-apply-replacements --help to see all available options. The
clang-tidy documentation describes --export-fixes.
- PyPI has wheels for LLVM 16 and 17.
pip install clang-apply-replacementsinstalls the newest;pip install "clang-apply-replacements==16.*"installs LLVM 16. - Wheels exist for Linux (x86-64, x86, ARM64 and ARMv7 with glibc; x86-64 and x86 with musl), macOS (x86-64 and ARM64) and Windows (x86-64 and x86). On other platforms pip builds the source distribution, which downloads and compiles LLVM.
- Since 22.1.8, the
clang-tidywheel on PyPI also installs aclang-apply-replacementscommand. In an environment with both packages, the one installed last provides the command, and uninstalling either one removes it. - For other LLVM versions, the static binaries include clang-apply-replacements for LLVM 12 to 23.
See CONTRIBUTING.md for development setup, build instructions, and the release process, and use GitHub issues for bug reports and feature requests.
This project is licensed under the Apache License 2.0 - see LICENSE.md for details. The clang-apply-replacements binary bundled in the wheels is part of the LLVM Project and is licensed under the Apache License 2.0 with LLVM Exceptions.