Author: Owen Pan Date: 2025-07-20T19:01:46-07:00 New Revision: 06ed4d2c92ef7785f6c39e567b8bdefd2defdedb
URL: https://github.com/llvm/llvm-project/commit/06ed4d2c92ef7785f6c39e567b8bdefd2defdedb DIFF: https://github.com/llvm/llvm-project/commit/06ed4d2c92ef7785f6c39e567b8bdefd2defdedb.diff LOG: [clang-format] Fix a bug in `BreakBeforeBinaryOperators: All` (#149695) Fixes #149520 Added: Modified: clang/lib/Format/ContinuationIndenter.cpp clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 4010f7fbd25be..bf67f9e5fd241 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 0bc1c6d45656e..11d94e47e5b06 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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits