[clang] [clang-format] Allow array alignment on non-rectangular arrays (PR #143781)
Ben Dunkin via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 2 12:12:30 PDT 2025
bdunkin wrote:
I have updated the PR description to cover what I've changed here.
To address directly the test you point out: The alignment code previously would add line breaks to long string literals that had been aligned so they crossed the column limit. The resulting format ignored other formatting rules, had edge cases that were not considered, and overwrote the result of the line break optimization pass where those edge cases _were_ considered. This caused a lot of bad formatting because it created formatting that the line break optimization would not have chosen. I could not find a satisfactory way to address the edge cases so I change the alignment code to not add or remove line breaks.
All line breaks are now added _only_ in the line break optimization pass, and alignment has to work within them. This means that any row that does not fit on a line needs a rule that can be applied at line break optimization time. I chose for them to be formatted like lists with a trailing comma (one element per line), but I have no strong attachment to that choice if someone comes up with an alternative.
https://github.com/llvm/llvm-project/pull/143781
More information about the cfe-commits
mailing list