[llvm-dev] Clang-format: Allow alignment across empty lines and comments

MyDeveloper Day via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 1 09:43:00 PST 2021


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

On Fri, Jan 1, 2021 at 4:07 PM Lukas Barth via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

>
> 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
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210101/b7df2522/attachment.html>


More information about the llvm-dev mailing list