[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-17 Thread Ameer J via cfe-commits
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 __

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-17 Thread Ameer J via 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/16] Add BinPackBinaryOperations --- clang/include/clang/Format/Format

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-17 Thread Ameer J via cfe-commits
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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-17 Thread Ameer J via cfe-commits
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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-17 Thread Ameer J via 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/15] Add BinPackBinaryOperations --- clang/include/clang/Format/Format

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-17 Thread Owen Pan via cfe-commits
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 _

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-17 Thread via cfe-commits
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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-16 Thread Björn Schäpers via 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; >

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-15 Thread Owen Pan via cfe-commits
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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-15 Thread Owen Pan via cfe-commits
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[

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-15 Thread Ameer J via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-15 Thread Ameer J via 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/14] Add BinPackBinaryOperations --- clang/include/clang/Format/Format

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-14 Thread Owen Pan via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-14 Thread Owen Pan via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -3153,6 +3153,15 @@ class ExpressionParser { parse(Precedence + 1); int CurrentPrecedence = getCurrentPrecedence(); + if (!Style.BinPackBinaryOperations && + (CurrentPrecedence > prec::Conditional) && + (CurrentPrecedence < prec::PointerTo

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via 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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Ameer J via 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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Ameer J via 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/11] Add BinPackBinaryOperations --- clang/include/clang/Format/Format

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via 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. +static bool startsNextOperand(const Forma

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via 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. +static bool startsNextOperand(const Forma

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via cfe-commits
@@ -3153,6 +3153,15 @@ class ExpressionParser { parse(Precedence + 1); int CurrentPrecedence = getCurrentPrecedence(); + if (!Style.BinPackBinaryOperations && + (CurrentPrecedence > prec::Conditional) && + (CurrentPrecedence < prec::PointerTo

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-10 Thread Owen Pan via 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. owenca wrote: Did you me

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-09 Thread Ameer J via cfe-commits
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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-03 Thread Björn Schäpers via cfe-commits
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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-02 Thread Ameer J via 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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-01 Thread Ameer J via 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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-01 Thread Björn Schäpers via cfe-commits
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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-01 Thread Ameer J via 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 1/9] Add BinPackBinaryOperations --- clang/include/clang/Format/Format.h

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-01 Thread via cfe-commits
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 --

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-01 Thread Ameer J via 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 1/8] Add BinPackBinaryOperations --- clang/include/clang/Format/Format.h

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-01 Thread Ameer J via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-07-01 Thread Ameer J via 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 1/7] Add BinPackBinaryOperations --- clang/include/clang/Format/Format.h

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-18 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-18 Thread Ameer J via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-12 Thread Ameer J via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-11 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-11 Thread Ameer J via 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 1/6] Add BinPackBinaryOperations --- clang/include/clang/Format/Format.h

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-11 Thread Ameer J via cfe-commits
@@ -1203,6 +1214,10 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, } } + if (!Style.BinPackBinaryOperations && Previous.is(TT_BinaryOperator) && + (Previous.getPrecedence() > prec::Conditional)) { +CurrentState.BreakBeforeParameter = tru

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-11 Thread Ameer J via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread via cfe-commits
@@ -27492,6 +27492,86 @@ TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) { verifyFormat("return sizeof \"5\";"); } +TEST_F(FormatTest, BinPackBinaryOperations) { + auto Style = getLLVMStyle(); + Style.BinPackBinaryOperations = false; mydeveloperday wrote

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread via cfe-commits
@@ -1203,6 +1214,10 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, } } + if (!Style.BinPackBinaryOperations && Previous.is(TT_BinaryOperator) && + (Previous.getPrecedence() > prec::Conditional)) { +CurrentState.BreakBeforeParameter = tru

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread Björn Schäpers via 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. +static bool startsNextOperand(const Forma

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread Björn Schäpers via cfe-commits
@@ -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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread via cfe-commits
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

[clang] [clang-format] Add BinPackBinaryOperations configuration (PR #95013)

2024-06-10 Thread Ameer J via cfe-commits
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