[clang] [clang-format] fix aligning inheritance lists with UT_AlignWithSpaces (PR #189218)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 29 14:30:13 PDT 2026


================
@@ -1237,6 +1237,13 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
           Style.ContinuationIndentWidth;
     }
   }
+  if ((Style.BreakInheritanceList == FormatStyle::BILS_AfterComma ||
+       Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon) &&
+      Previous.isOneOf(TT_InheritanceComma, tok::comma) &&
----------------
HazardyKnusperkeks wrote:

I'm afraid this isn't good enough, although unlikely in real code.

```
void foo() {
int i // comment
, j;
}
```
Will change it's formatting:
Before:
```
format "void foo {int i //comment\n,j;}" --style="{UseTab: AlignWithSpaces, TabWidth: 4}" | sed -n l
void foo {$
  int i // comment$
\t  ,$
\t  j;$
}$
```

After:
```
format "void foo {int i //comment\n,j;}" --style="{UseTab: AlignWithSpaces, TabWidth: 4}" | sed -n l
void foo {$
  int i // comment$
\t  ,$
      j;$
}$
```

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


More information about the cfe-commits mailing list