[Format] Don't derive pointers right based on space before method ref-qualifiers
authorSam McCall <sam.mccall@gmail.com>
Thu, 3 Feb 2022 17:15:49 +0000 (18:15 +0100)
committerSam McCall <sam.mccall@gmail.com>
Fri, 4 Feb 2022 11:13:58 +0000 (12:13 +0100)
commitacc3ce945c32a71ec077df379c99d859f31cc741
tree5c2986c1be5cf349dc5d3c510058fa668ba23736
parent42afaf7f472ce8ae14f1aa3858f1a8f3abc4ac67
[Format] Don't derive pointers right based on space before method ref-qualifiers

The second space in `void foo() &` is always produced by clang-format,
and isn't evidence of any particular style.

Before this patch, it was considered evidence of PAS_Right, because
there is a space before a pointerlike ampersand.

This caused the following code to have "unstable" pointer alignment:
  void a() &;
  void b() &;
  int *x;
PAS_Left, Derive=false would produce 'int* x' with other lines unchanged.
But subsequent formatting with Derive=true would produce 'int *x' again.

Differential Revision: https://reviews.llvm.org/D118921
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp