================
@@ -147,10 +161,52 @@ void OwningMemoryCheck::registerMatchers(MatchFinder
*Finder) {
// Matching on functions, that return an owner/resource, but don't declare
// their return type as owner.
Finder->addMatcher(
- functionDecl(hasDescendant(returnStmt(hasReturnValue(ConsideredOwner))
- .bind("bad_owner_return")),
- unless(returns(qualType(hasDeclaration(OwnerDecl)))))
- .bind("function_decl"),
+ functionDecl(
+ decl().bind("function_decl"),
+ hasBody(stmt(
+ stmt().bind("body"),
+ hasDescendant(
+ returnStmt(hasReturnValue(ConsideredOwner),
+ // Ignore sub-lambda expressions
+ hasAncestor(stmt(anyOf(equalsBoundNode("body"),
----------------
PiotrZSL wrote:
there is hasAncestor body or lambda. Simply it will match an first one that it
finds, and that we bind to 'scope'.
In next lines we simply check if body and scope is same, if not then we in
lambda.
https://github.com/llvm/llvm-project/pull/77246
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits