[llvm-dev] Codifying our Brace rules-

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 30 12:59:10 PDT 2020



> On Jun 29, 2020, at 8:05 AM, David Greene <david.greene at hpe.com> wrote:
> 
> Chris Lattner via llvm-dev <llvm-dev at lists.llvm.org> writes:
> 
>> For those who don’t like it, is the currently documented policy broken
>> enough to be important to changing?
> 
> I believe it is, simply for safety reasons.  Adding a statement to a
> single-statement block can introduce bugs.  Mandating braces everywhere
> prevents that.

Sure, I get that.  For background, the Swift language (which I was highly involved in) mandates braces - I’m just saying that I'm aware of the benefits and tradeoffs here.  In addition to the “safety” advantages, there are balancing cognitive disadvantages to requiring braces (less code fits on one screen, etc).  These are all well understood effects.

That said, this is not a new project, and many of the benefits fall below the line of being “worth it” given a large and established codebase.  I don’t see a strong reason to change the policy here, though I think we should give more guidance and clarify the wording!

-Chris



More information about the llvm-dev mailing list