================
@@ -1429,6 +1429,37 @@ TEST_F(FormatTestComments, CommentsInStaticInitializers) 
{
                "    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment\n"
                "    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment\n"
                "    0x00, 0x00, 0x00, 0x00};            // comment");
+
+  // The usual 'open brace with trailing comment' behaviour is to forcibly
+  // break the trailing comment onto onto a new line -
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  StringRef Input = "int a[2][2] = {\n"
+                    "    { // a\n"
+                    "        0, // x\n"
+                    "        1,\n"
+                    "    },\n"
+                    "    {\n"
+                    "        2,\n"
+                    "        3, // y\n"
+                    "    }\n"
+                    "};";
+  verifyFormat("int a[2][2] = {\n"
+               "    {\n"
+               "        // a\n"
+               "        0, // x\n"
+               "        1,\n"
+               "    },\n"
+               "    {\n"
+               "        2,\n"
+               "        3, // y\n"
+               "    }\n"
+               "};",
+               Input, Style);
+  // But, especially for nested, multi-dimensional initialization, allowing
+  // open braces with trailing comments can be desirable -
----------------
GertyP wrote:

Thanks.

"... -" is something I use to more explicitly link the comment to the lines 
that immediately follow (as opposed to anything before the comment), so it 
becomes more synonymous with "..., thus".

It hadn't occured to me that this could be misinterpreted or queried... until 
now, so I don't have a problem replacing the '-' with a '.'.

https://github.com/llvm/llvm-project/pull/89956
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to