aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2025-07-20 19:01:46 -0700
committerGitHub <noreply@github.com>2025-07-20 19:01:46 -0700
commit06ed4d2c92ef7785f6c39e567b8bdefd2defdedb (patch)
tree5749cf9ff9e3140bf3f3f143826beaa6799360ae /clang
parent22ef58ceda9490184f084fe1f938d333ba5d6cfd (diff)
downloadllvm-06ed4d2c92ef7785f6c39e567b8bdefd2defdedb.zip
llvm-06ed4d2c92ef7785f6c39e567b8bdefd2defdedb.tar.gz
llvm-06ed4d2c92ef7785f6c39e567b8bdefd2defdedb.tar.bz2
[clang-format] Fix a bug in `BreakBeforeBinaryOperators: All` (#149695)
Fixes #149520
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp1
-rw-r--r--clang/unittests/Format/FormatTest.cpp5
2 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 4010f7f..bf67f9e 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -560,6 +560,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
return true;
}
} else if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore &&
+ Current.getPrecedence() != prec::Assignment &&
CurrentState.BreakBeforeParameter) {
return true;
}
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 0bc1c6d..11d94e4 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -28375,6 +28375,11 @@ TEST_F(FormatTest, BreakAfterAttributes) {
verifyFormat("[[nodiscard]]\n"
"Foo& operator-(Foo&);",
Style);
+
+ Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+ verifyFormat("[[deprecated]]\n"
+ "void f() = delete;",
+ Style);
}
TEST_F(FormatTest, InsertNewlineAtEOF) {