[clang] [clang-format] Fix incorrect trailing comment and escaped newlines when AlignArrayOfStructures is enabled (PR #180305)

Ben Dunkin via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 12 09:54:43 PST 2026


================
@@ -409,9 +425,10 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
         } else if (Style.PointerAlignment != FormatStyle::PAS_Right) {
           continue;
         }
-        Changes[Previous + 1].Spaces -= Shift;
-        Changes[Previous].Spaces += Shift;
-        Changes[Previous].StartOfTokenColumn += Shift;
+
+        int Next = Previous + 1;
----------------
bdunkin wrote:

I would rather not modify the logic of the loop if I can help it because it isn't relevant to the fix I am making. I had created this new variable because using `Previous + 1` inline caused a line break that looked ugly. I've now added a new function that takes a delta instead of absolute spaces, and used it here. This makes the line not as long with an inline `Previous + 1`, and we don't need to worry about naming. 

https://github.com/llvm/llvm-project/pull/180305


More information about the cfe-commits mailing list