Issue 181132
Summary clang-format Adds more and more spaces with misaligned comments, ReflowComments Always and AlignTrailingComments Kind Leave
Labels clang-format
Assignees
Reporter ChristianFeldmann
    With the given example settings and a misaligned block comment, clang-format keeps adding spaces to the lines inside of the comment block with every call to clang format. I am using clang-format version 21.1.8 on macos 26.2. 

`.clang-format`
```
AlignTrailingComments:
  Kind: Leave
ReflowComments: Always
```

`TestSource.cpp`
```
void someFunction()
{
/* This long commment is not indented correctly.
   Clang format will keep adding spaces in front of this line
   and any consequent lines with each call to clang-format. */
}
```

I then call `clang-format -i TestSource.cpp` repeatedly.

Call 1:
```
void someFunction() {
/* This long commment is not indented correctly.
     Clang format will keep adding spaces in front of this line
     and any consequent lines with each call to clang-format. */
}
```

Call 2:
```
void someFunction() {
/* This long commment is not indented correctly.
       Clang format will keep adding spaces in front of this line
       and any consequent lines with each call to clang-format. */
}
```

Call 3:
```
void someFunction() {
/* This long commment is not indented correctly.
         Clang format will keep adding spaces in front of this line
         and any consequent lines with each call to clang-format. */
}
```

Call 4:
```

void someFunction() {
/* This long commment is not indented correctly.
 Clang format will keep adding spaces in front of this line
           and any consequent lines with each call to clang-format. */
}
```

I tried searching for already existing issues and found [this one](https://github.com/llvm/llvm-project/issues/75035) which may be related.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to