[PATCH] D80947: Add to the Coding Standard our that single-line bodies omit braces
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 06:33:11 PDT 2020
arsenm added inline comments.
================
Comment at: llvm/docs/CodingStandards.rst:1573
+Don't Use Braces on Simple Single-Statement Bodies of if/else/loop Statements
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
----------------
I would rather just ban single line statements like this and require putting them on the next line.
For the case of cases, especially when combined with the style of not indenting the cases from the switch, omitting braces is really painful. So many times I've produced bad merges and had a hard time figuring out where the double }} at the end is necessary. It would be easier to just always use the braces
================
Comment at: llvm/docs/CodingStandards.rst:1603
+
+ // This should also omit braces. The for loop contains only a single statement,
+ // so it shouldn't have braces. The if also only contains a single statement (the
----------------
This loop should use braces. It covers multiple lines. Omitting braces invariably just increases diffs/merge conflicts when something else is added to the loop body.
This one isn't consistently applied and I've been enforcing the opposite
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80947/new/
https://reviews.llvm.org/D80947
More information about the llvm-commits
mailing list