[PATCH] D80947: Add to the Coding Standard our that single-line bodies omit braces
Hubert Tong via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 1 12:59:58 PDT 2020
hubert.reinterpretcast added inline comments.
================
Comment at: llvm/docs/CodingStandards.rst:1580
+statement is accompanied by a comment that loses its meaning if hoisted above the if
+or loop statement, or where the single statement is complex enough that it stops being
+clear that it is a single line. Note that comments should only be hoisted for loops and
----------------
I'm happy with the implications of how this is phrased, but I am not sure it was intended. A statement that is not going to be a single line (a loop inside an else) qualifies for braces.
================
Comment at: llvm/docs/CodingStandards.rst:1592
+ handleVarDecl(D);
+ else {
+ // In this else case, it is necessary that we explain the situation with this
----------------
I believe this is an example of bad style. Applying the prose text to the example:
Adding braces in this example to the above bodies do not introduce "meaningless lines of code" as the lines already occur regardless. Adding braces may arguably improve readability.
Say, for the following, the lack of uniformity in the use of braces is a distraction:
```
if (A)
zip();
else if (B) {
foo();
bar();
} else
hello;
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80947/new/
https://reviews.llvm.org/D80947
More information about the cfe-commits
mailing list