[PATCH] D146101: [clang-format] Add DesignatedInitializerIndentWidth option.

Jon Phillips via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 19 05:03:56 PDT 2023


jp4a50 added a comment.

> The style guide doesn't mention indenting designated initializers with 2 spaces?

That is a fair point. I will get it updated because the author and maintainer of that style guide is the one requesting this change since, in practice, codebases following this style guide indent designated initializers with 2 spaces.

>> I think it's also worth noting that the google style guide gives an example of designated initializers indented at 2 spaces (whereas their "continuation indent" for wrapped function parameters is 4).
>
> It's likely an error that the designated initializer example there shows 2-space indents as clang-format uses the 4-space continuation indent width:

This is possible, but isn't it also possible that they would prefer designated initializers to be indented at 2 spaces but don't have the option with clang-format currently?

The only general information supplied in the google style guide about indentation is as follows:

> - Default indentation is 2 spaces.
> - Wrapped parameters have a 4 space indent.

If we are taking a strict definition of parameters, the above suggests to me that designated initializers would fall under the default indentation of 2 spaces.

As mentioned on my other diff, I'm away until next Monday now so won't be able to get back to further comments til then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146101/new/

https://reviews.llvm.org/D146101



More information about the cfe-commits mailing list