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

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 31 12:58:36 PDT 2023


HazardyKnusperkeks added inline comments.


================
Comment at: clang/include/clang/Format/Format.h:949
+  /// If unset, ``ContinuationIndentWidth`` is used.
+  /// \code
+  ///   AlignAfterOpenBracket: AlwaysBreak
----------------
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




================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:1659
       opensProtoMessageField(Current, Style)) {
+    const FormatToken *NextNonComment = Current.getNextNonComment();
     if (Current.opensBlockOrBlockTypeList(Style)) {
----------------
Why did you move it?


================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:1664-1668
+      const auto BracedInitializerIndentWidth =
+          Style.BracedInitializerIndentWidth
+              ? *Style.BracedInitializerIndentWidth
+              : Style.ContinuationIndentWidth;
+      NewIndent = CurrentState.LastSpace + BracedInitializerIndentWidth;
----------------
You can keep the local variable if you want, but please use `value_or`, it expresses the intent better.


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