[cfe-commits] r172431 - in /cfe/trunk: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/FormatTest.cpp

Jordan Rose jordan_rose at apple.com
Wed Jan 16 10:39:35 PST 2013


On Jan 16, 2013, at 2:06 , Chandler Carruth <chandlerc at google.com> wrote:

> On Mon, Jan 14, 2013 at 8:44 AM, Nico Weber <thakis at chromium.org> wrote:
> On Mon, Jan 14, 2013 at 8:24 AM, Daniel Jasper <djasper at google.com> wrote:
> > Author: djasper
> > Date: Mon Jan 14 10:24:39 2013
> > New Revision: 172431
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=172431&view=rev
> > Log:
> > Make single-line if statements optional.
> 
> Thanks!
> 
> Out of curiosity, do you know how common this style is in Google's
> internal code? I haven't seen it much.
> 
> For what it's worth, despite having written a lot of single-line if statements, I don't think this is worth options in the formatter. I think consistency and simplicity should trump here, and since there trivially exist cases that can't be on a single line, it seems of very low value to support folding onto a single line....
> 
> My two cents, and it applies both to Google's internal coding style, and my feelings on LLVM's coding style.

This is pure opinion, but I actually prefer single-line if statements if the braces are omitted. It makes it clearer to me that you can't add anything to the consequent clause.

(I agree that this is not the dominant style in LLVM though, or at least not in Clang.)

This may eventually be subsumed by a setting to add braces to single-statement if-statement.

Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130116/3c3d2106/attachment.html>


More information about the cfe-commits mailing list