[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

Maximilian Fickert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 24 06:22:56 PST 2020


fickert added a comment.

In D75034#1889107 <https://reviews.llvm.org/D75034#1889107>, @MyDeveloperDay wrote:

> > Is this intentional, or is it an oversight?
>
> This is the key question, which I'm not sure how we can answer without the help of the original authors @djasper and @klimek
>
> For example I can't understand with the example below if the TabWith is 8 why are you putting 13 spaces in, rather than the original test which had 1 tab (assuming 8 characters) and 5 spaces? (to make up 13)
>
> Could you explain why this is the correct change for this example why its correct to put 13 spaces? (is this not continuation or indentation?)
>
>   Tab.UseTab = FormatStyle::UT_ForContinuationAndIndentation;
>   Tab.TabWidth = 8;
>   Tab.IndentWidth = 8;
>   verifyFormat("class X {\n"
>                "\tvoid f() {\n"
>                "\t\tsomeFunction(parameter1,\n"
>                "\t\t.............parameter2);\n"
>                "\t}\n"
>                "};",
>                Tab);
>   


In this example, the first two tabs are for indentation, and the remaining whitespace before parameter2 is for alignment (not continuation) with parameter1. If tabs are used in the alignment, the formatted code will only look aligned with the correct tab width, whereas if the alignment is done with spaces, the code will look aligned with arbitrary tab width.

I believe this to be the expected behavior for `UT_ForContinuationAndIndentation`, and tabs should only be used for alignment with `UT_Always`, but I would also be happy about comments from the original authors.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75034/new/

https://reviews.llvm.org/D75034





More information about the cfe-commits mailing list