[clang] [clang-format] Break trailing comment alignment at non-trailing comments (PR #208324)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 18 00:01:21 PDT 2026
================
@@ -3007,6 +3007,130 @@ TEST_F(FormatTestComments, AlignTrailingCommentsAcrossEmptyLines) {
Style);
}
+TEST_F(FormatTestComments, NonTrailingCommentBreaksAlignment) {
+ // Regression test for https://llvm.org/PR208266
+ FormatStyle Style = getGoogleStyle(FormatStyle::LK_Proto);
+ Style.AlignConsecutiveAssignments.Enabled = true;
+ Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Always;
+ Style.AlignTrailingComments.OverEmptyLines = 4;
+ Style.ColumnLimit = 0;
+
+ verifyNoChange("enum E {\n"
+ " A = 0; /* e */\n"
+ "}\n"
+ "/* c */\n"
+ "message M {\n"
+ " int32 a = 1; /* f */\n"
+ " int32 abcd = 2; /* g */\n"
+ "}",
+ Style);
+
+ Style = getLLVMStyle();
+ Style.AlignConsecutiveAssignments.Enabled = true;
+ Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Always;
+ Style.AlignTrailingComments.OverEmptyLines = 4;
+ Style.ColumnLimit = 0;
----------------
owenca wrote:
```suggestion
auto Style = getLLVMStyle();
EXPECT_EQ(Style.AlignTrailingComments.Kind, FormatStyle::TCAS_Always);
Style.AlignTrailingComments.OverEmptyLines = 2;
```
https://github.com/llvm/llvm-project/pull/208324
More information about the cfe-commits
mailing list