llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: None (XDeme) <details> <summary>Changes</summary> Fixes llvm/llvm-project#<!-- -->74901 --- Full diff: https://github.com/llvm/llvm-project/pull/74943.diff 2 Files Affected: - (modified) clang/lib/Format/ContinuationIndenter.cpp (+2-1) - (modified) clang/unittests/Format/FormatTest.cpp (+14) ``````````diff diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 9e4e939503dfe4..de3768d475e7b2 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -593,7 +593,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { // name. !Style.isJavaScript()) || (Current.is(tok::kw_operator) && Previous.isNot(tok::coloncolon))) && - Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) { + Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter && + (Style.isCpp() && Current.Tok.isNot(tok::kw_operator))) { return true; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 24b2fd599dc397..a1f3beed475ff3 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -26417,6 +26417,20 @@ TEST_F(FormatTest, BreakAfterAttributes) { "void g() {}", CtorDtorCode, Style); + Style.ReferenceAlignment = FormatStyle::ReferenceAlignmentStyle::RAS_Left; + constexpr StringRef OperatorOverloadCode( + "struct Foo {\n" + "[[maybe_unused]] void operator+();\n" + "};\n" + "[[nodiscard]] Foo& operator-(Foo&);"); + verifyFormat("struct Foo {\n" + " [[maybe_unused]]\n" + " void operator+();\n" + "};\n" + "[[nodiscard]]\n" + "Foo& operator-(Foo&);", + OperatorOverloadCode, Style); + Style.BreakBeforeBraces = FormatStyle::BS_Linux; verifyFormat("struct Foo {\n" " [[deprecated]]\n" `````````` </details> https://github.com/llvm/llvm-project/pull/74943 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits