D26943: [CodingStandards] Add style guide rule about "if" statements and loops.

Robinson, Paul via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 06:39:15 PST 2016



> -----Original Message-----
> From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf
> Of Matt Arsenault via llvm-commits
> Sent: Monday, November 21, 2016 4:02 PM
> To: jlebar at google.com; rnk at google.com; matze at braunis.de
> Cc: llvm-commits at lists.llvm.org
> Subject: [PATCH] D26943: [CodingStandards] Add style guide rule about "if"
> statements and loops.
> 
> arsenm added a comment.
> 
> In https://reviews.llvm.org/D26943#601970, @MatzeB wrote:
> 
> > In https://reviews.llvm.org/D26943#601961, @compnerd wrote:
> >
> > > Personally, I think I would prefer that we add braces only if one of
> the bodies of the code path requires it:
> >
> >
> > Just for the sake of discussion (I personally would prefer braces). This
> would result in this in the extreme case:
> >
> >   if (foo)
> >     for (Baz b : bazes)
> >       if (b)
> >         ++BCount;
> >       else
> >         ++NotBCount;
> >   else
> >     foobar();
> >
> 
> 
> +1 for braces

+1.  In this example both the outermost 'if' and the 'for' have
a multiline body (even if each individual statement has only 1 line)
and so I also prefer they have braces.
--paulr

> 
> 
> https://reviews.llvm.org/D26943
> 
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list