Skip to content

Commit dddce94

Browse files
jurahulDanielCChen
authored andcommitted
[NFC][CodingStandard] Add additional example for if-else brace rule (llvm#111733)
Add example to document that single statement `else` needs a brace if the associated `if` needs a brace.
1 parent 2d6fb24 commit dddce94

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

llvm/docs/CodingStandards.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,14 @@ would help to avoid running into a "dangling else" situation.
17131713
handleOtherDecl(D);
17141714
}
17151715

1716+
// Use braces for the `else` block to keep it uniform with the `if` block.
1717+
if (isa<FunctionDecl>(D)) {
1718+
verifyFunctionDecl(D);
1719+
handleFunctionDecl(D);
1720+
} else {
1721+
handleOtherDecl(D);
1722+
}
1723+
17161724
// This should also omit braces. The `for` loop contains only a single
17171725
// statement, so it shouldn't have braces. The `if` also only contains a
17181726
// single simple statement (the `for` loop), so it also should omit braces.

0 commit comments

Comments
 (0)