Issue 97303
Summary [clang-format] Feature Request: Newline after declarations
Labels clang-format
Assignees
Reporter Jacobfaib
    I would like to enforce that variable declarations are followed (or preceded) by `N` empty lines. To my knowledge, this is not possible to directly enforce in current (`clang-format-19`). Something like:
```yaml
EmptyLinesAroundDecls:
  Enabled: <bool>
  Before: <int>
  After: <int>
```
It would be great if this could also distinguish between empty lines after block openings, and functions calls. If I specify that I want `Before: 1` and `After: 1`, I want to ignore `Before` for block openings. Probably this requires an additional option `IgnoreBlockOpening`?
```c++
// GOOD
foo();

int x;
double y;
auto z = [] { return 0; }();

foo();

{
  int x; // Note, no empty line above OK

  foo();
}
```
```c++
// BAD (no empty lines before or after decls)
foo();
int x;
double y;
auto z = [] { return 0; }();
foo();
{

  int x; // BAD, empty line after block opening
}
```
```c++
// BAD (no empty lines after decls)
foo();

int x;
double y;
auto z = [] { return 0; }();
foo();
```
```c++
// BAD (no empty lines before decls)
foo();
int x;
double y;
auto z = [] { return 0; }();

foo();
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to