[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-14 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46 +CheckFactories.registerCheck( +"misc-redundant-condition"); CheckFactories.registerCheck( aaron.ballman wrote: > baloghadamsoftware

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. Poking @alexfh for more opinions about check similarity. Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46 +CheckFactories.registerCheck( +"misc-redundant-condition"); CheckFactories.registerCheck(

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46 +CheckFactories.registerCheck( +"misc-redundant-condition"); CheckFactories.registerCheck( aaron.ballman wrote: > baloghadamsoftware

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46 +CheckFactories.registerCheck( +"misc-redundant-condition"); CheckFactories.registerCheck( baloghadamsoftware wrote: > aaron.ballman wrote:

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46 +CheckFactories.registerCheck( +"misc-redundant-condition"); CheckFactories.registerCheck( aaron.ballman wrote: > baloghadamsoftware

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46 +CheckFactories.registerCheck( +"misc-redundant-condition"); CheckFactories.registerCheck( baloghadamsoftware wrote: > aaron.ballman wrote:

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 3 inline comments as done. baloghadamsoftware added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46 +CheckFactories.registerCheck( +"misc-redundant-condition"); CheckFactories.registerCheck(

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 285309. baloghadamsoftware added a comment. Updated according to the comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81272/new/ https://reviews.llvm.org/D81272 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:73 + // If the variable has an alias then it can be changed by that alias as well. + // FIXME: Track pointers and references. + if (hasPtrOrReferenceInFunc(Func,

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-12 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:73 + // If the variable has an alias then it can be changed by that alias as well. + // FIXME: Track pointers and references. + if

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp:46 +CheckFactories.registerCheck( +"misc-redundant-condition"); CheckFactories.registerCheck( I think this check should probably live in the

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-08-11 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment. 6 findings in the //LLVM Project//. All of them confirmed as trues positives, 5 of them already fixed. Fix pending for the last one. D82555 , D8556 , D82557 ,

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-30 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment. True positive confirmed in //PostGreS//: Mailing List Archive . It is fixed by now, so you cannot see it on the link in my previous comment anymore.

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-25 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment. As a future work, when something support `if`s, it should also support `?:`, and eliminate redundant conditionals from there, too. I believe this check (together with `misc-redundant-expr`) should go into the `readability-` group. CHANGES SINCE LAST ACTION

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-24 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment. I tested this check on several open-source projects: //BitCoin//, //CURL//, //OpenSSL//, //PostGreS/, //TMux/ and //Xerces//. I only got two warnings issued by this checker, the first one in //BitCoin//: src/checkqueue.h:93:25: redundant condition

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-10 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 269769. baloghadamsoftware added a comment. Thank you for your help, @njames93! I updated the patch according to your comments. (And of course, also thank you, @Eugene.Zelenko, I also incorporated the changes you suggested.) CHANGES SINCE LAST

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-08 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. These test cases don't show it, from what i can see this will erroneously match: if (onFire) { tryPutFireOut(); } else { if (isHot && onFire) { scream(); } } It appears that this will change the second if to: if (isHot) { scream(); }

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/docs/clang-tidy/checks/misc-redundant-condition.rst:6 + +Finds condition variables in nested `if` statements that were also checked in +the outer `if` statement and were not changed. Please use

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-08 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 11 inline comments as done. baloghadamsoftware added inline comments. Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:39 + declRefExpr(hasDeclaration(varDecl().bind("cond_var"))), +

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-08 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 269222. baloghadamsoftware added a comment. Updated according to the comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81272/new/ https://reviews.llvm.org/D81272 Files: clang-tools-extra/clang-tidy/misc/CMakeLists.txt

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-05 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment. I feel the refactoring of Aliasing should be in its own PR, with this being a child of it. Comment at: clang-tools-extra/clang-tidy/misc/RedundantConditionCheck.cpp:38 + ifStmt(hasCondition(anyOf( +

[PATCH] D81272: [clang-tidy] New check `misc-redundant-condition`

2020-06-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tools-extra/docs/ReleaseNotes.rst:78 ^^ +- New :doc:`misc-redundant-condition + ` check. Please keep alphabetical order in new checks list. Comment at:

[PATCH] D81272: [Clang-Tidy] New check `misc-redundant-condition`

2020-06-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done. baloghadamsoftware added a comment. This check was made upon user request. I think it is a good base that can later be extended also for the negated cases (where the code inside the inner `if` never executes). That case is even more

[PATCH] D81272: [Clang-Tidy] New check `misc-redundant-condition`

2020-06-05 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision. baloghadamsoftware added reviewers: aaron.ballman, gribozavr2. baloghadamsoftware added a project: clang-tools-extra. Herald added subscribers: martong, steakhal, gamesh411, Szelethus, dkrupp, rnkovacs, xazax.hun, whisperity, mgorny. Herald added a