[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-10 Thread Björn Schäpers via cfe-commits

HazardyKnusperkeks wrote:

> > > Oh, I seem to have misunderstood the word "style" in the context of 
> > > clang-format. I took it to mean a concrete built-in style, like LLVM, 
> > > Google, Chromium, Mozilla, WebKit...
> > > Am I wrong?
> > 
> > 
> > It's not talking about a new style, but a new style option, and that is 
> > what you want to add.
> 
> is it really better to have new forks appear, each user's own (usually 
> abandoned and unsupported), and incompatible with others?
> 
> on the other hand, clang-format has a good verification system, allowing new 
> options to be added safely.
> 
> P.S. I have 4 more new options =)

The thing is:
* That rule is written in the documentation
* It stands longer than I even know about clang-format
* You want to remove spaces after comma and colon, which we never had before, 
the space before some of those tokens is configurable, but you want to add 
something completely new
* I've never seen anyone doing something like that
* This PR will lead to 4 times the possible formatting combinations
* Which are obviously not tested

So I think it's not too much if you could at least reply to the content. I've 
never said I wouldn't accept this PR, otherwise I wouldn't have provided 
feedback.

But if you think a fork will help you, I won't stop you, and I also don't think 
it will hurt clang-format much.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-09 Thread via cfe-commits

niXman wrote:

> > Oh, I seem to have misunderstood the word "style" in the context of 
> > clang-format. I took it to mean a concrete built-in style, like LLVM, 
> > Google, Chromium, Mozilla, WebKit...
> > Am I wrong?
> 
> It's not talking about a new style, but a new style option, and that is what 
> you want to add.

is it really better to have new forks appear, each user's own (usually 
abandoned and unsupported), and incompatible with others?

on the other hand, clang-format has a good verification system, allowing new 
options to be added safely.

P.S.
I have 4 more PRs =)

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-09 Thread via cfe-commits

https://github.com/niXman updated 
https://github.com/llvm/llvm-project/pull/190657

>From 189602113f7336b9dca3f9c21e20afe834893f7c Mon Sep 17 00:00:00 2001
From: niXman 
Date: Mon, 6 Apr 2026 22:17:47 +0300
Subject: [PATCH 1/6] initial impl

---
 clang/docs/ClangFormatStyleOptions.rst | 20 
 clang/include/clang/Format/Format.h| 20 
 clang/lib/Format/Format.cpp|  6 ++
 clang/lib/Format/TokenAnnotator.cpp|  4 
 clang/unittests/Format/ConfigParseTest.cpp |  2 ++
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 6 files changed, 58 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ed4e2aaa26052..84a7569d50c27 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6678,6 +6678,26 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  class Foo : Bar {} vs. class Foo: Bar {}
 
+.. _SpaceAfterCtorInitializerColon:
+
+**SpaceAfterCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer colon.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+
+.. _SpaceAfterCtorInitializerComma:
+
+**SpaceAfterCtorInitializerComma** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer comma.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 2028c963ac306..b70b47aa6a5cb 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4955,6 +4955,22 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerColon;
+
+  /// If ``false``, spaces will be removed after constructor initializer comma.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerComma;
+
   /// If ``false``, spaces will be removed before inheritance colon.
   /// \code
   ///true:  false:
@@ -5909,6 +5925,10 @@ struct FormatStyle {
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
+   SpaceAfterCtorInitializerColon ==
+   R.SpaceAfterCtorInitializerColon &&
+   SpaceAfterCtorInitializerComma ==
+   R.SpaceAfterCtorInitializerComma &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
SpaceBeforeJsonColon == R.SpaceBeforeJsonColon &&
SpaceBeforeParens == R.SpaceBeforeParens &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f67ec86b101a..dd05f27536b07 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1374,6 +1374,10 @@ template <> struct MappingTraits {
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerColon",
+   Style.SpaceAfterCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerComma",
+   Style.SpaceAfterCtorInitializerComma);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.mapOptional("SpaceBeforeJsonColon", Style.SpaceBeforeJsonColon);
@@ -1879,6 +1883,8 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerComma = true;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeJsonColon = false;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1b588435d6302..32dcc83ce8902 100644
--- a/cla

[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-09 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks commented:

> Oh, I seem to have misunderstood the word "style" in the context of 
> clang-format. I took it to mean a concrete built-in style, like LLVM, Google, 
> Chromium, Mozilla, WebKit...
> 
> Am I wrong?

It's not talking about a new style, but a new style option, and that is what 
you want to add.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-09 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks edited 
https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-09 Thread Björn Schäpers via cfe-commits


@@ -5024,6 +5024,22 @@ struct FormatStyle {
   /// \version 3.5
   bool SpaceAfterCStyleCast;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}

HazardyKnusperkeks wrote:

```suggestion
  ///Foo::Foo() : a(a) {}   vs. Foo::Foo() :a(a) {}
```
same below.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-08 Thread via cfe-commits

https://github.com/niXman updated 
https://github.com/llvm/llvm-project/pull/190657

>From 189602113f7336b9dca3f9c21e20afe834893f7c Mon Sep 17 00:00:00 2001
From: niXman 
Date: Mon, 6 Apr 2026 22:17:47 +0300
Subject: [PATCH 1/5] initial impl

---
 clang/docs/ClangFormatStyleOptions.rst | 20 
 clang/include/clang/Format/Format.h| 20 
 clang/lib/Format/Format.cpp|  6 ++
 clang/lib/Format/TokenAnnotator.cpp|  4 
 clang/unittests/Format/ConfigParseTest.cpp |  2 ++
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 6 files changed, 58 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ed4e2aaa26052..84a7569d50c27 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6678,6 +6678,26 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  class Foo : Bar {} vs. class Foo: Bar {}
 
+.. _SpaceAfterCtorInitializerColon:
+
+**SpaceAfterCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer colon.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+
+.. _SpaceAfterCtorInitializerComma:
+
+**SpaceAfterCtorInitializerComma** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer comma.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 2028c963ac306..b70b47aa6a5cb 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4955,6 +4955,22 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerColon;
+
+  /// If ``false``, spaces will be removed after constructor initializer comma.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerComma;
+
   /// If ``false``, spaces will be removed before inheritance colon.
   /// \code
   ///true:  false:
@@ -5909,6 +5925,10 @@ struct FormatStyle {
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
+   SpaceAfterCtorInitializerColon ==
+   R.SpaceAfterCtorInitializerColon &&
+   SpaceAfterCtorInitializerComma ==
+   R.SpaceAfterCtorInitializerComma &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
SpaceBeforeJsonColon == R.SpaceBeforeJsonColon &&
SpaceBeforeParens == R.SpaceBeforeParens &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f67ec86b101a..dd05f27536b07 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1374,6 +1374,10 @@ template <> struct MappingTraits {
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerColon",
+   Style.SpaceAfterCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerComma",
+   Style.SpaceAfterCtorInitializerComma);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.mapOptional("SpaceBeforeJsonColon", Style.SpaceBeforeJsonColon);
@@ -1879,6 +1883,8 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerComma = true;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeJsonColon = false;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1b588435d6302..32dcc83ce8902 100644
--- a/cla

[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-08 Thread Björn Schäpers via cfe-commits


@@ -5549,6 +5554,8 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 return true;
   if (Right.is(TT_CtorInitializerColon))
 return Style.SpaceBeforeCtorInitializerColon;
+  if (Right.Previous->is(TT_CtorInitializerColon))

HazardyKnusperkeks wrote:

That is not what I meant... please use `Left` and move it to the other `Left` 
checks.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-08 Thread Björn Schäpers via cfe-commits


@@ -5537,6 +5537,11 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
   Left.isOneOf(TT_TrailingReturnArrow, TT_LambdaArrow)) {
 return true;
   }
+  if (Left.is(tok::comma) && Left.is(TT_CtorInitializerComma) &&
+  Right.isNot(TT_OverloadedOperatorLParen) &&
+  (Left.Children.empty() || !Left.MacroParent)) {
+return Style.SpaceAfterCtorInitializerComma;
+  }

HazardyKnusperkeks wrote:

```suggestion
  if (Left.is(TT_CtorInitializerComma))
return Style.SpaceAfterCtorInitializerComma;
```
Why do you think you need all those checks?

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-08 Thread via cfe-commits

https://github.com/niXman updated 
https://github.com/llvm/llvm-project/pull/190657

>From 189602113f7336b9dca3f9c21e20afe834893f7c Mon Sep 17 00:00:00 2001
From: niXman 
Date: Mon, 6 Apr 2026 22:17:47 +0300
Subject: [PATCH 1/4] initial impl

---
 clang/docs/ClangFormatStyleOptions.rst | 20 
 clang/include/clang/Format/Format.h| 20 
 clang/lib/Format/Format.cpp|  6 ++
 clang/lib/Format/TokenAnnotator.cpp|  4 
 clang/unittests/Format/ConfigParseTest.cpp |  2 ++
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 6 files changed, 58 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ed4e2aaa26052..84a7569d50c27 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6678,6 +6678,26 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  class Foo : Bar {} vs. class Foo: Bar {}
 
+.. _SpaceAfterCtorInitializerColon:
+
+**SpaceAfterCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer colon.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+
+.. _SpaceAfterCtorInitializerComma:
+
+**SpaceAfterCtorInitializerComma** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer comma.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 2028c963ac306..b70b47aa6a5cb 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4955,6 +4955,22 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerColon;
+
+  /// If ``false``, spaces will be removed after constructor initializer comma.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerComma;
+
   /// If ``false``, spaces will be removed before inheritance colon.
   /// \code
   ///true:  false:
@@ -5909,6 +5925,10 @@ struct FormatStyle {
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
+   SpaceAfterCtorInitializerColon ==
+   R.SpaceAfterCtorInitializerColon &&
+   SpaceAfterCtorInitializerComma ==
+   R.SpaceAfterCtorInitializerComma &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
SpaceBeforeJsonColon == R.SpaceBeforeJsonColon &&
SpaceBeforeParens == R.SpaceBeforeParens &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f67ec86b101a..dd05f27536b07 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1374,6 +1374,10 @@ template <> struct MappingTraits {
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerColon",
+   Style.SpaceAfterCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerComma",
+   Style.SpaceAfterCtorInitializerComma);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.mapOptional("SpaceBeforeJsonColon", Style.SpaceBeforeJsonColon);
@@ -1879,6 +1883,8 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerComma = true;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeJsonColon = false;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1b588435d6302..32dcc83ce8902 100644
--- a/cla

[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-08 Thread via cfe-commits

niXman wrote:

> > fixed! ping.
> 
> Not really, and there's no need for a ping.
> 
> > > Adding additional style options
> > > Each additional style option adds costs to the clang-format project. Some 
> > > of these costs affect the clang-format development itself, as we need to 
> > > make sure that any given combination of options work and that new 
> > > features don’t break any of the existing options in any way. There are 
> > > also costs for end users as options become less discoverable and people 
> > > have to think about and make a decision on options they don’t really care 
> > > about.
> > > The goal of the clang-format project is more on the side of supporting a 
> > > limited set of styles really well as opposed to supporting every single 
> > > style used by a codebase somewhere in the wild. Of course, we do want to 
> > > support all major projects and thus have established the following bar 
> > > for adding style options. Each new style option must:
> > > 
> > > * be used in a project of significant size (have dozens of contributors)
> > > * have a publicly accessible style guide
> > > * have a person willing to contribute and maintain patches
> 
> Can you at least comment on this?

Oh, I seem to have misunderstood the word "style" in the context of 
clang-format.
I took it to mean a concrete built-in style, like LLVM, Google, Chromium, 
Mozilla, WebKit...

Am I wrong?

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-08 Thread Björn Schäpers via cfe-commits


@@ -5121,6 +5121,21 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerColon;

HazardyKnusperkeks wrote:

This still stands.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-08 Thread Björn Schäpers via cfe-commits

HazardyKnusperkeks wrote:

> fixed! ping.

Not really, and there's no need for a ping.



> > Adding additional style options
> > Each additional style option adds costs to the clang-format project. Some 
> > of these costs affect the clang-format development itself, as we need to 
> > make sure that any given combination of options work and that new features 
> > don’t break any of the existing options in any way. There are also costs 
> > for end users as options become less discoverable and people have to think 
> > about and make a decision on options they don’t really care about.
> > The goal of the clang-format project is more on the side of supporting a 
> > limited set of styles really well as opposed to supporting every single 
> > style used by a codebase somewhere in the wild. Of course, we do want to 
> > support all major projects and thus have established the following bar for 
> > adding style options. Each new style option must:
> > 
> > * be used in a project of significant size (have dozens of contributors)
> > * have a publicly accessible style guide
> > * have a person willing to contribute and maintain patches

Can you at least comment on this?

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-08 Thread via cfe-commits

https://github.com/niXman updated 
https://github.com/llvm/llvm-project/pull/190657

>From 189602113f7336b9dca3f9c21e20afe834893f7c Mon Sep 17 00:00:00 2001
From: niXman 
Date: Mon, 6 Apr 2026 22:17:47 +0300
Subject: [PATCH 1/3] initial impl

---
 clang/docs/ClangFormatStyleOptions.rst | 20 
 clang/include/clang/Format/Format.h| 20 
 clang/lib/Format/Format.cpp|  6 ++
 clang/lib/Format/TokenAnnotator.cpp|  4 
 clang/unittests/Format/ConfigParseTest.cpp |  2 ++
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 6 files changed, 58 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ed4e2aaa26052..84a7569d50c27 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6678,6 +6678,26 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  class Foo : Bar {} vs. class Foo: Bar {}
 
+.. _SpaceAfterCtorInitializerColon:
+
+**SpaceAfterCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer colon.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+
+.. _SpaceAfterCtorInitializerComma:
+
+**SpaceAfterCtorInitializerComma** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer comma.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 2028c963ac306..b70b47aa6a5cb 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4955,6 +4955,22 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerColon;
+
+  /// If ``false``, spaces will be removed after constructor initializer comma.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerComma;
+
   /// If ``false``, spaces will be removed before inheritance colon.
   /// \code
   ///true:  false:
@@ -5909,6 +5925,10 @@ struct FormatStyle {
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
+   SpaceAfterCtorInitializerColon ==
+   R.SpaceAfterCtorInitializerColon &&
+   SpaceAfterCtorInitializerComma ==
+   R.SpaceAfterCtorInitializerComma &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
SpaceBeforeJsonColon == R.SpaceBeforeJsonColon &&
SpaceBeforeParens == R.SpaceBeforeParens &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f67ec86b101a..dd05f27536b07 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1374,6 +1374,10 @@ template <> struct MappingTraits {
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerColon",
+   Style.SpaceAfterCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerComma",
+   Style.SpaceAfterCtorInitializerComma);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.mapOptional("SpaceBeforeJsonColon", Style.SpaceBeforeJsonColon);
@@ -1879,6 +1883,8 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerComma = true;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeJsonColon = false;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1b588435d6302..32dcc83ce8902 100644
--- a/cla

[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-08 Thread via cfe-commits

niXman wrote:

fixed!
ping.


https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-07 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- 
clang/include/clang/Format/Format.h clang/lib/Format/Format.cpp 
clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/ConfigParseTest.cpp 
clang/unittests/Format/FormatTest.cpp --diff_from_common_commit
``

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index f69ea31b3..cf34b87ae 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -6099,10 +6099,8 @@ struct FormatStyle {
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
-   SpaceAfterCtorInitializerColon ==
-   R.SpaceAfterCtorInitializerColon &&
-   SpaceAfterCtorInitializerComma ==
-   R.SpaceAfterCtorInitializerComma &&
+   SpaceAfterCtorInitializerColon == R.SpaceAfterCtorInitializerColon 
&&
+   SpaceAfterCtorInitializerComma == R.SpaceAfterCtorInitializerComma 
&&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
SpaceBeforeJsonColon == R.SpaceBeforeJsonColon &&
SpaceBeforeParens == R.SpaceBeforeParens &&

``




https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-07 Thread via cfe-commits

github-actions[bot] wrote:


# :penguin: Linux x64 Test Results

* 87242 tests passed
* 1375 tests skipped
* 1 test failed

## Failed Tests
(click on a test name to see its output)

### Clang

Clang.Format/docs_updated.test

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
"/usr/bin/python3" 
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Format/../../docs/tools/dump_format_style.py
 -o 
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Format/Output/docs_updated.test.tmp.style
# executed command: /usr/bin/python3 
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Format/../../docs/tools/dump_format_style.py
 -o 
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Format/Output/docs_updated.test.tmp.style
# note: command had no output on stdout or stderr
# RUN: at line 2
diff --strip-trailing-cr 
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Format/Output/docs_updated.test.tmp.style

/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Format/../../docs/ClangFormatStyleOptions.rst
# executed command: diff --strip-trailing-cr 
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Format/Output/docs_updated.test.tmp.style
 
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Format/../../docs/ClangFormatStyleOptions.rst
# .---command stdout
# | *** 
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Format/Output/docs_updated.test.tmp.style
# | --- 
/home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Format/../../docs/ClangFormatStyleOptions.rst
# | ***
# | *** 6711,6736 
# |true:  false:
# |(int) i;   vs. (int)i;
# |   
# | - .. _SpaceAfterCtorInitializerColon:
# | - 
# | - **SpaceAfterCtorInitializerColon** (``Boolean``) 
:versionbadge:`clang-format 22` :ref:`¶ `
# | -   If ``false``, spaces will be removed after constructor initializer 
colon.
# | - 
# | -   .. code-block:: c++
# | - 
# | -  true:  false:
# | -  Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
# | - 
# | - .. _SpaceAfterCtorInitializerComma:
# | - 
# | - **SpaceAfterCtorInitializerComma** (``Boolean``) 
:versionbadge:`clang-format 22` :ref:`¶ `
# | -   If ``false``, spaces will be removed after constructor initializer 
comma.
# | - 
# | -   .. code-block:: c++
# | - 
# | -  true:  false:
# | -  Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
# | - 
# |   .. _SpaceAfterLogicalNot:
# |   
# |   **SpaceAfterLogicalNot** (``Boolean``) :versionbadge:`clang-format 9` 
:ref:`¶ `
# | --- 6711,6716 
# | ***
# | *** 6870,6875 
# | --- 6850,6875 
# |   
# |true:  false:
# |class Foo : Bar {} vs. class Foo: Bar {}
# | + 
# | + .. _SpaceAfterCtorInitializerColon:
# | + 
# | + **SpaceAfterCtorInitializerColon** (``Boolean``) 
:versionbadge:`clang-format 22` :ref:`¶ `
# | +   If ``false``, spaces will be removed after constructor initializer 
colon.
# | + 
# | +   .. code-block:: c++
# | + 
# | +  true:  false:
# | +  Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
# | + 
# | + .. _SpaceAfterCtorInitializerComma:
# | + 
# | + **SpaceAfterCtorInitializerComma** (``Boolean``) 
:versionbadge:`clang-format 22` :ref:`¶ `
# | +   If ``false``, spaces will be removed after constructor initializer 
comma.
# | + 
# | +   .. code-block:: c++
# | + 
# | +  true:  false:
# | +  Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
# |   
# |   .. _SpaceBeforeJsonColon:
# |   
# `-
# error: command failed with exit status: 1

--

```


If these failures are unrelated to your changes (for example tests are broken 
or flaky at HEAD), please open an issue at 
https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-07 Thread via cfe-commits

github-actions[bot] wrote:


# :window: Windows x64 Test Results

* 53500 tests passed
* 1070 tests skipped
* 1 test failed

## Failed Tests
(click on a test name to see its output)

### Clang

Clang.Format/docs_updated.test

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
"C:\Python312\python.exe" 
C:\_work\llvm-project\llvm-project\clang\test\Format/../../docs/tools/dump_format_style.py
 -o 
C:\_work\llvm-project\llvm-project\build\tools\clang\test\Format\Output\docs_updated.test.tmp.style
# executed command: 'C:\Python312\python.exe' 
'C:\_work\llvm-project\llvm-project\clang\test\Format/../../docs/tools/dump_format_style.py'
 -o 
'C:\_work\llvm-project\llvm-project\build\tools\clang\test\Format\Output\docs_updated.test.tmp.style'
# note: command had no output on stdout or stderr
# RUN: at line 2
diff --strip-trailing-cr 
C:\_work\llvm-project\llvm-project\build\tools\clang\test\Format\Output\docs_updated.test.tmp.style

C:\_work\llvm-project\llvm-project\clang\test\Format/../../docs/ClangFormatStyleOptions.rst
# executed command: diff --strip-trailing-cr 
'C:\_work\llvm-project\llvm-project\build\tools\clang\test\Format\Output\docs_updated.test.tmp.style'
 
'C:\_work\llvm-project\llvm-project\clang\test\Format/../../docs/ClangFormatStyleOptions.rst'
# .---command stdout
# | *** 
C:\_work\llvm-project\llvm-project\build\tools\clang\test\Format\Output\docs_updated.test.tmp.style
# | --- 
C:\_work\llvm-project\llvm-project\clang\test\Format/../../docs/ClangFormatStyleOptions.rst
# | ***
# | *** 6711,6736 
# |true:  false:
# |(int) i;   vs. (int)i;
# |   
# | - .. _SpaceAfterCtorInitializerColon:
# | - 
# | - **SpaceAfterCtorInitializerColon** (``Boolean``) 
:versionbadge:`clang-format 22` :ref:`¶ `
# | -   If ``false``, spaces will be removed after constructor initializer 
colon.
# | - 
# | -   .. code-block:: c++
# | - 
# | -  true:  false:
# | -  Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
# | - 
# | - .. _SpaceAfterCtorInitializerComma:
# | - 
# | - **SpaceAfterCtorInitializerComma** (``Boolean``) 
:versionbadge:`clang-format 22` :ref:`¶ `
# | -   If ``false``, spaces will be removed after constructor initializer 
comma.
# | - 
# | -   .. code-block:: c++
# | - 
# | -  true:  false:
# | -  Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
# | - 
# |   .. _SpaceAfterLogicalNot:
# |   
# |   **SpaceAfterLogicalNot** (``Boolean``) :versionbadge:`clang-format 9` 
:ref:`¶ `
# | --- 6711,6716 
# | ***
# | *** 6870,6875 
# | --- 6850,6875 
# |   
# |true:  false:
# |class Foo : Bar {} vs. class Foo: Bar {}
# | + 
# | + .. _SpaceAfterCtorInitializerColon:
# | + 
# | + **SpaceAfterCtorInitializerColon** (``Boolean``) 
:versionbadge:`clang-format 22` :ref:`¶ `
# | +   If ``false``, spaces will be removed after constructor initializer 
colon.
# | + 
# | +   .. code-block:: c++
# | + 
# | +  true:  false:
# | +  Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
# | + 
# | + .. _SpaceAfterCtorInitializerComma:
# | + 
# | + **SpaceAfterCtorInitializerComma** (``Boolean``) 
:versionbadge:`clang-format 22` :ref:`¶ `
# | +   If ``false``, spaces will be removed after constructor initializer 
comma.
# | + 
# | +   .. code-block:: c++
# | + 
# | +  true:  false:
# | +  Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
# |   
# |   .. _SpaceBeforeJsonColon:
# |   
# `-
# error: command failed with exit status: 1

--

```


If these failures are unrelated to your changes (for example tests are broken 
or flaky at HEAD), please open an issue at 
https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-07 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks edited 
https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-07 Thread Björn Schäpers via cfe-commits


@@ -5121,6 +5121,21 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerColon;

HazardyKnusperkeks wrote:

Please sort (here and everywhere else in `Format.h|cpp`) alphabetically.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-07 Thread Björn Schäpers via cfe-commits


@@ -5549,6 +5551,8 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 return true;
   if (Right.is(TT_CtorInitializerColon))
 return Style.SpaceBeforeCtorInitializerColon;
+  if (Left.is(TT_CtorInitializerColon))

HazardyKnusperkeks wrote:

All checks here are for `Right` don't mix it with putting the `Left` check here.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-07 Thread Björn Schäpers via cfe-commits


@@ -5541,6 +5541,8 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
   // In an unexpanded macro call we only find the parentheses and commas
   // in a line; the commas and closing parenthesis do not require a space.
   (Left.Children.empty() || !Left.MacroParent)) {
+if (Left.is(TT_CtorInitializerComma))

HazardyKnusperkeks wrote:

I don't think you should be in this if.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-07 Thread Björn Schäpers via cfe-commits

https://github.com/HazardyKnusperkeks commented:

> Adding additional style options
> 
> Each additional style option adds costs to the clang-format project. Some of 
> these costs affect the clang-format development itself, as we need to make 
> sure that any given combination of options work and that new features don’t 
> break any of the existing options in any way. There are also costs for end 
> users as options become less discoverable and people have to think about and 
> make a decision on options they don’t really care about.
> 
> The goal of the clang-format project is more on the side of supporting a 
> limited set of styles really well as opposed to supporting every single style 
> used by a codebase somewhere in the wild. Of course, we do want to support 
> all major projects and thus have established the following bar for adding 
> style options. Each new style option must:
> 
>  * be used in a project of significant size (have dozens of contributors)
>  * have a publicly accessible style guide
>  * have a person willing to contribute and maintain patches


https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-07 Thread Björn Schäpers via cfe-commits


@@ -5121,6 +5121,21 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22

HazardyKnusperkeks wrote:

```suggestion
  /// \version 23
```
22 is already shipped.

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-06 Thread via cfe-commits

https://github.com/niXman updated 
https://github.com/llvm/llvm-project/pull/190657

>From 189602113f7336b9dca3f9c21e20afe834893f7c Mon Sep 17 00:00:00 2001
From: niXman 
Date: Mon, 6 Apr 2026 22:17:47 +0300
Subject: [PATCH] initial impl

---
 clang/docs/ClangFormatStyleOptions.rst | 20 
 clang/include/clang/Format/Format.h| 20 
 clang/lib/Format/Format.cpp|  6 ++
 clang/lib/Format/TokenAnnotator.cpp|  4 
 clang/unittests/Format/ConfigParseTest.cpp |  2 ++
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 6 files changed, 58 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ed4e2aaa26052..84a7569d50c27 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6678,6 +6678,26 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  class Foo : Bar {} vs. class Foo: Bar {}
 
+.. _SpaceAfterCtorInitializerColon:
+
+**SpaceAfterCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer colon.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+
+.. _SpaceAfterCtorInitializerComma:
+
+**SpaceAfterCtorInitializerComma** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer comma.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 2028c963ac306..b70b47aa6a5cb 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4955,6 +4955,22 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerColon;
+
+  /// If ``false``, spaces will be removed after constructor initializer comma.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerComma;
+
   /// If ``false``, spaces will be removed before inheritance colon.
   /// \code
   ///true:  false:
@@ -5909,6 +5925,10 @@ struct FormatStyle {
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
+   SpaceAfterCtorInitializerColon ==
+   R.SpaceAfterCtorInitializerColon &&
+   SpaceAfterCtorInitializerComma ==
+   R.SpaceAfterCtorInitializerComma &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
SpaceBeforeJsonColon == R.SpaceBeforeJsonColon &&
SpaceBeforeParens == R.SpaceBeforeParens &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f67ec86b101a..dd05f27536b07 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1374,6 +1374,10 @@ template <> struct MappingTraits {
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerColon",
+   Style.SpaceAfterCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerComma",
+   Style.SpaceAfterCtorInitializerComma);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.mapOptional("SpaceBeforeJsonColon", Style.SpaceBeforeJsonColon);
@@ -1879,6 +1883,8 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerColon = true;
+  LLVMStyle.SpaceAfterCtorInitializerComma = true;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeJsonColon = false;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 1b588435d6302..32dcc83ce8902 100644
--- a/clang/l

[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: niXman (niXman)


Changes

This fix adds two new clang-format style options to control spacing after 
constructor initializer punctuation:

- SpaceAfterCtorInitializerColon
- SpaceAfterCtorInitializerComma

These options complement existing `SpaceBeforeCtorInitializerColon` and allow 
formatting styles such as `:prev` and `,next`.

New Behavior
1) `SpaceAfterCtorInitializerColon`
Controls whether a space is inserted after the constructor initializer colon 
(`:`).

2) `SpaceAfterCtorInitializerComma`
Controls whether a space is inserted after commas inside constructor 
initializer lists.

Default values are true for both options (backward-compatible behavior).

Input:
```
struct X {
  X()
  :   prev{nullptr}
  , next{nullptr} {}
};
```
Result:
```
struct X {
  X()
  :prev{nullptr}
  ,next{nullptr} {}
};
```


---
Full diff: https://github.com/llvm/llvm-project/pull/190657.diff


6 Files Affected:

- (modified) clang/docs/ClangFormatStyleOptions.rst (+20) 
- (modified) clang/include/clang/Format/Format.h (+20) 
- (modified) clang/lib/Format/Format.cpp (+6) 
- (modified) clang/lib/Format/TokenAnnotator.cpp (+4) 
- (modified) clang/unittests/Format/ConfigParseTest.cpp (+2) 
- (modified) clang/unittests/Format/FormatTest.cpp (+6) 


``diff
diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ed4e2aaa26052..84a7569d50c27 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6678,6 +6678,26 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  class Foo : Bar {} vs. class Foo: Bar {}
 
+.. _SpaceAfterCtorInitializerColon:
+
+**SpaceAfterCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer colon.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+
+.. _SpaceAfterCtorInitializerComma:
+
+**SpaceAfterCtorInitializerComma** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer comma.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 2028c963ac306..b70b47aa6a5cb 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4955,6 +4955,22 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerColon;
+
+  /// If ``false``, spaces will be removed after constructor initializer comma.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerComma;
+
   /// If ``false``, spaces will be removed before inheritance colon.
   /// \code
   ///true:  false:
@@ -5909,6 +5925,10 @@ struct FormatStyle {
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
+   SpaceAfterCtorInitializerColon ==
+   R.SpaceAfterCtorInitializerColon &&
+   SpaceAfterCtorInitializerComma ==
+   R.SpaceAfterCtorInitializerComma &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
SpaceBeforeJsonColon == R.SpaceBeforeJsonColon &&
SpaceBeforeParens == R.SpaceBeforeParens &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f67ec86b101a..dd05f27536b07 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1374,6 +1374,10 @@ template <> struct MappingTraits {
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerColon",
+   Style.SpaceAfterCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerComma",
+   Style.SpaceAfterCtorInitializerComma);
 IO.mapOptional("SpaceBeforeInheritanceColon",
Style.SpaceBeforeInheritanceColon);
 IO.m

[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-06 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/190657
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] No spaces after colon and comma in initializer list (PR #190657)

2026-04-06 Thread via cfe-commits

https://github.com/niXman created 
https://github.com/llvm/llvm-project/pull/190657

This fix adds two new clang-format style options to control spacing after 
constructor initializer punctuation:

- SpaceAfterCtorInitializerColon
- SpaceAfterCtorInitializerComma

These options complement existing `SpaceBeforeCtorInitializerColon` and allow 
formatting styles such as `:prev` and `,next`.

New Behavior
1) `SpaceAfterCtorInitializerColon`
Controls whether a space is inserted after the constructor initializer colon 
(`:`).

2) `SpaceAfterCtorInitializerComma`
Controls whether a space is inserted after commas inside constructor 
initializer lists.

Default values are true for both options (backward-compatible behavior).

Input:
```
struct X {
  X()
  :   prev{nullptr}
  , next{nullptr} {}
};
```
Result:
```
struct X {
  X()
  :prev{nullptr}
  ,next{nullptr} {}
};
```


>From 189602113f7336b9dca3f9c21e20afe834893f7c Mon Sep 17 00:00:00 2001
From: niXman 
Date: Mon, 6 Apr 2026 22:17:47 +0300
Subject: [PATCH] initial impl

---
 clang/docs/ClangFormatStyleOptions.rst | 20 
 clang/include/clang/Format/Format.h| 20 
 clang/lib/Format/Format.cpp|  6 ++
 clang/lib/Format/TokenAnnotator.cpp|  4 
 clang/unittests/Format/ConfigParseTest.cpp |  2 ++
 clang/unittests/Format/FormatTest.cpp  |  6 ++
 6 files changed, 58 insertions(+)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ed4e2aaa26052..84a7569d50c27 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6678,6 +6678,26 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  class Foo : Bar {} vs. class Foo: Bar {}
 
+.. _SpaceAfterCtorInitializerColon:
+
+**SpaceAfterCtorInitializerColon** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer colon.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+
+.. _SpaceAfterCtorInitializerComma:
+
+**SpaceAfterCtorInitializerComma** (``Boolean``) :versionbadge:`clang-format 
22` :ref:`¶ `
+  If ``false``, spaces will be removed after constructor initializer comma.
+
+  .. code-block:: c++
+
+ true:  false:
+ Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 2028c963ac306..b70b47aa6a5cb 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4955,6 +4955,22 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeCtorInitializerColon;
 
+  /// If ``false``, spaces will be removed after constructor initializer colon.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a) {}   Foo::Foo() :a(a) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerColon;
+
+  /// If ``false``, spaces will be removed after constructor initializer comma.
+  /// \code
+  ///true:  false:
+  ///Foo::Foo() : a(a), b(b) {} Foo::Foo() : a(a),b(b) {}
+  /// \endcode
+  /// \version 22
+  bool SpaceAfterCtorInitializerComma;
+
   /// If ``false``, spaces will be removed before inheritance colon.
   /// \code
   ///true:  false:
@@ -5909,6 +5925,10 @@ struct FormatStyle {
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&
+   SpaceAfterCtorInitializerColon ==
+   R.SpaceAfterCtorInitializerColon &&
+   SpaceAfterCtorInitializerComma ==
+   R.SpaceAfterCtorInitializerComma &&
SpaceBeforeInheritanceColon == R.SpaceBeforeInheritanceColon &&
SpaceBeforeJsonColon == R.SpaceBeforeJsonColon &&
SpaceBeforeParens == R.SpaceBeforeParens &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2f67ec86b101a..dd05f27536b07 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1374,6 +1374,10 @@ template <> struct MappingTraits {
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
Style.SpaceBeforeCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerColon",
+   Style.SpaceAfterCtorInitializerColon);
+IO.mapOptional("SpaceAfterCtorInitializerComma",
+   Style.SpaceAfterCtorInitializerComma);
 IO.map