This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add readability-nested-ifs check
Needs ReviewPublic

Authored by njames93 on Jul 27 2022, 5:40 AM.

Details

Summary

Add a check to detect nested if statements which can be combined into one by ANDing the conditions.
This reduces indentation making code easier to read.

Diff Detail

Event Timeline

njames93 created this revision.Jul 27 2022, 5:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2022, 5:40 AM
njames93 requested review of this revision.Jul 27 2022, 5:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2022, 5:40 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Eugene.Zelenko added inline comments.Jul 27 2022, 6:48 AM
clang-tools-extra/docs/clang-tidy/checks/readability/nested-ifs.rst
59

Excessive newline.

njames93 updated this revision to Diff 448064.Jul 27 2022, 9:06 AM
njames93 marked an inline comment as done.

Remove Excessive Newline.
Hopefully fix the windows test failing.

njames93 updated this revision to Diff 448172.Jul 27 2022, 2:53 PM

Fix typo in test file.

njames93 updated this revision to Diff 449621.Aug 3 2022, 3:12 AM

Handle cases where the fix is incorrect due to operator precedence.

How does this check interact with macros that expand to if statements?