llvm-project
llvm-project copied to clipboard
With `ColumnLimit 0`, `PackConstructorInitializers: CurrentLine` does not work as expected
Steps to reproduce
In my .clang-format file, I have
ColumnLimit: 120
PackConstructorInitializers: CurrentLine
With this, the following code:
Watcher::Watcher(const fs::path& path, const WatchdogCallback& callback) : mPath(path), mCallback(callback)
stays unaltered.
However after changing ColumnLimit to 0 in .clang-format without any other changes results in:
Watcher::Watcher(const fs::path& path, const WatchdogCallback& callback) :
mPath(path),
mCallback(callback)
Expected behavior The documentation for ColumnLimit says:
A column limit of
0means that there is no column limit. In this case, clang-format will respect the input’s line breaking decisions within statements unless they contradict other rules.
For PackConstructorInitializers: CurrentLine, the documentation says
Put all constructor initializers on the current line if they fit. Otherwise, put each one on its own line.
My expectation would be that this combination of ColumnLimit 0 and PackConstructorInitializers: CurrentLine means that constructor initializers will always stay in a single line.
Reproduced with Clang-Format version 16.0.6.
@llvm/issue-subscribers-clang-format
https://reviews.llvm.org/D157179