llvm / llvm/llvm-project

[clang-format] Add MinArgumentsToWrap option for function arguments/parameters

Open
#190,865 2 comments 0 reactions 0 assignees View on GitHub
clang-format
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

# Feature Request
Add an option to control the minimum number of function arguments/parameters before wrapping is applied.

# Motivation
I've been tinkering with clang-format and couldn't find a way to have something like this, currently what's possible
- Fully manual wrapping when setting ColumnLimit: 0
- Fully automatic wrapping either when line gets longer than ColumnLimit or always wrapping even for one argument

# Proposed Behavior
When set:
MinArgumentsToWrap: 3

```cpp
// one argument - stays inline
void Process(SomeTypeName param);

// two arguments still inline
void Process(int a, int b);

// three arguments wraps one argument per line
void Process(
int a,
int b,
int c
);
```

I can try to implement this and submit a PR if the approach is acceptable.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.