This is a bug fix of https://bugs.llvm.org/show_bug.cgi?id=49175.
The AlignConsecutiveDeclarations option doesn't handle pointer properly:
The expected code format:
unsigned int* a; int* b; unsigned int Const* c;
The actual code after formatting:
unsigned int* a; int* b; unsigned int Const* c;
From the code of clang-format, it seems the WhitespaceManager miss treated Const as one of the token and which leads to the faulty behavior. So I added an extra check that if the next token is a pointer or a reference, then the current token is not the aligned token (the matcher lambda returns false).
Unit test passed:
darwin@Darwins-iMac build % cmake --build . -j24 -t check-clang-unit ... [100%] Running lit suite /Volumes/silo/Projects/llvm-project/clang/test/Unit Testing Time: 270.81s Passed: 13848 [100%] Built target check-clang-unit
Maybe I should combine the conditions into this isOneOf(...) together since they all return false.
Well, when I was writing this, I remembered why I had put the check before line 714. It was because line 714 would be executed and breaks in that scenario.