[llvm-dev] Codifying our Brace rules-

Nicolai Hähnle via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 18 03:56:06 PDT 2020


On Tue, Jun 16, 2020 at 10:35 AM Momchil Velikov via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> My 2 pennies is braces add unnecessary clutter and impair readability when
> used on a *single-line* statement. I count comments, that are on their
> own line as statement(s).

+1 for this. I think braces around single-line statements can be
allowed, but they really shouldn't be mandated, and that's been my
personal policy for reviews. In particular,

  if (!is_transform_applicable) {
    return {};
  }

is very aggravating clutter.

Braces should be required around multi-line statements. Note:

BAD:
  for (...)
    for (...)
      single_line_statement;

GOOD:
  for (...) {
    for (...)
      single_line_statement;
  }

Cheers,
Nicolai
-- 
Lerne, wie die Welt wirklich ist,
aber vergiss niemals, wie sie sein sollte.


More information about the llvm-dev mailing list