Alecto
Alecto

Reputation: 10750

Get clang format to put closing parenthesis of multiline function calls on separate lines?

I've been using clang format to help keep my code clean. For multiline function calls, is there any way to get clang to put the closing parenthesis on it's own line?

Example:

What it's doing now:

increment_and_call_on_match(
    clique_colors,
    0,
    max_clique_color,
    [&](int clique_color) { 
        comms.emplace_back(context.split_by_color(clique_color)); 
    },
    [&](int) { context.split_by_color(); });

What I want:

increment_and_call_on_match(
    clique_colors,
    0,
    max_clique_color,
    [&](int clique_color) { 
        comms.emplace_back(context.split_by_color(clique_color)); 
    },
    [&](int) { context.split_by_color(); }
); //Closing paren on new line

Upvotes: 22

Views: 3757

Answers (1)

Dwayne Robinson
Dwayne Robinson

Reputation: 2439

A new option AlignAfterOpenBracket: BlockIndent was added 2022-01-17 in the approved code review https://reviews.llvm.org/D109557, which is in LLVM 14.0.0-rc1 or later.

(I too want this, as we have thousands of lines of code which use this style, and clang-format supporting this would get me to adopt clang format in Visual Studio - https://developercommunity.visualstudio.com/content/problem/232465/clang-format-messes-with-closing-parentheses-in-fu.html)

Upvotes: 19

Related Questions