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

Eugene Shalygin via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 1 02:55:14 PDT 2026


================
@@ -8435,6 +8435,20 @@ TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
       "  : public aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
       "    public bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {};",
       Style);
+  FormatStyle Tabbed = getLLVMStyleWithColumns(42);
+  Tabbed.IndentWidth = 4;
+  Tabbed.TabWidth = 4;
+  Tabbed.UseTab = FormatStyle::UT_AlignWithSpaces;
+  verifyFormat("class Foo : public aaaaaaaaa,\n"
+               "            protected bbbbbbbbb,\n"
+               "            private cccccccccc,\n"
+               "            dddddddddd {};",
+               Tabbed);
+  verifyFormat("struct S {\n"
+               "\tclass Foo : public aaaaaaaaa,\n"
+               "\t            private bbbbbbbbb {};\n"
+               "};",
+               Tabbed);
----------------
zeule wrote:

I understand that that is the current behaviour, thank you. It is just the documentation text which is confusing to me.

Maybe something like the following would be self describing?
```c++
enum BreakBehavior {No, Allow, Force};
enum BreakPoisition {Before, After};
struct  BreakElement {
    BreakBehavior behavior;
    BreakPoisition position;
};
struct BreakInheritanceList {
    BreakElement colon;
    BreakElement comma;
};
```

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


More information about the cfe-commits mailing list