LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 46550 - clang-format: Add option to enforce separation line between method definitions
Summary: clang-format: Add option to enforce separation line between method definitions
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-01 23:52 PDT by Rémi Verschelde
Modified: 2020-07-01 23:52 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rémi Verschelde 2020-07-01 23:52:49 PDT
This is a feature request for clang-format.

In C/C++ codebases, some developers (possible some IDEs?) tend to group the definition of setters and getters together, without having an empty line separating each definition, e.g.:

```
void some_method() {
    // some code
}

void set_some_property(int p_value) {
    some_property = p_value;
    // do setter stuff
}
int get_some_property() {
    return some_property;
}

void some_other_method() {
     // some code
}
```

Since this "style" is down to personal preference, it tends not to be upheld consistently in big codebases, so in my project (https://github.com/godotengine/godot) we want to enforce having a separation line between *all* method definitions, whether or not they might be semantically related, i.e.:

```
void some_method() {
    // some code
}

void set_some_property(int p_value) {
    some_property = p_value;
    // do setter stuff
}

int get_some_property() {
    return some_property;
}

void some_other_method() {
     // some code
}
```

I would appreciate having a way to enforce this via clang-format instead of manual review.

I'm not sure what the best name would be for the option, maybe EnforceSeparationLineBetweenMethodDefinitions?

I don't know if there would be a use case for a flag that would enforce *not* having a separation line between all method definitions (I don't have any myself), but if so it could be SeparationLineBetweenMethodDefinitions: [Always, Never, LeaveAsIs].