[PATCH] D153205: [clang-format] Add new block type ListInit

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 18 12:00:27 PDT 2023


HazardyKnusperkeks added a comment.

In D153205#4430528 <https://reviews.llvm.org/D153205#4430528>, @owenpan wrote:

> It seems to me that there has been a proliferation of new options being proposed and/or accepted recently. I'd like to remind everyone of the long-standing policy <https://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options> of adding new options. That being said, I wonder if we should add a new language `LK_C` along with its variants C78 (i.e. K&R C), C89 (i.e. ANSI C), GNU extensions (e.g. #55745 <https://github.com/llvm/llvm-project/issues/55745> and #62755 <https://github.com/llvm/llvm-project/issues/62755>), etc.

That was already discussed: D117416#3250415 <https://reviews.llvm.org/D117416#3250415>

You add a lot of checks and I honestly can't say if it does not affect other code that is not covered by the tests.



================
Comment at: clang/lib/Format/FormatToken.cpp:79
 bool FormatToken::opensBlockOrBlockTypeList(const FormatStyle &Style) const {
+  auto bk = getBlockKind();
   // C# Does not indent object initialisers as continuations.
----------------



================
Comment at: clang/lib/Format/FormatToken.cpp:86-88
+  if (is(tok::l_brace) && (bk == BK_BracedInit || bk == BK_ListInit) &&
+      Style.Cpp11BracedListStyle && Style.Language == FormatStyle::LK_Cpp)
+    return false;
----------------
Which clang-format should've added.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153205/new/

https://reviews.llvm.org/D153205



More information about the cfe-commits mailing list