[PATCH] D127114: new clang-tidy checker for assignments within condition clause of if statement
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 5 09:29:20 PDT 2022
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.
LGTM with a few minor edits.
Do you have commit access?
================
Comment at: clang-tools-extra/clang-tidy/bugprone/AssignmentInIfConditionCheck.cpp:19-21
+void AssignmentInIfConditionCheck::registerMatchers(MatchFinder *Finder) {
+ // Scott Added this one
+ Finder->addMatcher(ifStmt(hasCondition(forEachDescendant(
----------------
================
Comment at: clang-tools-extra/clang-tidy/bugprone/AssignmentInIfConditionCheck.cpp:32-34
+ const MatchFinder::MatchResult &Result) {
+ // Add callback implementation.
+ const auto *MatchedDecl =
----------------
No need to repeat the code in comments.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-assignment-in-if-condition.cpp:1-4
+// RUN: %check_clang_tidy %s bugprone-assignment-in-if-condition %t
+
+// Add something that triggers the check here.
+void f(int arg) {
----------------
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127114/new/
https://reviews.llvm.org/D127114
More information about the cfe-commits
mailing list