Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC][CodingStandard] Add additional example for if-else brace rule #111733

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/docs/CodingStandards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,14 @@ would help to avoid running into a "dangling else" situation.
handleOtherDecl(D);
}

// Use braces for the `else` block to keep it uniform with the `if` block.
if (isa<FunctionDecl>(D)) {
verifyFunctionDecl(D);
handleFunctionDecl(D);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add an else if single-statement block too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I'll amend the example to include an else if and an else.

handleOtherDecl(D);
}

// This should also omit braces. The `for` loop contains only a single
// statement, so it shouldn't have braces. The `if` also only contains a
// single simple statement (the `for` loop), so it also should omit braces.
Expand Down
Loading