[clang-format] Fix mismatched break in BlockIndent (#124998) · llvm/llvm-project@e7ae553 (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -349,6 +349,13 @@ bool ContinuationIndenter::canBreak(const LineState &State) { | ||
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
352 | +// Allow breaking before the right parens with block indentation if there was | |
353 | +// a break after the left parens, which is tracked by BreakBeforeClosingParen. | |
354 | +if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent && | |
355 | + Current.is(tok::r_paren)) { | |
356 | +return CurrentState.BreakBeforeClosingParen; | |
357 | + } | |
358 | + | |
352 | 359 | // Don't allow breaking before a closing brace of a block-indented braced list |
353 | 360 | // initializer if there isn't already a break. |
354 | 361 | if (Current.is(tok::r_brace) && Current.MatchingParen && |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -9614,6 +9614,10 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) { | ||
9614 | 9614 | " auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" |
9615 | 9615 | " ) {};", |
9616 | 9616 | Style); |
9617 | + verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaa(\n" | |
9618 | + " &bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n" | |
9619 | + ");", | |
9620 | + Style); | |
9617 | 9621 | } |
9618 | 9622 | |
9619 | 9623 | TEST_F(FormatTest, ParenthesesAndOperandAlignment) { |