| Issue |
52914
|
| Summary |
Alignment of consecutive assignment and declarations causes incorrect indentation for structs
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
JohnC32
|
Given
```c++
void foo() {
const char* formats[] = {"%",
"%%", // some comment
"%+-?4.5d"
"%#-4.3%f",
"%15.a6e"};
const int numFormats = sizeof(formats) / sizeof(char*);
}
```
clang-format 13 will produce:
```c++
void foo() {
const char* formats[] = {"%",
"%%", // some comment
"%+-?4.5d"
"%#-4.3%f",
"%15.a6e"};
const int numFormats = sizeof(formats) / sizeof(char*);
}
```
Note, this differs from clang-format 12.0.1 which is slightly better but still incorrect.
Here's the _clang-format used in the above:
```yaml
---
BasedOnStyle: Google
ColumnLimit: 100
IndentWidth: 4
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveDeclarations: Consecutive
...
```
If you comment out the AlignConsecutive* lines in _clang-format, we get correct indentation, thus the alignment items are causing problems.
```c++
---
BasedOnStyle: Google
ColumnLimit: 100
IndentWidth: 4
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveDeclarations: Consecutive
...
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs