Issue 166632
Summary clang-format: Allow empty records and enums on a single line
Labels clang-format
Assignees
Reporter daggerbot
    Feel free to close this if this is already possible and I just failed to figure out how.

There doesn't appear to be a way to accomplish this with clang-format:

```cpp
// Break before braces after class/struct/union:
struct Foo
{
  int x;
};

// AND allow empty class/struct/union on a single line:
struct Foo {};
```

If we set `BraceWrapping: AfterStruct: true` and `BraceWrapping: SplitEmptyRecord: false`, we instead get this:

```cpp
struct Foo
{};
```

My proposal would have two parts:
- Add a `bool AllowEmptyRecordsOnASingleLine` option to handle the case in this example, and
- Change the type of `AllowShortEnumsOnASingleLine` to have `Yes`, `No`, and `Empty` values (while allowing `true` or `false` for backwards compatibility if possible) to allow the same behavior for empty enums but not short, non-empty enums.

If others think this would be an acceptable enhancement, I can look into implementing it myself, but I though I'd request feedback before I put in the work.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to