Issue 52915
Summary ColumnLimit not honored when AlignConsecutiveDeclarations is used in clang-format 13
Labels new issue
Assignees
Reporter JohnC32
    Given the following and the _clang-format below,

```c++
class one1234567891012345789;
extern void bar();
extern int  Op(int, int);
extern int  Conversion(int, int);
const int   foo12345678901234568901 = 1;
    
void foo() {
    bar();
    // comment
    {
        one1234567891012345789 const one();
        int const                    otherthing = Op(foo12345678901234568901,
                                                     Conversion(foo12345678901234568901,
                                                                foo12345678901234568901));

    }
}
```
Running clang-format 13 on this combines the arguments to the Conversion() call and puts them past column 100 which means it's not honoring the ColumnLimit.

```c++
class one1234567891012345789;
extern void bar();
extern int  Op(int, int);
extern int  Conversion(int, int);
const int   foo12345678901234568901 = 1;

void foo() {
    bar();
    // comment
    {
        one1234567891012345789 const one();
        int const                    otherthing = Op(foo12345678901234568901,
                                                     Conversion(foo12345678901234568901, foo12345678901234568901));
    }
}
```
Note, clang-format 12.0.1 differs in that it honors the ColumnLimit setting, but the indentation-level is not correct in clang-format 12.0.1, with clang-format 12.0.1 we get:

```c++
class one1234567891012345789;
extern void bar();
extern int  Op(int, int);
extern int  Conversion(int, int);
const int   foo12345678901234568901 = 1;

void foo() {
    bar();
    // comment
    {
        one1234567891012345789 const one();
        int const                    otherthing = Op(foo12345678901234568901,
                                  Conversion(foo12345678901234568901, foo12345678901234568901));
    }
}
```
My expectation is that clang-format would honor the ColumnLimit and produce the following where the indent level is 4 spaces relative to the prior line for the Converstion() call line:

```c++
class one1234567891012345789;
extern void bar();
extern int  Op(int, int);
extern int  Conversion(int, int);
const int   foo12345678901234568901 = 1;

void foo() {
    bar();
    // comment
    {
        one1234567891012345789 const one();
        int const                    otherthing = Op(foo12345678901234568901,
            Conversion(foo12345678901234568901, foo12345678901234568901));
    }
}
```


Here's the _clang-format used in the above:

```yaml
---
BasedOnStyle: Google
ColumnLimit: 100
IndentWidth: 4
AlignConsecutiveDeclarations: Consecutive
...
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to