llvm / llvm/llvm-project

[clang-format] AllowShortFunctionsOnASingleLine.Other depends on Empty

Open
#206,144 1 comment 0 reactions 0 assignees View on GitHub
clang-format confirmed
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

`AllowShortFunctionsOnASingleLine.Other` only works if `AllowShortFunctionsOnASingleLine.Empty` is also set. This is not expected based on the documentation and examples.

Command:
`clang-format --style="{BasedOnStyle: LLVM, AllowShortFunctionsOnASingleLine: {Empty: false, Other: true}}"`

Expected Unchanged Input:
```
void foo() {
}

void bar() { return; }
```

Actual
```
void foo() {
}

void bar() {
return;
}
```

Note that setting `Empty: true` gives expected results:
`clang-format --style="{BasedOnStyle: LLVM, AllowShortFunctionsOnASingleLine: {Empty: true, Other: true}}"`

```
void foo() {}

void bar() { return; }
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided clang-format command and compare the output for Empty: false and Empty: true. Trace the handling of AllowShortFunctionsOnASingleLine options, then ensure Other: true preserves the one-line non-empty function without requiring Empty: true, while the empty function remains unchanged; add or update coverage for these cases.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.