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

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 15:33:17 PST 2016


MatzeB added a comment.

In https://reviews.llvm.org/D26943#601951, @jlebar wrote:

> > I feel like this should live down near "Don’t use else after a return"
>
> I put it here because the overall section header is "Mechanical Source Issues".  But now I see that e.g. "Spaces Before Parentheses" is down at the bottom of the doc, so...I now have no idea how this is structured.
>
> > to make it clear we want braces for if else.
>
> We do?  Elsewhere in the style guide they have unbraced if/else, e.g. following "or better yet (in this case)".


Ok, I grepped around llvm source and the majority of cases is indeed without braces. Then add this to the examples:

  if (I.isEven())
    handleEven(I);
  else
    handleOdd(I);


https://reviews.llvm.org/D26943





More information about the llvm-commits mailing list