<div dir="ltr">This patch adds a new option "AllowSimpleBracedStatements" that allows braced statements to be considered as "simple". That is, if AllowShortIfStatementsOnASingleLine and AllowShortLoopStatementsOnASingle line are enabled, code like:<div>

<br></div><div>if (true) {</div><div>  f();</div><div>}</div><div><br></div><div>can be wrapped into a single line as:</div><div><br></div><div>if (true) { f(); }</div><div><br></div><div>AllowSimpleBracedStatements defaults to false, meaning that the above transformation will not happen since braced block are considered "complex" and thus are not allowed to be put on a single line.<br>

</div><div><br></div><div>This is a fix for <a href="http://llvm.org/bugs/show_bug.cgi?id=19193">http://llvm.org/bugs/show_bug.cgi?id=19193</a> . There, the following remarks were made:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Things to do before this can get accepted: <br>- You clang-format in LLVM style to format the changes (or e.g. git-clang-format). <br>- Add tests, i.e. your test program should be put as unit tests into unittests/Format/FormatTest.cpp</blockquote>

<div><br></div><div>These issues have been addressed (hopefully!) in the attached patch </div><div>and adding the tests has made the patch better (so thanks for the feedback!).</div><div><br></div><div>Some newbie impressions on the clang-format code for those interested:</div>

<div><br></div><div>I have almost no experience with clang-format but after hacking on it a bit I feel that in the future there should be a way to format blocks independently of them being braced or not, belonging to a function, a control statements, a loop, ... Right now there are multiple functions dealing with the formatting of blocks and it felt a bit messy. </div>

<div><br></div><div>It also took me a bit to figure out how to add a new test, and how to launch clang-format tests only (independently of all others llvm tests) but this could probably fixed with a small paragraph in the docs.</div>

<div><br></div><div>Otherwise the code is self explanatory and well documented, and for someone like me who has no idea what he is doing (and what clang-format is doing) it was really easy to get clang-format to do what I wanted. </div>

<div><br></div><div>Bests,</div><div>Gonzalo BG</div>







</div>