================
@@ -102,6 +102,210 @@ void BranchCloneCheck::registerMatchers(MatchFinder
*Finder) {
this);
Finder->addMatcher(switchStmt().bind("switch"), this);
Finder->addMatcher(conditionalOperator().bind("condOp"), this);
+
Finder->addMatcher(ifStmt(hasDescendant(ifStmt())).bind("ifWithDescendantIf"),
----------------
5chmidti wrote:
The current matcher will check for `if`s as descendants, not only as direct
children. So code like
```c++
void foo() {
if (true) {
[]() {
if (false) {
}
};
}
}
```
will still produce a match, that you filter out later, instead of in the
matcher.
A matcher like `ifStmt(anyOf(has(ifStmt().bind("inner_if")),
has(compoundStmt(has(ifStmt().bind("inner_if"))))).bind("ifWithDescendantIf")`
will ensure that only direct children are looked at. To enforce the requirement
of the first statement inside a compound statement, adding a custom matcher
would be best IMO.
https://github.com/llvm/llvm-project/pull/114715
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits