llvm / llvm/llvm-project

[clang-format] Option to put each argument on its own line with continuation indent

Open
#212,670 11 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

# feat

Less parameter line leading spaces

## problem

Each parameter line have too much leading spaces = **26**

## version

clang-format version 21.1.8

## reproduce

```c
// clang-format off
uint64_t reproduce_original(uint64_t (*add)(uint64_t, uint64_t), uint64_t left, uint64_t right);
// clang-format on
```

## actual

Due to length of `uint64_t reproduce_actual`, Each parameter line have too much leading spaces = **26**

`.clang-format`

```yaml
BasedOnStyle: LLVM
BinPackParameters: false
```

```c
uint64_t reproduce_actual(uint64_t (*add)(uint64_t, uint64_t),
uint64_t left,
uint64_t right);
```

## expected

Each parameter line leading spaces = 2

```c
// clang-format off
uint64_t reproduce_expected(
uint64_t (*add)(uint64_t, uint64_t),
uint64_t left,
uint64_t right
);
// clang-format on
```

Contributor guide

Open the contributing guide

Research direction

Start by running clang-format 21.1.8 on the provided C reproducer with the shown .clang-format settings and compare the actual and expected layouts. Read the clang-format option handling and formatting path for function parameters; done means a configurable option produces one parameter per line with two-space continuation indentation and the closing parenthesis on its own line.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.