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

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 24 02:17:35 PDT 2023


owenpan added inline comments.


================
Comment at: clang/include/clang/Format/Format.h:2037
+  /// \endcode
+  int DesignatedInitializerIndentWidth;
+
----------------
owenpan wrote:
> 
Please disregard my comment above.


================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:1665-1669
+      const auto DesignatedInitializerIndentWidth =
+          Style.DesignatedInitializerIndentWidth < 0
+              ? Style.ContinuationIndentWidth
+              : Style.DesignatedInitializerIndentWidth;
+      NewIndent = CurrentState.LastSpace + DesignatedInitializerIndentWidth;
----------------
owenpan wrote:
> Using -1 to mean `ContinuationIndentWidth` is unnecessary and somewhat confusing IMO.
Please disregard my comment above.


================
Comment at: clang/lib/Format/Format.cpp:1372
   LLVMStyle.DerivePointerAlignment = false;
+  LLVMStyle.DesignatedInitializerIndentWidth = -1;
   LLVMStyle.DisableFormat = false;
----------------
owenpan wrote:
> 
Please disregard my comment above.


================
Comment at: clang/unittests/Format/ConfigParseTest.cpp:250-251
+              DesignatedInitializerIndentWidth, 34);
+  CHECK_PARSE("DesignatedInitializerIndentWidth: -1",
+              DesignatedInitializerIndentWidth, -1);
   CHECK_PARSE("CommentPragmas: '// abc$'", CommentPragmas, "// abc$");
----------------
owenpan wrote:
> Delete.
Please disregard my comment above.


================
Comment at: clang/unittests/Format/FormatTest.cpp:4845
+  Style.ContinuationIndentWidth = 8;
+  Style.DesignatedInitializerIndentWidth = -1; // Use ContinuationIndentWidth.
+  verifyFormat("auto s = SomeStruct{\n"
----------------
owenpan wrote:
> Delete it and rearrange the tests so that the unspecified (default) `DesignatedInitializerIndentWidth` is tested first.
Please disregard my comment above.


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