[PATCH] D27651: [clang-format] Even with AlignConsecutiveDeclarations, PointerAlignment: Right should keep *s and &s to the right

Ken-Patrick Lehrmann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 1 04:54:31 PDT 2018

KP added inline comments.

Comment at: unittests/Format/FormatTest.cpp:7878
+            "  int const i   = 1;\n"
+            "  int     **j   = 2, ***k;\n"
+            "  int      &k   = i;\n"
djasper wrote:
> This looks wrong to me. Wouldn't you want to align on the */& then? I.e.:
>   int const i   = 1;
>   int       **j = 2, ***k;
>   int       &k  = i;
Sorry for the very late reply.
I believe no. In my mind (and how my organization wanted it) was to align on the variable names, and 'just' put the */& just before to it, without any space in between.

An other way of saying it would be: "PAS_Right means the */& stick with the variable name".
AlignConsecutiveDeclaration aligns the variable names, which give the results we have here.
We believe it is fine.

What you suggest breaks the alignment on the variable names, it looks wrong too...  Probably, there's not a perfect answer here.

I'd say it's better to have the variable names aligned. Wdyt ?


More information about the cfe-commits mailing list