Skip to content

Commit 06ed4d2

Browse files
authored
[clang-format] Fix a bug in BreakBeforeBinaryOperators: All (#149695)
Fixes #149520
1 parent 22ef58c commit 06ed4d2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
560560
return true;
561561
}
562562
} else if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore &&
563+
Current.getPrecedence() != prec::Assignment &&
563564
CurrentState.BreakBeforeParameter) {
564565
return true;
565566
}

clang/unittests/Format/FormatTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28375,6 +28375,11 @@ TEST_F(FormatTest, BreakAfterAttributes) {
2837528375
verifyFormat("[[nodiscard]]\n"
2837628376
"Foo& operator-(Foo&);",
2837728377
Style);
28378+
28379+
Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
28380+
verifyFormat("[[deprecated]]\n"
28381+
"void f() = delete;",
28382+
Style);
2837828383
}
2837928384

2838028385
TEST_F(FormatTest, InsertNewlineAtEOF) {

0 commit comments

Comments
 (0)