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

Jon Phillips via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 4 12:14:04 PDT 2023


jp4a50 added inline comments.


================
Comment at: clang/include/clang/Format/Format.h:949
+  /// If unset, ``ContinuationIndentWidth`` is used.
+  /// \code
+  ///   AlignAfterOpenBracket: AlwaysBreak
----------------
owenpan wrote:
> HazardyKnusperkeks wrote:
> > jp4a50 wrote:
> > > MyDeveloperDay wrote:
> > > > did you check generating the html from the rst? I can never remember if we need a newline before the \code
> > > Nope - how do I do that exactly? I would guess a newline is not needed based on other examples.
> > > did you check generating the html from the rst? I can never remember if we need a newline before the \code
> > 
> > 
> > Nope - how do I do that exactly? I would guess a newline is not needed based on other examples.
> 
> See D147327#4236718.
HTML looks good.


================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:1659
       opensProtoMessageField(Current, Style)) {
+    const FormatToken *NextNonComment = Current.getNextNonComment();
     if (Current.opensBlockOrBlockTypeList(Style)) {
----------------
HazardyKnusperkeks wrote:
> Why did you move it?
I originally needed it in the new `else if` block since I was checking if it was a designated initializer period but the condition has since changed. Thanks for spotting. I've moved it back.


================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:1664-1668
+      const auto BracedInitializerIndentWidth =
+          Style.BracedInitializerIndentWidth
+              ? *Style.BracedInitializerIndentWidth
+              : Style.ContinuationIndentWidth;
+      NewIndent = CurrentState.LastSpace + BracedInitializerIndentWidth;
----------------
HazardyKnusperkeks wrote:
> You can keep the local variable if you want, but please use `value_or`, it expresses the intent better.
Have used `.value_or()` and got rid of temp variable since it's more concise now.


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