[llvm-bugs] [Bug 46550] New: clang-format: Add option to enforce separation line between method definitions

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 1 23:52:49 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46550

            Bug ID: 46550
           Summary: clang-format: Add option to enforce separation line
                    between method definitions
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rverschelde at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

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].

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200702/68a6223e/attachment.html>


More information about the llvm-bugs mailing list