================
@@ -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 && condition2) {\n"
+ "}",
+ Style);
+
+ verifyFormat("if (condition1 && condition2 &&\n"
+ " (condition3 || condition4) && condition5 &&\n"
+ " condition6) {\n"
+ "}",
+ Style);
+
+ verifyFormat("if (loooooooooooooooooooooongcondition1 &&\n"
+ " loooooooooooooooooooooongcondition2) {\n"
+ "}",
+ Style);
+
+ // Arithmetic
+ verifyFormat("const int result = lhs + rhs;", Style);
+
+ verifyFormat("const int result = loooooooongop1 + looooooooongop2 +\n"
+ " loooooooooooooooooooooongop3;",
+ Style);
+
+ verifyFormat("result = longOperand1 + longOperand2 -\n"
+ " (longOperand3 + longOperand4) -\n"
+ " longOperand5 * longOperand6;",
+ Style);
+
+ verifyFormat("const int result =\n"
+ " operand1 + operand2 - (operand3 + operand4);\n",
----------------
owenca wrote:
```suggestion
" operand1 + operand2 - (operand3 + operand4);",
```
https://github.com/llvm/llvm-project/pull/95013
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits