[all-commits] [llvm/llvm-project] acc3ce: [Format] Don't derive pointers right based on spac...

Sam McCall via All-commits all-commits at lists.llvm.org
Fri Feb 4 03:16:49 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: acc3ce945c32a71ec077df379c99d859f31cc741
      https://github.com/llvm/llvm-project/commit/acc3ce945c32a71ec077df379c99d859f31cc741
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2022-02-04 (Fri, 04 Feb 2022)

  Changed paths:
    M clang/lib/Format/Format.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list