Skip to content

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

Closed
@realnc

Description

@realnc
Member
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.

Activity

llvmbot

llvmbot commented on Jul 13, 2020

@llvmbot
Member

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

mkurdej

mkurdej commented on Sep 22, 2020

@mkurdej
Member

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

mkurdej

mkurdej commented on Sep 22, 2020

@mkurdej
Member

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.

added a commit that references this issue on Jun 17, 2024
d06b923
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mkurdej@realnc@llvmbot

        Issue actions

          clang-format adds bogus linebreak when function arguments contain lambda · Issue #44486 · llvm/llvm-project