How do you install clang-tidy on macOS?
It seems quite easy to install clang-format (using brew) on macOS, but it it seems much harder to install clang-tidy without install and building all of clang and building from source. Is there a better option?
If you have the llvm toolchain already installed, you can find the clang-format.py file in /usr/local/opt/llvm/share/clang/clang-format.py without having to install a separate clang-format binary through Homebrew.
I don't think there is a really easy way to do this today, here are some details:
brew install clang-format
As a result it seems like the best way to get clang-tidy on macOS is to simply install all of llvm and then make symlinks for the tools you want to use.
brew install llvm ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format" ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy" ln -s "$(brew --prefix llvm)/bin/clang-apply-replacements" "/usr/local/bin/clang-apply-replacements"
Alternatively, you could download the prebuilt binaries and create the same symlinks. It's not a good idea to add all of llvm to your PATH
because of conflicts with the default clang compiler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With