[clang-format] Align all struct/union members without aligning variable declarations

Hello,

This is the first time I post on a mailing list like this so I’m sorry if something is not formatted correctly. I tried searching for a similar thread, but I found nothing.

Currently, clang-format is not really able to format a structure as this (I really hope this will be displayed as I want to, but just in case: https://pastebin.com/dW62kJys):

struct
{
int field1;
char *field2;
struct
} my_struct;

Almost all options format it like this:

struct
{
int field1;
char *field2;
} my_struct;

This looks ok for small structs, but makes longer structs harder to read. This is subjective, but I think that having all the fields aligned is sometimes better.

There is a workaround that almost works, but doesn’t. If you set AlignConsecutiveDeclarations to true the fields will be aligned in the above case. Unfortunately this will also align variable declarations, which may not be what a user is looking for.
Also, if you have any kind of comments above the fields it will not work anymore.

Is there any possibility of having an option that aligns the fields inside a structure?

It should probably apply to unions as well.

Maybe there is already a reason for which this wasn’t included in the options and I’m missing it?

Best regards,
Cristi