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

Jon Phillips via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 17 04:59:11 PDT 2023


jp4a50 added a comment.

In D146101#4195293 <https://reviews.llvm.org/D146101#4195293>, @owenpan wrote:

> Please see https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options. Is there a way to fix the issue without adding a new option?

@owenpan We could simply change the indentation level of designated initializers for everyone to match `IndentWidth` instead of `ContinuationIndentWidth` but I suspect that other users might be unhappy if we made that breaking change? I guess we could also consider making this behaviour only kick in when a specific set of *other* options are specified (e.g. `AlwaysBreak`) so that it applies to our clang-format style and not *all* others but that just feels like a hack.

I understand the added complexity and maintenance burden of a new option but we do meet the 3 criteria listed in your link.

- it is part of the KJ style guide which is used by the capn proto <https://github.com/capnproto/capnproto> project which has over 100 maintainers
- the style guide is publicly accessible here <https://github.com/capnproto/capnproto/blob/master/style-guide.md>
- I'm willing to contribute and maintain patches :)

I think it's also worth noting that the google style guide <https://google.github.io/styleguide/cppguide.html#Designated_initializers> gives an example of designated initializers indented at 2 spaces (whereas their "continuation indent" for wrapped function parameters is 4).


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