[clang] [clang-format] Remove special handling of comments after brace/paren (PR #71672)

via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 6 14:23:49 PDT 2025


================
@@ -1474,12 +1474,12 @@ TEST_F(FormatTestComments, CommentsInStaticInitializers) {
   verifyFormat("S s = {{a, b, c},  // Group #1\n"
                "       {d, e, f},  // Group #2\n"
                "       {g, h, i}}; // Group #3");
-  verifyFormat("S s = {{// Group #1\n"
-               "        a, b, c},\n"
-               "       {// Group #2\n"
-               "        d, e, f},\n"
-               "       {// Group #3\n"
-               "        g, h, i}};");
+  verifyFormat("S s = {{ // Group #1\n"
+               "         a, b, c},\n"
----------------
sstwcw wrote:

I don't see why this line should have the extra space added.  The patch removes special handling of the comment on the previous line.  If the previous line is not a comment, this line will not have the extra space.

If the comment is for what comes before it like discussed in the bug report, then this line does not have to be aligned to the comment.

Oh by the way, why did this patch take so long?

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


More information about the cfe-commits mailing list