<div dir="ltr">Just to be sure, you would find<div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">double x[][] = { {</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">  1.12345</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">} }</span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">More readable than</span></div>
<div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><div><span style="font-family:arial,sans-serif;font-size:13px">double x[][] = {</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">  { 1.12345 </span><span style="font-family:arial,sans-serif;font-size:13px">}</span></div><div><span style="font-family:arial,sans-serif;font-size:13px">}</span><br>
</div><div><br></div><div><font face="arial, sans-serif">?</font></div><div><font face="arial, sans-serif"><br></font></div><div style><font face="arial, sans-serif">I am just asking because I don't agree at all :-). Especially if you start adding elements:</font></div>
<div style><font face="arial, sans-serif"><br></font></div><div style><div><span style="font-family:arial,sans-serif;font-size:13px">double x[][] = {</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">  { 1.12345 </span><span style="font-family:arial,sans-serif;font-size:13px">}, </span><span style="font-size:13px;font-family:arial,sans-serif">{ 1.12345 </span><span style="font-size:13px;font-family:arial,sans-serif">}, ...</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">}</span></div></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">As mentioned in the change description, this change basically does not modify the behavior (except in some very rare edge case). Your example would have been formatted identically before and after the change. However, we are currently investigating how to get some kind of consistency into all the different formattings that can now be created with C++11's braced-init-lists. Once we have a reasonably complete proposal, I will post that somewhere.</span></div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 17, 2013 at 6:09 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yeah, I actually find<br>
<br>
double x[] = {<br>
        1.12345<br>
}<br>
<br>
to be more readable than<br>
<br>
double x[] =<br>
        { 1.12345 }<br>
<br>
and I feel like that last example is basically the same.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On May 17, 2013, at 2:35 , Daniel Jasper <<a href="mailto:djasper@google.com">djasper@google.com</a>> wrote:<br>
<br>
> Author: djasper<br>
> Date: Fri May 17 04:35:01 2013<br>
> New Revision: 182082<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=182082&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=182082&view=rev</a><br>
> Log:<br>
> Slightly modify the formatting rules for braced lists.<br>
><br>
> Basically, the new rule is: The opening "{" always has to be on the<br>
> same line as the first element if the braced list is nested<br>
> (e.g. in another braced list or in a function).<br>
><br>
> The solution that clang-format produces almost always adheres to this<br>
> rule anyway and this makes clang-format significantly faster for larger<br>
> lists. Added a test cases for the only exception I could find<br>
> (which doesn't seem to be very important at first sight).<br>
><br>
> Modified:<br>
>    cfe/trunk/lib/Format/Format.cpp<br>
>    cfe/trunk/unittests/Format/FormatTest.cpp<br>
><br>
> Modified: cfe/trunk/lib/Format/Format.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=182082&r1=182081&r2=182082&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=182082&r1=182081&r2=182082&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Format/Format.cpp (original)<br>
> +++ cfe/trunk/lib/Format/Format.cpp Fri May 17 04:35:01 2013<br>
> @@ -977,10 +977,18 @@ private:<br>
><br>
>   /// \brief Returns \c true, if a line break after \p State is allowed.<br>
>   bool canBreak(const LineState &State) {<br>
> -    if (!State.NextToken->CanBreakBefore &&<br>
> -        !(State.NextToken->is(tok::r_brace) &&<br>
> +    const AnnotatedToken &Current = *State.NextToken;<br>
> +    const AnnotatedToken &Previous = *Current.Parent;<br>
> +    if (!Current.CanBreakBefore &&<br>
> +        !(Current.is(tok::r_brace) &&<br>
>           State.Stack.back().BreakBeforeClosingBrace))<br>
>       return false;<br>
> +    // The opening "{" of a braced list has to be on the same line as the first<br>
> +    // element if it is nested in another braced init list or function call.<br>
> +    if (!Current.MustBreakBefore && Previous.is(tok::l_brace) &&<br>
> +        Previous.Parent &&<br>
> +        Previous.Parent->isOneOf(tok::l_brace, tok::l_paren, tok::comma))<br>
> +      return false;<br>
>     return !State.Stack.back().NoLineBreak;<br>
>   }<br>
><br>
><br>
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182082&r1=182081&r2=182082&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182082&r1=182081&r2=182082&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Fri May 17 04:35:01 2013<br>
> @@ -1192,6 +1192,18 @@ TEST_F(FormatTest, StaticInitializers) {<br>
>       "static SomeClass = { a, b, c, d, e, f, g, h, i, j,\n"<br>
>       "                     looooooooooooooooooooooooooooooooooongname,\n"<br>
>       "                     looooooooooooooooooooooooooooooong };");<br>
> +  // Here, everything other than the "}" would fit on a line.<br>
> +  verifyFormat("static int LooooooooooooooooooooooooongVariable[1] = {\n"<br>
> +               "  100000000000000000000000\n"<br>
> +               "};");<br>
> +<br>
> +  // FIXME: This would fit into the column limit if we'd fit "{ {" on the first<br>
> +  // line. However, the formatting looks a bit off and this probably doesn't<br>
> +  // happen often in practice.<br>
> +  verifyFormat("static int Variable[1] = {\n"<br>
> +               "  { 1000000000000000000000000000000000000 }\n"<br>
> +               "};",<br>
> +               getLLVMStyleWithColumns(40));<br>
> }<br>
><br>
> TEST_F(FormatTest, NestedStaticInitializers) {<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br>
</div></div></blockquote></div><br></div>