[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:49:06 PST 2026


================
@@ -284,6 +284,33 @@ void WhitespaceManager::calculateLineBreakInformation() {
   }
 }
 
+// Sets the spaces in front of a Change, and updates the start/end columns of
+// subsequent tokens so that trailing comments and escaped newlines can be
+// aligned properly
+static void
+SetChangeSpaces(unsigned Start, unsigned Spaces,
+                SmallVector<WhitespaceManager::Change, 16> &Changes) {
+  WhitespaceManager::Change &FirstChange = Changes[Start];
+  const int ColumnChange = Spaces - FirstChange.Spaces;
+
+  if (ColumnChange == 0)
+    return;
+
+  FirstChange.Spaces += ColumnChange;
+  FirstChange.StartOfTokenColumn += ColumnChange;
+
+  for (unsigned i = Start + 1; i < Changes.size(); i++) {
----------------
bdunkin wrote:

Fixed.

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


More information about the cfe-commits mailing list