[clang] [clang-format] Option to Ignore Trailing Comment Length to AlignConsecutive (PR #190668)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 7 13:53:45 PDT 2026


================
@@ -1913,6 +1913,229 @@ TEST_F(AlignmentTest, ConsecutiveDeclarations) {
                "void f2(void);\n"
                "size_t f3(void);",
                Alignment);
+
+  Style = getLLVMStyleWithColumns(47);
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+  verifyFormat("int a = 3; // a long trailing comment\n"
+               "int b = 4; // short comment 1\n"
+               "AReallyLongTypeName c = 5; // short comment 2\n",
+               Style);
+
+  Style.AlignConsecutiveDeclarations.IgnoreTrailingCommentLength = true;
+  verifyFormat("int                 a = 3; // a long trailing comment\n"
+               "int                 b = 4; // short comment 1\n"
+               "AReallyLongTypeName c = 5; // short comment 2\n",
+               Style);
+
+  Style = getLLVMStyleWithColumns(120);
----------------
HazardyKnusperkeks wrote:

Does it have to be 120? If yes, please use `// clang-format off` and show the actual line breaks.
Also I think it would be nice to reduce the test content a bit.

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


More information about the cfe-commits mailing list