ameerj wrote:
> I'm not finding the true/false every clear, can we use an enum?
Reworked this to now be an enum. Please let me know if the intent is more clear
now or if anything needs further clarification.
https://github.com/llvm/llvm-project/pull/95013
__
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 01/16] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format
ameerj wrote:
> It seems
> [AlignOperands](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#alignoperands)
> is supposed to do what this new option would, so maybe we should fix/extend
> `AlignOperands` instead?
This new setting is only responsible for breaking long expressions, not
ameerj wrote:
> The logical && and bitwise | operations are not broken up into one per line,
> and the column limit is exceeded.
@owenca this should be fixed in the latest commit
https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 01/15] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format
owenca wrote:
It seems
[AlignOperands](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#alignoperands)
is supposed to do what this new option would, so maybe we should fix/extend
`AlignOperands` instead?
https://github.com/llvm/llvm-project/pull/95013
_
mydeveloperday wrote:
I'm not finding the true/false every clear, can we use an enum?
https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
HazardyKnusperkeks wrote:
> It seems that this patch implements the new option without regard to the
> relative precedence of the binary operators:
>
> ```
> $ cat bar.cc
> f1 = f2 * f3 +
> f4 / f5 - f6;
>
owenca wrote:
It seems that this patch implements the new option without regard to the
relative precedence of the binary operators:
```
$ cat bar.cc
f1 = f2 * f3 +
f4 / f5 - f6;
$ clang-format -style='{BinPa
owenca wrote:
This patch doesn't seem to work with the last two examples in #79487:
```
$ cat foo.cc
template
concept my_concept =
std::is_object_v
&& std::is_const_v
&& std::default_initializable;
std::uint32_t a =
byte_buffer[0]
| byte_buffer[1] << 8
| byte_buffer[
@@ -27628,6 +27628,119 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyleWithColumns(60);
+ // Logical operations
+ verifyFormat("if (condition1 && condi
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 01/14] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format
@@ -27628,6 +27628,119 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyleWithColumns(60);
+ // Logical operations
+ verifyFormat("if (condition1 && condi
@@ -27628,6 +27628,119 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyleWithColumns(60);
+ // Logical operations
+ verifyFormat("if (condition1 && condi
@@ -27628,6 +27628,109 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyleWithColumns(60);
+ // Logical operations
+ verifyFormat("if (condition1 && condi
@@ -3153,6 +3153,15 @@ class ExpressionParser {
parse(Precedence + 1);
int CurrentPrecedence = getCurrentPrecedence();
+ if (!Style.BinPackBinaryOperations &&
+ (CurrentPrecedence > prec::Conditional) &&
+ (CurrentPrecedence < prec::PointerTo
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/owenca commented:
Also, we need ConfigParseTest for the new option.
https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current,
Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma));
}
+// Returns \c true if \c Current starts a new operand in a binary operation.
ameerj wrote:
The wordin
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 01/11] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format
@@ -27628,6 +27628,109 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyleWithColumns(60);
+ // Logical operations
+ verifyFormat("if (condition1 && condi
@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current,
Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma));
}
+// Returns \c true if \c Current starts a new operand in a binary operation.
+static bool startsNextOperand(const Forma
@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current,
Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma));
}
+// Returns \c true if \c Current starts a new operand in a binary operation.
+static bool startsNextOperand(const Forma
@@ -3153,6 +3153,15 @@ class ExpressionParser {
parse(Precedence + 1);
int CurrentPrecedence = getCurrentPrecedence();
+ if (!Style.BinPackBinaryOperations &&
+ (CurrentPrecedence > prec::Conditional) &&
+ (CurrentPrecedence < prec::PointerTo
@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current,
Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma));
}
+// Returns \c true if \c Current starts a new operand in a binary operation.
owenca wrote:
Did you me
ameerj wrote:
Thanks for the review and approval @HazardyKnusperkeks !
I don't have write permissions to the repo so please merge this for me when you
have a moment.
https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-com
https://github.com/HazardyKnusperkeks approved this pull request.
https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 01/10] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 01/10] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format
https://github.com/HazardyKnusperkeks commented:
Could you please add a note to `clang/docs/ReleaseNotes.rst`.
https://github.com/llvm/llvm-project/pull/95013
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailma
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 1/9] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format.h
github-actions[bot] wrote:
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
You can test this locally with the following command:
``bash
git-clang-format --diff a30ef38cd455d500680fea8afdc824b4983fa981
28ef1c7f87d3cd37dc5f5c409aab5e9ca76f6578 --
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 1/8] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format.h
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 1/7] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format.h
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
https://github.com/ameerj updated
https://github.com/llvm/llvm-project/pull/95013
>From a50f3d4395efd09eea8ba2e750bb785857f9a550 Mon Sep 17 00:00:00 2001
From: ameerj
Date: Mon, 10 Jun 2024 12:09:40 -0400
Subject: [PATCH 1/6] Add BinPackBinaryOperations
---
clang/include/clang/Format/Format.h
@@ -1203,6 +1214,10 @@ unsigned
ContinuationIndenter::addTokenOnNewLine(LineState &State,
}
}
+ if (!Style.BinPackBinaryOperations && Previous.is(TT_BinaryOperator) &&
+ (Previous.getPrecedence() > prec::Conditional)) {
+CurrentState.BreakBeforeParameter = tru
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
mydeveloperday wrote
@@ -1203,6 +1214,10 @@ unsigned
ContinuationIndenter::addTokenOnNewLine(LineState &State,
}
}
+ if (!Style.BinPackBinaryOperations && Previous.is(TT_BinaryOperator) &&
+ (Previous.getPrecedence() > prec::Conditional)) {
+CurrentState.BreakBeforeParameter = tru
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
verifyFormat("return sizeof \"5\";");
}
+TEST_F(FormatTest, BinPackBinaryOperations) {
+ auto Style = getLLVMStyle();
+ Style.BinPackBinaryOperations = false;
+
+ // Logical operations
+ verifyF
@@ -146,6 +146,14 @@ static bool startsNextParameter(const FormatToken &Current,
Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma));
}
+// Returns \c true if \c Current starts a new operand in a binary operation.
+static bool startsNextOperand(const Forma
@@ -1203,6 +1214,10 @@ unsigned
ContinuationIndenter::addTokenOnNewLine(LineState &State,
}
}
+ if (!Style.BinPackBinaryOperations && Previous.is(TT_BinaryOperator) &&
HazardyKnusperkeks wrote:
Couldn't you just call `startsNextOperand`?
https://gith
llvmbot wrote:
@llvm/pr-subscribers-clang-format
Author: Ameer J (ameerj)
Changes
By default, clang-format packs binary operations, but it may be desirable to
have compound operations be on individual lines instead of being packed.
This PR adds the option `BinPackBinaryOperations`, which
https://github.com/ameerj created
https://github.com/llvm/llvm-project/pull/95013
By default, clang-format packs binary operations, but it may be desirable to
have compound operations be on individual lines instead of being packed.
This PR adds the option `BinPackBinaryOperations`, which mimic
52 matches
Mail list logo