Skip to content

clang-format: add a style option for disabling all function arguments on one line #29133

@llvmbot

Description

@llvmbot
Bugzilla Link 28762
Version trunk
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

The style option AllowAllParametersOfDeclarationOnNextLine allows me to
prevent clang-format from pulling all parameters in a function declaration onto
a single line when I have intentionally put them on separate lines. This is
great.

But there doesn't appear to be a corresponding option for function calls.
clang-format is happy to pull function arguments onto a single line, even
when I've intentionally put them on separate lines and disabled bin packing.

Small example that reproduces this:

% cat .clang-format 
ColumnLimit: 80
BinPackArguments: false
BinPackParameters: false
AllowAllParametersOfDeclarationOnNextLine: false
AlignAfterOpenBracket: AlwaysBreak


% cat foo.cc
extern int arg_0, arg_1, arg_2;

void DoSomethingWithThreeIntsThatRequiresAVeryLongFunctionNameSeriouslyLong(
    int a,
    int b,
    int c);

void foo() {
  // I'm intentionally putting these one per line; I want them to align.
  DoSomethingWithThreeIntsThatRequiresAVeryLongFunctionNameSeriouslyLong(
      arg_0,
      arg_1,
      arg_2);
}


% clang-format -style=file foo.cc
extern int arg_0, arg_1, arg_2;

void DoSomethingWithThreeIntsThatRequiresAVeryLongFunctionNameSeriouslyLong(
    int a,
    int b,
    int c);

void foo() {
  // I'm intentionally putting these one per line; I want them to align.
  DoSomethingWithThreeIntsThatRequiresAVeryLongFunctionNameSeriouslyLong(
      arg_0, arg_1, arg_2);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions