[llvm-dev] Codifying our Brace rules-

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Mon Jun 15 18:25:47 PDT 2020



> On Jun 15, 2020, at 4:13 PM, River Riddle via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> 
> 
> On Mon, Jun 15, 2020 at 4:08 PM David Blaikie via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
> On Mon, Jun 15, 2020 at 4:05 PM Mehdi AMINI via llvm-dev
> <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
> >
> > As another data point, the MLIR part of the codebase is pretty consistent on this: never use braces for trivial (single statement) if/else/for, but always put it on every branch if needed on any side of the if/else.
> 
> Any opinion/stance policy/practice on the "one line, or one statement
> (& possibly comments, etc)" issue?
> 
> Generally, any time there is a comment within the body I don't really see it as "trivial" anymore.
> 
> Prefer:
>   if (...) {
>     // Some comment.
>     single statement;
>   }
>   // Some comment.
>   If (...)
>     single statement;
> 
> Over:
>   if (...)
>     // Some comment
>     single statement;

+1

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200615/b3e41640/attachment-0001.html>


More information about the llvm-dev mailing list