================
@@ -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;
+
+ verifyNoChange("void f() {\n"
+ " int a = 0; /* e */\n"
+ "}\n"
+ "/* c */\n"
+ "void g() {\n"
+ " int b = 1; /* f */\n"
+ " int abcd = 2; /* g */\n"
+ "}",
+ Style);
+
+ // OverEmptyLines should not align trailing comments across block boundaries
+ // even without an intervening comment separator.
+ verifyNoChange("void f() {\n"
----------------
owenca wrote:
```suggestion
verifyFormat("void f() {\n"
```
https://github.com/llvm/llvm-project/pull/208324
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits