Clang-format: Allow alignment across empty lines and comments


I would like to patch clang-format such that its alignment tools (such
as AlignConsecutiveAssignments) can work across empty lines and
comments. In effect, I would like that this code:

int foo = 1;
int longbar = 2;

/* Some comment */
int baz = 3;

can automatically be formatted to this:

int foo     = 1;
int longbar = 2;

/* Some comment */
int baz     = 3;

I have a first working patch, but since I've never contributed to LLVM, I
wanted to discuss here (a) whether this change would be accepted in
principle and (b) how the configuration options should look like, before
I put in the work to make the patch "production ready".

Regarding (a): I think this would be useful. People use this style in
practice [1]. Also, if you have a long block of aligned assignments, and some
code change (temporarily, maybe) comments-out a single assignment in the
middle, this suddenly causes clang-format to re-indent the assignments
below that - even though there is no functional change to those

Regarding (b): Currently, the `AlignConsecutive{Assignments, BitFields,
Declarations, Macros}` are boolean options. I see two ways of
controlling intended behavior: Either, add two new booleans per option,
in the style of `AlignConsecutiveAssignmentsAcrossEmptyLines` and
`AlignConsecutiveAssignmentsAcrossComments`, or make the four existing
options enums, with the choices
       - `<Something>_None` (the old `false`)
       - `<Something>_Consecutive` (the old `true`)
       - `<Something>_AcrossComments`
       - `<Something>_AcrossEmptyLines`
       - `<Something>_AcrossEmptyLinesAndComments`

Of course I would parse `true` to `Consecutive` and `false` to `None`
for backwards compatibility. I favor this enum-approach.

One final question: I have a patch for the `AlignConsecutiveAssignments`
alignment. The others would be very similar, but some busy-work
(changing unit tests, etc.) is required. Would it be preferrable if I
first submitted the smaller patch for AlignConsecutiveAssignments,
discuss it and get it in, and then supply the patch for the other four,
or would a one-in-all patch be preferred?


[1] mu/mu-msg.h at 46bd705131db50dbebe624f0fe513fe615382582 · djcb/mu · GitHub