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

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 19 02:25:32 PDT 2023


owenpan added a comment.

In D146101#4201842 <https://reviews.llvm.org/D146101#4201842>, @jp4a50 wrote:

> 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>

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

> - 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).

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:

  clang-format -style=Google
  Point p = {
      .x = 1.0, .y = 2.0,
      // z will be 0.0
  };
  Point p = {
      .x = 1.0, .y = 2.0,
      // z will be 0.0
  };


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