[clang] [clang-format] Change BinPackParameters to an enum to add a BreakAlways (PR #101882)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 17 01:14:16 PDT 2024


================
@@ -8925,6 +8925,97 @@ TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) {
       NoBinPacking);
 }
 
+TEST_F(FormatTest, FormatsDeclarationBreakAlways) {
+  FormatStyle BreakAlways = getGoogleStyle();
+  BreakAlways.BinPackParameters = FormatStyle::BPPS_OnePerLine;
+  verifyFormat("void f(int a,\n"
+               "       int b);",
+               BreakAlways);
+  verifyFormat("void f(int aaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+               "       int bbbbbbbbbbbbbbbbbbbbbbbbb,\n"
+               "       int cccccccccccccccccccccccc);",
+               BreakAlways);
+
+  // Ensure AlignAFterOpenBracket interacts correctly with
+  // PackParameters set to BreakAlways.
----------------
owenca wrote:

```suggestion
  // Ensure AlignAfterOpenBracket interacts correctly with BinPackParameters set
  // to BPPS_Never.
```

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


More information about the cfe-commits mailing list