llvm / llvm/llvm-project

[clang-format] RFC add SeparateDeclarationBlocks: (Leave|Always)

Open
#202,900 7 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

we have SeparateDefinitionBlocks which puts a newline between function definitions

```c++
void foo()
{
}
<----- newline added
void bar()
{
}
```

what do you think about having a SeparateDeclarationBlocks for putting newlines after declarations, I func headers with large amount of doxygen style comments get visually cluttered and would like to be able to auto add a newline.

```c++
/** foo func */
void foo();
/** bar func */
void bar();
```

becomes
```c++
/** foo func */
void foo();

/** bar func */
void bar();
```

@owenca , @HazardyKnusperkeks, I would be interested to hear your opinion on the value of such a capability.

Contributor guide

Open the contributing guide

Research direction

Start by tracing clang-format's existing SeparateDefinitionBlocks option and its formatting behavior. Determine where declaration blocks are classified, then verify that the requested setting inserts a blank line between documented declarations without changing other formatting; the examples in the issue define the expected result.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.