[Docs] Clarify the guideline on omitting braces
authorowenca <owenpiano@gmail.com>
Thu, 26 May 2022 23:07:53 +0000 (16:07 -0700)
committerowenca <owenpiano@gmail.com>
Wed, 1 Jun 2022 06:35:30 +0000 (23:35 -0700)
commit3d56131bf6dd41449390ab551337540bbbe04402
tree227add3d08d798f6468e77cb53725f847186561b
parente290fcef111c24ed833c9768809eb900a21c94e0
[Docs] Clarify the guideline on omitting braces

While working on a clang-format option RemoveBracesLLVM that removes
braces following the guideline, we were unsure about what to do with
the braces of do-while loops. The ratio of using to omitting the
braces is about 4:1 in the llvm-project source, so it will help to
add an example to the guideline.

Also cleans up the original examples including making the nested if
example more targeted on avoiding potential dangling else situations.

Differential Revision: https://reviews.llvm.org/D126512
llvm/docs/CodingStandards.rst