[PATCH] D108752: [clang-format] Group options that pack constructor initializers
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 27 03:11:02 PDT 2021
owenpan added inline comments.
================
Comment at: clang/lib/Format/Format.cpp:666-677
+ if (Style.PackConstructorInitializers == FormatStyle::PCIS_BinPack) {
+ bool OnCurrentLine = false;
+ IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine",
+ OnCurrentLine);
+ if (OnCurrentLine) {
+ bool OnNextLine = false;
+ IO.mapOptional("AllowAllConstructorInitializersOnNextLine", OnNextLine);
----------------
Also need to handle the default value `PCIS_NextLine` for Google and Chromium styles:
```
StringRef BasedOn;
IO.mapOptional("BasedOnStyle", BasedOn);
const bool IsGoogleOrChromium = BasedOn.equals_insensitive("google") ||
BasedOn.equals_insensitive("chromium");
bool OnCurrentLine = IsGoogleOrChromium;
bool OnNextLine = IsGoogleOrChromium;
IO.mapOptional("ConstructorInitializerAllOnOneLineOrOnePerLine",
OnCurrentLine);
IO.mapOptional("AllowAllConstructorInitializersOnNextLine", OnNextLine);
if (IsGoogleOrChromium &&
Style.PackConstructorInitializers == FormatStyle::PCIS_NextLine) {
if (!OnCurrentLine)
Style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
else if (!OnNextLine)
Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
} else if (Style.PackConstructorInitializers == FormatStyle::PCIS_BinPack &&
OnCurrentLine) {
Style.PackConstructorInitializers = OnNextLine
? FormatStyle::PCIS_NextLine
: FormatStyle::PCIS_CurrentLine;
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108752/new/
https://reviews.llvm.org/D108752
More information about the cfe-commits
mailing list