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 08:22:44 PST 2016
> -----Original Message-----
> From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf
> Of Robinson, Paul via llvm-commits
> Sent: Tuesday, November 22, 2016 6:39 AM
> To: reviews+D26943+public+5c1a379143b6f3e8 at reviews.llvm.org; Matt
> Arsenault; jlebar at google.com; rnk at google.com; matze at braunis.de
> Cc: llvm-commits at lists.llvm.org
> Subject: RE: D26943: [CodingStandards] Add style guide rule about "if"
> statements and loops.
>
>
>
> > -----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.
Although, for really simple cases it's probably fine to omit them:
if (auto Foo = bar())
for (auto Baz : Foo.stuff())
bazIt(Baz);
> --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
> _______________________________________________
> 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