[PATCH] clang-format: "break before else" behavior

Daniel Jasper djasper at google.com
Tue Aug 5 05:15:28 PDT 2014


Submitted as r214857, thank you!


On Fri, May 9, 2014 at 2:20 PM, Jarkko Hietaniemi <jhi at iki.fi> wrote:

> I wanted cuddled braces for 'if' and 'else' (just like the default style
> gives) *except* that I wanted my 'else' keywords themselves "uncuddled",
> that is, inserting a break before the 'else':
>
> if (a) {
>   a();
> }
> else {
>   b();
> }
>
> This style makes the 'else' stand out better, instead of being hidden in
>
>   } else {
>
> while still giving the relatively tighter vertical packing of lines.
>
> This looks to be part of the "Stroustrup" style.
>
> However, I'm a little dubious about changing this because so far it hasn't
> been part of the Stroustrup behavior... that is, existing users of
> BS_Stroustrup will have their code look different when they re-format.
>
> But http://www.stroustrup.com/Programming/PPP-style-rev3.pdf very clearly
> "uncuddles" the 'else', while the braces of both 'else' and 'if' are
> "cuddled", as a proper K&R descendant should.
>
> In case changing the behavior of BS_Stroustrup is deemed too big a change,
> I'm also including an alternate version of the change which adds a new
> top-level option for this, AlwaysBreakBeforeElse.
>
> Patches attached.
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140805/eb96361e/attachment.html>


More information about the cfe-commits mailing list