Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-format] AlignArrayOfStructures ignores Cpp11BracedListStyle #57611

Closed
gerboengels opened this issue Sep 7, 2022 · 2 comments
Closed
Assignees

Comments

@gerboengels
Copy link

gerboengels commented Sep 7, 2022

$ clang-format --version
clang-format version 15.0.0
$ echo "auto x = { { a, b }, { c, d } }" | clang-format --style="{ Cpp11BracedListStyle: false, AlignArrayOfStructures: Left }"
auto x = {
  {a,  b},
  { c, d}
}

Note the inconsistent spacing before a and c
With Cpp11BracedListStyle: false I'd expect the following, with spaces both before and after the curlies

auto x = {
  { a, b },
  { c, d }
}
@llvmbot
Copy link
Member

llvmbot commented Sep 7, 2022

@llvm/issue-subscribers-clang-format

@galenelias
Copy link

@HazardyKnusperkeks HazardyKnusperkeks added the awaiting-review Has pending Phabricator review label Aug 25, 2023
@owenca owenca closed this as completed in 58c67e7 Aug 31, 2023
@owenca owenca removed the awaiting-review Has pending Phabricator review label Aug 31, 2023
smeenai pushed a commit to smeenai/llvm-project that referenced this issue Sep 1, 2023
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 llvm#57611.

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

commit-id:e09cfa2b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants