[clang-format] Minimize the damage caused by AlignArrayOfStructures when working...
authormydeveloperday <mydeveloperday@gmail.com>
Sat, 12 Mar 2022 17:21:33 +0000 (17:21 +0000)
committermydeveloperday <mydeveloperday@gmail.com>
Sat, 12 Mar 2022 17:22:31 +0000 (17:22 +0000)
commitadfe58b09df957f8911c5e152daa9564e5931631
treec42631a670d0e7d52bba2602b743983dfbda5641
parent6c123674d828412d9f57973958560896da9a7bc9
[clang-format] Minimize the damage caused by AlignArrayOfStructures when working on non square arrays

I have lost count of the number of times this has been reported, but it fundamentally comes down to the fact that the "AlignArrayLeft/Right" function is fundamentally broken for non-square arrays.

As a result, a pointer can end up running off the end of the array structure, I've spent the last 2 weekends trying to rewrite this algorithm but I've struggled to get it aligned correctly.

This is an interim fix, that ignores all array that are non-square and leaves them alone. I think this can allow us to close out most of the crashes (if not all).

I think this can help reduce the number of bugs coming in that are duplicates.

https://github.com/llvm/llvm-project/issues/53748
https://github.com/llvm/llvm-project/issues/51767
https://github.com/llvm/llvm-project/issues/51277

Reviewed By: curdeius, HazardyKnusperkeks, feg208

Differential Revision: https://reviews.llvm.org/D121069
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/FormatTest.cpp