[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:13:48 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:

> In the old test that was deleted it's setting the `Style.BinPackParameters = false;` but testing with a function call. Should it be using `Style.BinPackArguments = false;` instead?

Sorry that I forgot to change it in my suggestion above.

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


More information about the cfe-commits mailing list