[PATCH] D109557: Adds a BlockIndent option to AlignAfterOpenBracket

Cameron Mulhern via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 13 08:06:25 PST 2021


csmulhern marked 4 inline comments as done.
csmulhern added inline comments.


================
Comment at: clang/lib/Format/ContinuationIndenter.cpp:951
 
+  if (PreviousNonComment && PreviousNonComment->is(tok::l_paren)) {
+    State.Stack.back().BreakBeforeClosingParen =
----------------
owenpan wrote:
> HazardyKnusperkeks wrote:
> > Remove the braces
> I think the braces should not be removed here. The [[ https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements | LLVM Coding Standards ]] says "braces should be used when a single-statement body is complex enough" which is rather subjective, but line wrapping is an objective metric and perhaps the only one we can apply.
> 
> 
> 
I'm not sure either way, but the prevailing style in this file seems like it would support having no braces, so I went ahead and made the change.


================
Comment at: clang/unittests/Format/FormatTest.cpp:22453
+  Style.AllowAllArgumentsOnNextLine = false;
+  Style.AllowAllConstructorInitializersOnNextLine = false;
+  Style.AllowAllParametersOfDeclarationOnNextLine = false;
----------------
HazardyKnusperkeks wrote:
> How does it behave without these?
It should put the closing parenthesis on a newline as long as it was opened with a newline. I've added additional test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109557



More information about the cfe-commits mailing list