This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix PointerAlignment: Right not working with tab indentation.
ClosedPublic

Authored by curdeius on May 13 2022, 2:41 AM.

Details

Summary

Fixes https://github.com/llvm/llvm-project/issues/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;
}

Diff Detail

Event Timeline

curdeius created this revision.May 13 2022, 2:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 2:41 AM
curdeius requested review of this revision.May 13 2022, 2:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 2:41 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
curdeius edited the summary of this revision. (Show Details)May 13 2022, 2:42 AM
owenpan accepted this revision.May 13 2022, 9:55 AM
owenpan added inline comments.
clang/unittests/Format/FormatTest.cpp
14222

Redundant.

This revision is now accepted and ready to land.May 13 2022, 9:55 AM
curdeius added inline comments.May 13 2022, 1:21 PM
clang/unittests/Format/FormatTest.cpp
14222

Good catch. Will remove when landing (after the weekend probably).

This revision was landed with ongoing or failed builds.May 16 2022, 12:42 AM
This revision was automatically updated to reflect the committed changes.
curdeius marked an inline comment as done.