[clang] [clang-format] Change BinPackParameters to enum and add AlwaysOnePerLine (PR #101882)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 21 23:42:29 PDT 2024


================
@@ -403,13 +416,25 @@ TEST_F(FormatTestComments, UnderstandsBlockComments) {
   verifyFormat("f(/* aaaaaaaaaaaaaaaaaa = */\n"
                "  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
 
-  FormatStyle NoBinPacking = getLLVMStyle();
-  NoBinPacking.BinPackParameters = false;
-  verifyFormat("aaaaaaaa(/* parameter 1 */ aaaaaa,\n"
-               "         /* parameter 2 */ aaaaaa,\n"
-               "         /* parameter 3 */ aaaaaa,\n"
-               "         /* parameter 4 */ aaaaaa);",
-               NoBinPacking);
+  FormatStyle BinPack = getLLVMStyle();
+  verifyFormat(
+      "int aaaaaaaaaaaaa(/* 1st */ int bbbbbbbbbb, /* 2nd */ int ccccccccccc,\n"
+      "                  /* 3rd */ int dddddddddddd);",
+      BinPack);
+
+  FormatStyle OnePerLine = getLLVMStyle();
+  OnePerLine.BinPackParameters = FormatStyle::BPPS_OnePerLine;
+  verifyFormat("int a(/* 1st */ int b, /* 2nd */ int c);", OnePerLine);
+  verifyFormat("int aaaaaaaaaaaaa(/* 1st */ int bbbbbbbbbb,\n"
+               "                  /* 2nd */ int ccccccccccc,\n"
+               "                  /* 3rd */ int dddddddddddd);",
+               OnePerLine);
+
+  FormatStyle AlwaysOnePerLine = getLLVMStyle();
+  AlwaysOnePerLine.BinPackParameters = FormatStyle::BPPS_AlwaysOnePerLine;
+  verifyFormat("int a(/* 1st */ int b,\n"
+               "      /* 2nd */ int c);",
+               AlwaysOnePerLine);
----------------
owenca wrote:

Actually, that wouldn't work. Instead, see https://github.com/llvm/llvm-project/pull/101882#discussion_r1726433515.

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


More information about the cfe-commits mailing list