[PATCH] D158795: Fix AlignArrayOfStructures + Cpp11BracedListStyle=false

Galen Elias via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 16:30:22 PDT 2023


galenelias created this revision.
galenelias added a project: clang-format.
Herald added projects: All, clang.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
galenelias requested review of this revision.

Fixes: https://github.com/llvm/llvm-project/issues/57611

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.


https://reviews.llvm.org/D158795

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158795.553303.patch
Type: text/x-patch
Size: 4111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230824/d973b79d/attachment.bin>


More information about the cfe-commits mailing list