[all-commits] [llvm/llvm-project] 58c67e: [clang-format] Fix AlignArrayOfStructures + Cpp11B...

Owen via All-commits all-commits at lists.llvm.org
Thu Aug 31 14:21:37 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 58c67e724f718be06ea43c766871135a338c2d55
      https://github.com/llvm/llvm-project/commit/58c67e724f718be06ea43c766871135a338c2d55
  Author: Galen Elias <galenelias at gmail.com>
  Date:   2023-08-31 (Thu, 31 Aug 2023)

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

  Log Message:
  -----------
  [clang-format] Fix AlignArrayOfStructures + Cpp11BracedListStyle=false

Currently AlignArrayOfStructures=Left is hard coding setting Spaces to
0 for the token following the initial opening brace, but not touching
Spaces for the subsequent lines, which leads to the array being
misaligned. Additionally, it's not adding a space before the trailing
} which is generally done when Cpp11BracedListStyle=false.

I'm not exactly sure why this function needs to override the Spaces as
it seems to generally already be set to either 0 or 1 according to
the other formatting settings, but I'm going with an explicit fix where
I just force the padding to 1 when Cpp11BracedListStyle=false.

AlignArrayOfStructures=Right doesn't have any alignment problems, but
isn't adding the expected padding around the braces either, so I'm
giving that the same treatment.

Fixes #57611.

Differential Revision: https://reviews.llvm.org/D158795




More information about the All-commits mailing list