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
Alignment of consecutive assignment and declarations causes incorrect indentation for array variables #52914
Comments
You say that version 12 gives incorrect formatting as well. What's the expected output for you? |
With 12.0.1, I get: void foo() {
const char* formats[] = {"%",
"%%", // some comment
"%+-?4.5d"
"%#-4.3%f",
"%15.a6e"};
const int numFormats = sizeof(formats) / sizeof(char*);
} Notice the 2nd through 5th items in the formats array are shifted left by one. If we remove the Align* items from the _clang-format file, we get the expected alignment with both 12.0.1 and 13.0.0. Thus, the Align* items in the _clang-format are causing one space back-shifting in 12.0.1 and one or two space back-shifting for 13.0.0 for the 2nd though 5th items in the formats array. Here's the expected result (and what we get if we remove the Align* items from _clang-format): void foo() {
const char* formats[] = {"%",
"%%", // some comment
"%+-?4.5d"
"%#-4.3%f",
"%15.a6e"};
const int numFormats = sizeof(formats) / sizeof(char*);
} |
Minimal reproduce:
with
The bug doesn't happen when only one of Align* options is used. |
Review: https://reviews.llvm.org/D116527. |
is the missing comma after the "%+-?4.5d" deliberate? |
I have noticed it as well, but it doesn't change anything to the fact that the quotes are not aligned to the quote on the first line. |
The missing comma was an accident, but the quotes should still align |
Given
clang-format 13 will produce:
Note, this differs from clang-format 12.0.1 which is slightly better but still incorrect.
Here's the _clang-format used in the above:
If you comment out the AlignConsecutive* lines in _clang-format, we get correct indentation, thus the alignment items are causing problems.
The text was updated successfully, but these errors were encountered: