Coding Style

Hi all,

What is the coding style that clang developers (https://github.com/llvm-mirror/clang) use? When I use “.clang-format” to reformat the code that is in this repo, cpp files change. Is there any other clang-format config that is used in this repo?

Hi all,

What is the coding style that clang developers (https://github.com/llvm-mirror/clang) use? When I use “.clang-format” to reformat the code that is in this repo, cpp files change. Is there any other clang-format config that is used in this repo?

That the code does not change when clang-format is applied using the LLVM style (--style=llvm) is not an actual requirement the last I checked. Put another way, clang-format output is not the only valid expression of the LLVM style. Instead of applying clang-format to the entire file, try using clang/tools/clang-format/git-clang-format.

To put it yet another way:

We want new/modified code to conform to the style enforced by clang-format. We have not applied that format to all existing code. LLVM’s coding style has evolved over the years, and the general feeling within the project is that a mass conversion from old to new style would be too disruptive. So, you will find a mix of styles within the project, although it’s not too common to find a mix of styles within the same file.

For patches you might be writing, there are a couple of useful scripts in clang/tools/clang-format, which are clang-format-diff.py and git-clang-format.

–paulr