[PATCH] D105099: [clang-format] Add an option to put one constructor initializer per line

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 29 15:05:58 PDT 2021


owenpan added a comment.

In D105099#2848317 <https://reviews.llvm.org/D105099#2848317>, @curdeius wrote:

> Formatting part and tests look good to me, but I'd rather see this patch merge all related boolean options into one enum.
> Just thinking out loud, but is it doable to merge AllowAllConstructorInitializersOnNextLine, ConstructorInitializerAllOnOneLineOrOnePerLine and this patch's ConstructorInitializerAlwaysOnePerLine into e.g. ConstructorInitializerStyle: AllowNextLine | NonBinPack==AllOnOneLineOrOnePerLine | OnePerLine. And one other enum value for the default case without special handling.
> Of course, we'd need to keep that backward compatible.

If we were to start this all over without the need of backward compatibility and the existence of the related unit tests, an enum might be a better option. Then I still think the user might have some trouble relating the following to the enum.

  If AlwaysOnePerLine:
    Put each on its own line.
  Else If AllOnOneLineOrOnePerline:
    If they all fit on one line:
      Put all of them on a single line.
    Else If AllOnNextLine:
      Put (the rest of) them on the next line.
    Else:
      Put each on its own line.
  Else:
    ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105099



More information about the cfe-commits mailing list