[clang] [clang-format] Fix BreakAfterOpenBracket options being ignored with larger continuation indents (PR #228085)

Hadong Lee via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 3 05:33:54 PDT 2026


================
@@ -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:

Updated: https://github.com/llvm/llvm-project/pull/228085/commits/f3e28468fbb4ee296f3ea31a16726a6908c76f2b

I extracted `ShouldBreakAfterOpeningBracket` and intentionally repeated token checks from IsOpeningBracket to make the supported cases explicit, rather than relying on the presence of a preceding token.

https://github.com/llvm/llvm-project/pull/228085


More information about the cfe-commits mailing list