================
@@ -996,7 +996,13 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
            Next->is(TT_FunctionDeclarationLParen) || 
IsFunctionCallParen(*Next);
   };
   if (IsOpeningBracket(Previous) &&
-      State.Column > getNewLineColumn(State).Total &&
+      (State.Column > getNewLineColumn(State).Total ||
+       // IsOpeningBracket checks BreakAfterOpenBracketBracedList before its
+       // (!Tok.Previous) shortcut. All other true returns with a preceding
+       // token require a BreakAfterOpenBracket* option.
+       // Only forbid later breaks if a break here is possible to prevent
+       // alternatives from being blocked.
+       ((Previous.Previous || Previous.is(tok::l_brace)) && canBreak(State))) 
&&
----------------
ChrisLee02 wrote:

`Previous.Previous` is used to distinguish cases where 
`IsOpeningBracket(Previous)` returns `true` for an opening bracket with an 
actual preceding token.

`IsOpeningBracket()` can return `true` either because:
- the preceding context and a `BreakAfterOpenBracket*` option make the bracket 
relevant, or
- `Tok.Previous == nullptr`.

Only the former case is relevant here, so `Previous.Previous` serves to select 
that path. `{` is handled separately because `BreakAfterOpenBracketBracedList` 
is checked in a different order.

Would a local `ShouldBreakAfterOpeningBracket` lambda make this intent clearer?

https://github.com/llvm/llvm-project/pull/228085
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to