[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

Anastasiia Lukianenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 09:33:34 PST 2020


anastasiia_lukianenko added inline comments.


================
Comment at: clang/lib/Format/Format.cpp:893
                              /*BeforeLambdaBody=*/false,
+                             /*BeforeStructInitialization=*/false,
                              /*BeforeWhile=*/false,
----------------
MyDeveloperDay wrote:
> I believe there are 3 places where BraceWrapping is initialized you seem to only be doing 2 of them
Sorry, I didn't find one more place. Can you please say where it is?


================
Comment at: clang/unittests/Format/FormatTest.cpp:5063
+               "    a = 1,\n"
+               "    b = 2,\n"
+               "};",
----------------
MyDeveloperDay wrote:
> could you add an additional test without the trailing `,`
Yes, I can add the test, but before I want to discuss the expected result.
Now with my patch and BeforeStructInitialization = false the behavior is the following:

```
struct new_struct struct_name = {a = 1};
struct new_struct struct_name = {a = 1, b = 2};
```
And with BeforeStructInitialization = true:

```
struct new_struct struct_name =
{a = 1};
struct new_struct struct_name =
{a = 1, b = 2};
```
Is it okay?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91949/new/

https://reviews.llvm.org/D91949



More information about the cfe-commits mailing list