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

>From 23f5d12bf9e97576a30e3e85ad11be4142650c58 Mon Sep 17 00:00:00 2001
From: Eugene Shalygin <[email protected]>
Date: Fri, 27 Mar 2026 17:02:04 +0100
Subject: [PATCH] [clang-format] fix aligning inheritance lists with
 UT_AlignWithSpaces

---
 clang/lib/Format/ContinuationIndenter.cpp |  7 +++++++
 clang/unittests/Format/FormatTest.cpp     | 15 +++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index a388b74920e0b..513453c7e4e40 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -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) &&
+      Current.isOneOf(tok::kw_private, tok::kw_protected, tok::kw_public,
+                      tok::identifier)) {
+    CurrentState.IsAligned = true;
+  }
 
   if ((PreviousNonComment &&
        PreviousNonComment->isOneOf(tok::comma, tok::semi) &&
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 3d55a814e6027..68537b0a2b5f6 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8433,6 +8433,21 @@ 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"
+               "            public bbbbbbbbb\n",
+               Tabbed);
+  verifyFormat("struct S {\n"
+               "\tclass Foo : public aaaaaaaaa,\n"
+               "\t            public bbbbbbbbb {};\n"
+               "};",
+               Tabbed);
+  verifyFormat("struct Foo : aaaaaaaaaaaaaaa,\n"
+               "             bbbbbbbbbbbbbbb\n",
+               Tabbed);
 }
 
 TEST_F(FormatTest, BreakConstructorInitializersAfterComma) {

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to