-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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: PointerAlignment: Right not working with tab indentation. #55407
clang-format: PointerAlignment: Right not working with tab indentation. #55407
Comments
@llvm/issue-subscribers-clang-format |
@llvm/issue-subscribers-bug |
Confirmed on main.
|
Revision URI: https://reviews.llvm.org/D125528 |
Thank you. I'm doing a half-day today but I'll aim to compile and test this Monday. |
I can confirm that it works as expected with the patch applied. Thank you very much for a fast turnaround. |
Is the fix for this in 14.0.4? I've installed the release today and am still seeing multiple issues. |
@mkurdej Is this OK to backport? |
Yes, absolutely! |
Should be fine to backport @tstellar |
/cherry-pick e20bc89 |
/branch llvm/llvm-project-release-prs/issue55407 |
…tation. Fixes llvm/llvm-project#55407. Given configuration: ``` UseTab: Always PointerAlignment: Right AlignConsecutiveDeclarations: true ``` Before, the pointer was misaligned in this code: ``` void f() { unsigned long long big; char *ptr; // misaligned int i; } ``` That was due to the fact that when handling right-aligned pointers, the Spaces were changed but StartOfTokenColumn was not. Also, a tab was used not only for indentation but for spacing too when using `UseTab: ForIndentation` config option: ``` void f() { unsigned long long big; char *ptr; // \t after char int i; } ``` Reviewed By: owenpan Differential Revision: https://reviews.llvm.org/D125528 (cherry picked from commit e20bc89)
/pull-request llvm/llvm-project-release-prs#15 |
/branch mkurdej/llvm-project/gh55407-14.x |
@tstellar, this should fix the automatic merge. |
Failed to create pull request for gh55407-14.x https://github.com/llvm/llvm-project/actions/runs/2459565902 |
Not sure what failed here... Any hints? |
I think that happens when you use the branch flow - it's a limitation in that one right now - @tstellar fixed a similar issue manually before. If you describe it Tom - I can also help out fixing them until the proper fix is in place. |
@tru The fix is to copy the branch to the llvm/llvm-project-release-prs repo and then use the new branch for the pull request. |
…tation. Fixes llvm/llvm-project#55407. Given configuration: ``` UseTab: Always PointerAlignment: Right AlignConsecutiveDeclarations: true ``` Before, the pointer was misaligned in this code: ``` void f() { unsigned long long big; char *ptr; // misaligned int i; } ``` That was due to the fact that when handling right-aligned pointers, the Spaces were changed but StartOfTokenColumn was not. Also, a tab was used not only for indentation but for spacing too when using `UseTab: ForIndentation` config option: ``` void f() { unsigned long long big; char *ptr; // \t after char int i; } ``` Reviewed By: owenpan Differential Revision: https://reviews.llvm.org/D125528
Merged: 3cd9df8 |
…tation. Fixes llvm/llvm-project#55407. Given configuration: ``` UseTab: Always PointerAlignment: Right AlignConsecutiveDeclarations: true ``` Before, the pointer was misaligned in this code: ``` void f() { unsigned long long big; char *ptr; // misaligned int i; } ``` That was due to the fact that when handling right-aligned pointers, the Spaces were changed but StartOfTokenColumn was not. Also, a tab was used not only for indentation but for spacing too when using `UseTab: ForIndentation` config option: ``` void f() { unsigned long long big; char *ptr; // \t after char int i; } ``` Reviewed By: owenpan Differential Revision: https://reviews.llvm.org/D125528
…tation. Fixes llvm/llvm-project#55407. Given configuration: ``` UseTab: Always PointerAlignment: Right AlignConsecutiveDeclarations: true ``` Before, the pointer was misaligned in this code: ``` void f() { unsigned long long big; char *ptr; // misaligned int i; } ``` That was due to the fact that when handling right-aligned pointers, the Spaces were changed but StartOfTokenColumn was not. Also, a tab was used not only for indentation but for spacing too when using `UseTab: ForIndentation` config option: ``` void f() { unsigned long long big; char *ptr; // \t after char int i; } ``` Reviewed By: owenpan Differential Revision: https://reviews.llvm.org/D125528
When using PointerAlignment: Right with Tabs then variable names get aligned incorrectly. This needs a combination of UseTab and PointerAlignment to reproduce, and probably AlignConsecutiveDeclarations as well in order to request the alignment. It's broken for several values of UseTab, although Never works as expected.
We are also using IndentWidth: 8, without this then UseTab ForIndentation appears to work, at least for first-level indents although UseTab Always is still broken.
Sample input file:
Configuration
Observed output, note the incorrect spacing before *ptr.
When running with PointerAlignment: Middle we see the output is correct, however this does not match our existing coding style.
Verified on
clang-format version 14.0.0 (Fedora 14.0.0-1.fc36)
(fedora 36) and others.The text was updated successfully, but these errors were encountered: