<div dir="ltr">I see. Is that part of some public coding style or just how you'd like things formatted? I didn't find any reference to this in the GNU Coding Standards (<a href="http://www.gnu.org/prep/standards/standards.html#Formatting">http://www.gnu.org/prep/standards/standards.html#Formatting</a>).<div>
<br></div><div>Generally, these are braced initializers and they are treated very differently from braces of function/class definitions or blocks. This is for good reason, especially with regard to the various braced initializers that C++11 offers.</div>
<div><br></div><div>A crude hack to get the behavior your are desiring is:</div><div><br></div><div><div>diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp</div><div>index ed6938f..a13568b 100644</div>
<div>--- a/lib/Format/TokenAnnotator.cpp</div><div>+++ b/lib/Format/TokenAnnotator.cpp</div><div>@@ -1650,6 +1650,8 @@ static bool isAllmanBrace(const FormatToken &Tok) {</div><div> bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,</div>
<div> const FormatToken &Right) {</div><div> const FormatToken &Left = *Right.Previous;</div><div>+ if (Right.is(tok::l_brace) && Right.BlockKind == BK_BracedInit)</div>
<div>+ return true;</div><div> if (Right.NewlinesBefore > 1)</div><div> return true;</div><div> if (Right.is(tok::comment)) {</div></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Tue, Aug 5, 2014 at 2:58 PM, Martin Liška <span dir="ltr"><<a href="mailto:mliska@suse.cz" target="_blank">mliska@suse.cz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class=""><br>
On 08/05/2014 01:37 PM, Daniel Jasper wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Could you be more specific about what clang-format currently doesn't do to your liking?<br>
</blockquote>
<br></div>
Sure,<br>
I attached a test case, where clang-format -style=gnu produces:<br>
<br>
struct s<br>
{<br>
int a;<br>
int b;<br>
int c;<br>
};<br>
<br>
static struct s ss = {<br>
my interest-----------^<br>
22222222, /* First value. */<br>
33333333, /* Second value. */<br>
44444444 /* Third value. */<br>
};<br>
<br>
int<br>
main ()<br>
{<br>
return ss.c;<br>
}<br>
<br>
Where I would like to expect:<br>
s ss =<br>
{<br>
...<br>
<br>
<br>
Thats my motivation,<br>
thank you,<br>
Martin<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
<br>
<br>
On Tue, Aug 5, 2014 at 2:27 PM, Martin Liška <<a href="mailto:mliska@suse.cz" target="_blank">mliska@suse.cz</a> <mailto:<a href="mailto:mliska@suse.cz" target="_blank">mliska@suse.cz</a>>> wrote:<br>
<br>
Hello,<br>
I would like to implement support for braces for struct inialization like:<br>
<br>
|address temp_addres= {<br>
0, // street_no<br>
nullptr, // street_name<br>
"Hamilton", // city<br>
"Ontario", // prov<br>
nullptr, // postal_code<br>
};<br>
|<br>
<br>
<br>
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?<br>
<br>
Thanks,<br>
Martin<br>
*<br>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br></div>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a> <mailto:<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a>><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
<br>
<br>
</blockquote>
<br>
</blockquote></div><br></div>