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

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 21 15:17:27 PST 2016


jlebar created this revision.
jlebar added reviewers: rnk, MatzeB.
jlebar added subscribers: llvm-commits, arsenm.

It seems that most LLVM code omits braces on, and only on, single-line
"if" and loop bodies.


https://reviews.llvm.org/D26943

Files:
  llvm/docs/CodingStandards.rst


Index: llvm/docs/CodingStandards.rst
===================================================================
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -510,6 +510,13 @@
 of indentation.  Also, do not reindent a whole source file: it makes for
 incredible diffs that are absolutely worthless.
 
+Omit braces for (and only for) one-line "if" and loop bodies
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If the body of an *if* statement or a loop is a single line, omit the curly
+braces.  If the *if* statement or loop is multiple lines long, do not omit the
+braces.
+
 Indent Code Consistently
 ^^^^^^^^^^^^^^^^^^^^^^^^
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26943.78795.patch
Type: text/x-patch
Size: 667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161121/7fc58abd/attachment.bin>


More information about the llvm-commits mailing list