| Issue |
180121
|
| Summary |
[clang-format] AlignAfterOpenBracket is ignored when ColumnLimit exceeds some threshold
|
| Labels |
clang-format
|
| Assignees |
|
| Reporter |
xziyu6
|
Issue:
`AlignAfterOpenBracket: BlockIndent` doesn't work when ColumnLimit is too large, the threshold in my case is 85.
But it works if I add `BinPackArguments: false` and `BinPackParameters: false`.
I've tried running with:
- A Linux remote through ms-vscode.cpptools (which I think uses 21.1.4)
- A Windows laptop through
- ms-vscode.cpptools
- separately installed LLVM, both 18.1.8 and 21.1.0, both VS Code's extension and terminal
Here is my .clang-format:
```yaml
BasedOnStyle: Google
ColumnLimit: 80
AlignAfterOpenBracket: BlockIndent
# BinPackArguments: false
# BinPackParameters: false
IncludeBlocks: Regroup
PointerAlignment: Left
AllowShortLambdasOnASingleLine: Inline
NamespaceIndentation: Inner
```
This is the original:
```cpp
const map<string, int> Card::SUIT_MAP_F = {
{"c", 0}, {"d", 1}, {"s", 2}, {"h", 3}
};
const map<int, string> Card::SUIT_MAP_B = {
{0, "c"}, {1, "d"}, {2, "s"}, {3, "h"}
};
const map<string, int> Card::RANK_MAP_F = {
{"a", 1},
{"2", 2},
{"3", 3},
{"4", 4},
{"5", 5},
{"6", 6},
{"7", 7},
{"8", 8},
{"9", 9},
{"10", 10},
{"j", 11},
{"q", 12},
{"k", 13}
};
const map<int, string> Card::RANK_MAP_B = {
{1, "a"},
{2, "2"},
{3, "3"},
{4, "4"},
{5, "5"},
{6, "6"},
{7, "7"},
{8, "8"},
{9, "9"},
{10, "10"},
{11, "j"},
{12, "q"},
{13, "k"}
};
```
If I run clang-format, I get:
```cpp
const map<string, int> Card::SUIT_MAP_F = {
{"c", 0}, {"d", 1}, {"s", 2}, {"h", 3}
};
const map<int, string> Card::SUIT_MAP_B = {
{0, "c"}, {1, "d"}, {2, "s"}, {3, "h"}
};
const map<string, int> Card::RANK_MAP_F = {
{"a", 1}, {"2", 2}, {"3", 3}, {"4", 4}, {"5", 5}, {"6", 6}, {"7", 7},
{"8", 8}, {"9", 9}, {"10", 10}, {"j", 11}, {"q", 12}, {"k", 13}
};
const map<int, string> Card::RANK_MAP_B = {
{1, "a"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"},
{8, "8"}, {9, "9"}, {10, "10"}, {11, "j"}, {12, "q"}, {13, "k"}
};
```
With `ColumnLimit: 85` I get:
```cpp
const map<string, int> Card::SUIT_MAP_F = {{"c", 0}, {"d", 1}, {"s", 2}, {"h", 3}};
const map<int, string> Card::SUIT_MAP_B = {{0, "c"}, {1, "d"}, {2, "s"}, {3, "h"}};
const map<string, int> Card::RANK_MAP_F = {
{"a", 1}, {"2", 2}, {"3", 3}, {"4", 4}, {"5", 5}, {"6", 6}, {"7", 7},
{"8", 8}, {"9", 9}, {"10", 10}, {"j", 11}, {"q", 12}, {"k", 13}
};
const map<int, string> Card::RANK_MAP_B = {
{1, "a"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"},
{8, "8"}, {9, "9"}, {10, "10"}, {11, "j"}, {12, "q"}, {13, "k"}
};
```
But with `ColumnLimit: 86` it becomes:
```cpp
const map<string, int> Card::SUIT_MAP_F = {{"c", 0}, {"d", 1}, {"s", 2}, {"h", 3}};
const map<int, string> Card::SUIT_MAP_B = {{0, "c"}, {1, "d"}, {2, "s"}, {3, "h"}};
const map<string, int> Card::RANK_MAP_F = {{"a", 1}, {"2", 2}, {"3", 3}, {"4", 4},
{"5", 5}, {"6", 6}, {"7", 7}, {"8", 8},
{"9", 9}, {"10", 10}, {"j", 11}, {"q", 12},
{"k", 13}};
const map<int, string> Card::RANK_MAP_B = {{1, "a"}, {2, "2"}, {3, "3"}, {4, "4"},
{5, "5"}, {6, "6"}, {7, "7"}, {8, "8"},
{9, "9"}, {10, "10"}, {11, "j"}, {12, "q"},
{13, "k"}};
```
Additionally, with `ColumnLimit: 100`, `BinPackArguments: false`, and `BinPackParameters: false`:
```cpp
const map<string, int> Card::SUIT_MAP_F = {{"c", 0}, {"d", 1}, {"s", 2}, {"h", 3}};
const map<int, string> Card::SUIT_MAP_B = {{0, "c"}, {1, "d"}, {2, "s"}, {3, "h"}};
const map<string, int> Card::RANK_MAP_F = {
{"a", 1},
{"2", 2},
{"3", 3},
{"4", 4},
{"5", 5},
{"6", 6},
{"7", 7},
{"8", 8},
{"9", 9},
{"10", 10},
{"j", 11},
{"q", 12},
{"k", 13}
};
const map<int, string> Card::RANK_MAP_B = {
{1, "a"},
{2, "2"},
{3, "3"},
{4, "4"},
{5, "5"},
{6, "6"},
{7, "7"},
{8, "8"},
{9, "9"},
{10, "10"},
{11, "j"},
{12, "q"},
{13, "k"}
};
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs