[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:
I can't make out if there are tests like your description where the comment has been reflown and then shifted. That should also be mentioned in the option description, very clearly, otherwise there will be bug reports.
https://github.com/llvm/llvm-project/pull/190668
More information about the cfe-commits
mailing list