[clang] [clang-tools-extra] [analyzer] Remove alpha.core.IdenticalExpr Checker (PR #114715)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 24 10:53:59 PST 2024
================
@@ -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
More information about the cfe-commits
mailing list