Skip to content

Add a new option to clang-format for newline before function parameters #62092

Open
@jrmolin

Description

@jrmolin

The Clang-Format options available do not allow one to configure a consistent look for function definitions and declarations.

Functions with few parameters tend to have no newlines inserted, while functions with either long names or many parameters have line breaks inserted.

The current state:

int
one_liner_function(int arg1, int arg2);

int
super_long_function_name_that_has_line_breaks(
    const custom_type_with_obnoxiously_long_name &first_parameter,
    int second_parameter);

The ideal possible:

int
one_liner_function(
    int arg1,
    int arg2);

int
super_long_function_name_that_has_line_breaks(
    const custom_type_with_obnoxiously_long_name &first_parameter,
    int second_parameter);

Please add an option AlwaysBreakBeforeFunctionParameters that is a boolean.

There is a Phabricator patch existing for this: https://reviews.llvm.org/D125171

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions