[PATCH] D82594: Clarify a bit the guideline on omitting braces, including more examples (NFC)
Erich Keane via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 25 14:11:54 PDT 2020
erichkeane added a comment.
A few small nits, but I don't sufficiently care enough about the rule, so long as there IS one (hence my reason for opening this can of worms). I added @lattner since he requested that he be added to changes to the coding standards in the past.
================
Comment at: llvm/docs/CodingStandards.rst:1583
+hoisted above the ``if`` or loop statement, see below).
+Similarly, braces should be used when single-statement body is complex enough
+that it becomes difficult to see where the block containing the following
----------------
used when _a_ single-statement body
?
================
Comment at: llvm/docs/CodingStandards.rst:1610
+ // surprisingly long comment, so it would be unclear without the braces whether
+ // the following statement is in the scope of the if
+ handleOtherDecl(D);
----------------
end in a period?
================
Comment at: llvm/docs/CodingStandards.rst:1623
+ // Use braces for the `if` block to keep it uniform with the else block.
+ if (isa<FunctionDecl>(D)) {
+ handleFunctionDecl(D);
----------------
I'll note that this example has been VERY inconsistently enforced. Typically I've seen the rule in if/else chains be; "Once you START using braces, use them for the rest".
================
Comment at: llvm/docs/CodingStandards.rst:1628
// surprisingly long comment, so it would be unclear without the braces whether
- // the following statement is in the scope of the else.
+ // the following statement is in the scope of the if
handleOtherDecl(D);
----------------
Same here, end in a full stop?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82594/new/
https://reviews.llvm.org/D82594
More information about the llvm-commits
mailing list