-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-format] Fix operator overload inconsistency in BreakAfterAttributes: Always
#74943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-format] Fix operator overload inconsistency in BreakAfterAttributes: Always
#74943
Conversation
@llvm/pr-subscribers-clang-format Author: None (XDeme) ChangesFixes llvm/llvm-project#74901 Full diff: https://github.com/llvm/llvm-project/pull/74943.diff 2 Files Affected:
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"
|
I got a mail, but it seems you have deleted the comment? Is it a regression? Could you bisect it? And you don't need (for me) to comment, when you addressed a comment, just click on resolved. Would reduce the amount of mails in my inbox. ;) |
Is it not a regression, I didn't verify the path of clang-format correctly, I thought I was using clang 16.0.6, but it was using the one I recently built |
Fixes #74901