llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.15k stars 11.62k forks source link

[clang-format] AlignConsecutiveAssignments breaks formatting of continued functions #53497

Open mkurdej opened 2 years ago

mkurdej commented 2 years ago

Related to #52772.

Given:

BasedOnStyle: LLVM
AlignConsecutiveAssignments: Consecutive
ColumnLimit: 50 # just for the ease of reproduce

The code:

auto b = f(aaaaaaaaaaaaaaaaaaaaaaaaa,
           ccc ? aaaaa : bbbbb,
           dddddddddddddddddddddddddd);

is formatted correctly.

However, this one, with alignment on the assignment:

auto aaaaaaaaaaaa = f();
auto b            = f(aaaaaaaaaaaaaaaaaaaaaaaaa,
           ccc ? aaaaa : bbbbb,
                      dddddddddddddddddddddddddd);

has its last line being aligned with the opening parenthesis.

Expected formatting (not sure about the indentation of the last two lines though):

auto aaaaaaaaaaaa = f();
auto b            = f(aaaaaaaaaaaaaaaaaaaaaaaaa,
           ccc ? aaaaa : bbbbb,
           dddddddddddddddddddddddddd);
llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-format

llvmbot commented 2 years ago

@llvm/issue-subscribers-bug