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

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 23 09:28:46 PST 2016


kparzysz added a comment.

In https://reviews.llvm.org/D26943#604404, @rnk wrote:

> I'm sympathetic to this idiom, but I can't come up with an easy way to write a rule to allow it:


Does it need to be codified in full? I think that putting more braces should be allowed and the coding guidelines should dictate where they can be omitted.

(1) If a nested statement has braces, the enclosing statement should have braces.
(2) If the immediate nesting has only one indented line, braces can be omitted, unless (1) applies.

The intent of (2) is to require braces in cases like this:

  for (auto a : Items)
    // Calculate foo for each item.
    a.foo();


https://reviews.llvm.org/D26943





More information about the llvm-commits mailing list