working with clang-format source code


I’d like to explore the source code of clang-format. Do I have to download and build the entire clang? I’m interested in how clang-format handles “simple structural rules like those in the LLVM coding standards.”


Hi Owen,

If you are just interested in exploring the source code of clang-format, you have a couple of options. You can browse the llvm-mirror on GitHub. You can also check out the LLVM + Clang + Clang tools repositories, as documented in “Getting Started: Building and Running Clang” steps 1-4. clang-format lives under llvm/tools/clang/tools/clang-format.

If you want to poke around and try changing some things, you can then compile the code by following step 7 in the getting started guide (“Build LLVM and Clang”). The binaries will show up in build/bin. The first time around the compilation will take its time, subsequent builds will be much faster.

Phillip van Heerden

Hi Phillip,

Thanks for the info. I know I can build the entire clang, which includes clang-format, but I don’t know if there is a way to download and build only the part of clang that’s required for clang-format. Any advice would be appreciated.


Hi Philip,
Would new language support (Swift) go into the standard Clang tools referred here?