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

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 10 23:34:11 PDT 2024


================
@@ -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 && 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;\n", Style);
----------------
owenca wrote:

The trailing newlines are still present.

https://github.com/llvm/llvm-project/pull/95013


More information about the cfe-commits mailing list