llvm / llvm-project

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

`AlignAfterOpenBracket: BlockIndent` is not applied to lambdas #104870

Open akbyrd opened 2 months ago

akbyrd commented 2 months ago

Version: 18.1.8

Config

ColumnLimit: 30
AlignAfterOpenBracket: BlockIndent
BinPackParameters: true

Input

void f1_____(int token, float context) {
}

auto f2 = [](int token, float context) {
};

Actual Output

void f1_____(
    int token, float context
) {}

auto f2 = [](int token,
             float context) {
};

Expected Output

void f1_____(
    int token, float context
) {}

auto f2 = [](
    int token, float context
) {};

Notice the closing paren for the lambda is not moved to a new line as with the function. Also, bin packing is not applied.

llvmbot commented 2 months ago

@llvm/issue-subscribers-clang-format

Author: Adam Byrd (akbyrd)

Config ``` ColumnLimit: 30 AlignAfterOpenBracket: BlockIndent BinPackParameters: false ``` Input ``` void f1_____(int token, float context) { } auto f2 = [](int token, float context) { }; ``` Actual Output ``` void f1_____( int token, float context ) {} auto f2 = [](int token, float context) { }; ``` Expected Output ``` void f1_____( int token, float context ) {} auto f2 = [](int token, float context ) { }; ```
akbyrd commented 2 months ago

I think this is a general issue with all values of AlignAfterOpenBracket applied to lambdas. Parameters are always aligned near the opening paren. This means none of DontAlign, BlockIndent, or AlwaysBreak behave as expected.