Skip to content

clang-format incorrectly formats C++ lambdas with BeforeLambdaBody true #54518

Closed as not planned
@tophoo

Description

@tophoo

Based on #51234 this issue is about the incorrect formatting of C++ lambdas with BeforeLambdaBody true. Content of .clang-format:

BreakBeforeBraces: Custom
BraceWrapping: {
    BeforeLambdaBody: true,
}
ColumnLimit: 0

The problem has been described by @kalinnikovv:
The closing brace of the lambda body always gets folded into the line before it.

foo(param, [] {
return 1;
}());

gets formatted into

foo(param, []
    {
         return 1;  });

while I expect it to become

foo(param, []
    {
         return 1;
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-formatobsoleteIssues with old (unsupported) versions of LLVM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions