[clang] [clang-format] Add BreakAfterOpenBracket* and BreakBeforeCloseBracket* (PR #108332)
Gedare Bloom via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 25 07:56:30 PDT 2025
================
@@ -6207,24 +6207,36 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
(Right.isBlockIndentedInitRBrace(Style)));
}
- // We only break before r_paren if we're in a block indented context.
+ // We can break before r_paren if we're in a block indented context or
+ // a control statement with an explicit style option.
if (Right.is(tok::r_paren)) {
- if (Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent ||
- !Right.MatchingParen) {
+ if (!Right.MatchingParen)
return false;
- }
auto Next = Right.Next;
if (Next && Next->is(tok::r_paren))
Next = Next->Next;
if (Next && Next->is(tok::l_paren))
return false;
const FormatToken *Previous = Right.MatchingParen->Previous;
- return !(Previous && (Previous->is(tok::kw_for) || Previous->isIf()));
+ if (!Previous)
+ return false;
+ if (Previous->isIf())
+ return Style.BreakBeforeCloseBracketIf;
+ auto IsLoopConditional = [&](const FormatToken &Tok) {
----------------
gedare wrote:
oh, yes I meant to refactor this one.
https://github.com/llvm/llvm-project/pull/108332
More information about the cfe-commits
mailing list