- Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Copy link
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillacheck-requestRequest for a new check in clang-tidyRequest for a new check in clang-tidyclang-tidy
Description
| Bugzilla Link | 40962 |
| Version | unspecified |
| OS | All |
Extended Description
Sometimes people write code like this:
bool invalid = false; invalid |= x > limit.x; invalid |= y > limit.y; invalid |= z > limit.z; if (invalid) { // error handling } However, we don't get short circuit evaluation in this case; all limits are checked even if the first limit is violated.
The alternative is to use logical operations instead of bitwise operations:
bool invalid = false; invalid = x > limit.x; invalid = invalid || y > limit.x; invalid = invalid || z > limit.z; if (invalid) { // error handling } Create a check that transforms bitwise operators on boolean quantities to logical operators.
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillacheck-requestRequest for a new check in clang-tidyRequest for a new check in clang-tidyclang-tidy