Clang-format: Allow alignment across empty lines and comments

How would the formatter know whether the declarations following the comment are a continuation of the preceding series of declarations?

Paul C. Anagnostopoulos via llvm-dev writes:

How would the formatter know whether the declarations following the
comment are a continuation of the preceding series of declarations?

If "across comments" is set, it would always assume that declarations
following a comment are a continuation of the previous ones. Only a line
containing anything but a declaration or a comment would break alignment.

One could further control this by distinguishing between block and line
comments. So for example:

int bar = 1;
// int baz = 2;
int longfoo = 3;

would be aligned to

int bar = 1;
// int baz = 2;
int longfoo = 3;

But

int bar = 1;
/* This comment is meant to break alignment */
int longfoo = 3;

would stay as-is.

Would you prefer this behavior? I can see its appeal - it gets rid of
all the "superfluous change" when commenting-out an assignment in the
middle of a block, without lobbing together blocks of alignment you want
separated. However, this would make configuration more complicated. For
full flexibility, the enum would then need to have the members:

  - `<Something>_None` (the old `false`)
  - `<Something>_Consecutive` (the old `true`)
  - `<Something>_AcrossComments`
  - `<Something>_AcrossBlockComments`
  - `<Something>_AcrossLineComments`
  - `<Something>_AcrossEmptyLines`
  - `<Something>_AcrossEmptyLinesAndComments`
  - `<Something>_AcrossEmptyLinesAndBlockComments`
  - `<Something>_AcrossEmptyLinesAndLineComments`

Regards,
Lukas

Can I suggest you submit the patch, so we can discuss it in Phabricator, you can put me down as a reviewer

https://llvm.org/docs/Contributing.html

MyDeveloper Day writes:

Can I suggest you submit the patch, so we can discuss it in Phabricator,
you can put me down as a reviewer

The patch is submitted here: https://reviews.llvm.org/D93986

Thanks for reviewing!

Lukas