[clang] [clang-format] add MaxSingleLinesInBracedList style option (PR #112482)

Gedare Bloom via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 26 10:38:58 PDT 2024


gedare wrote:

So it turns out that this buggy behavior I'm seeing is also present in unmodified clang-format when the first item in the list is longer than the rest of the items. For example:
```
echo "vector<int> x{1111111111111, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};" > c.txt
clang-format --style=llvm c.txt

vector<int> x{1111111111111,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10,
              11,
              12,
              13,
              14,
              15,
              16,
              17,
              18,
              19,
              20,
              21,
              22,
              23,
              24};
```

versus:
```
echo "vector<int> x{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};" > d.txt
vector<int> x{1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12,
              13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
```


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


More information about the cfe-commits mailing list