Skip to content

clang-format adds bogus linebreak when function arguments contain lambda #44486

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
realnc opened this issue Mar 7, 2020 · 3 comments
Closed
Labels
bugzilla Issues migrated from bugzilla clang-format confirmed Verified by a second party

Comments

@realnc
Copy link
Member

realnc commented Mar 7, 2020

Bugzilla Link 45141
Version 10.0
OS Linux
CC @mkurdej,@emmenlau

Extended Description

clang-format is unable to correctly format code like this:

func(0, [] {}, 0);

It will format it into:

func(
    0, [] {}, 0);

Shortest example code that reproduces it:

void f()
{
    func(0, [] {}, 0);
}

The clang-format invocation can be the simplest possible. Just "clang-format test.cpp" without any .clang-format input file and no arguments.

@llvmbot
Copy link
Member

llvmbot commented Jul 13, 2020

It only happens when the lambda is neither the first nor the last argument.

@mkurdej
Copy link
Member

mkurdej commented Sep 22, 2020

That's a regression between clang-format 7(.1) and 8.

@mkurdej
Copy link
Member

mkurdej commented Sep 22, 2020

This behaviour was caused by commit 5528cac ([clang-format] tweaked another case of lambda formatting). Reverting this commit makes the testcases from this PR pass.

The mentioned commit introduced an aggressive way of breaking lines when lambda is not the last arguments.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bugzilla Issues migrated from bugzilla clang-format confirmed Verified by a second party
Projects
None yet
Development

No branches or pull requests

3 participants