[cfe-dev] clang-format support for braces in struct initialization

Martin Liška mliska at suse.cz
Tue Aug 5 05:58:06 PDT 2014


On 08/05/2014 01:37 PM, Daniel Jasper wrote:
> Could you be more specific about what clang-format currently doesn't do to your liking?

Sure,
    I attached a test case, where clang-format -style=gnu produces:

struct s
{
   int a;
   int b;
   int c;
};

static struct s ss = {
my interest-----------^
   22222222, /* First value.  */
   33333333, /* Second value.  */
   44444444  /* Third value.  */
};

int
main ()
{
   return ss.c;
}

Where I would like to expect:
s ss =
{
...


Thats my motivation,
thank you,
Martin
>
>
> On Tue, Aug 5, 2014 at 2:27 PM, Martin Liška <mliska at suse.cz <mailto:mliska at suse.cz>> wrote:
>
>     Hello,
>        I would like to implement support for braces for struct inialization like:
>
>     |address temp_addres=  {
>       0,   // street_no
>       nullptr,   // street_name
>       "Hamilton",   // city
>       "Ontario",   // prov
>       nullptr,   // postal_code
>     };
>     |
>
>
>     My interest is to control if the brace after equation should be placed to a separate line or not (controlled by *BreakBeforeBraces). I tried to read UnwrappedLineParser, but don't know how to identify such a context?
>
>     Thanks,
>     Martin
>     *
>     _______________________________________________
>     cfe-dev mailing list
>     cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
>     http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: struct.c
Type: text/x-csrc
Size: 195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140805/cbe138e7/attachment.c>


More information about the cfe-dev mailing list