18 functionDecl(hasAnyName(
"ERR_PTR",
"PTR_ERR",
"IS_ERR",
"IS_ERR_OR_NULL",
19 "ERR_CAST",
"PTR_ERR_OR_ZERO"));
20 auto NonCheckingStmts = stmt(anyOf(compoundStmt(), labelStmt()));
22 callExpr(callee(ErrFn), hasParent(NonCheckingStmts)).bind(
"call"),
this);
24 auto ReturnToCheck = returnStmt(hasReturnValue(callExpr(callee(ErrFn))));
25 auto ReturnsErrFn = functionDecl(hasDescendant(ReturnToCheck));
26 Finder->addMatcher(callExpr(callee(ReturnsErrFn), hasParent(NonCheckingStmts))
27 .bind(
"transitive_call"),
32 const auto *MatchedCallExpr = Result.Nodes.getNodeAs<CallExpr>(
"call");
33 if (MatchedCallExpr) {
34 diag(MatchedCallExpr->getExprLoc(),
"result from function %0 is unused")
35 << MatchedCallExpr->getDirectCallee();
38 const auto *MatchedTransitiveCallExpr =
39 Result.Nodes.getNodeAs<CallExpr>(
"transitive_call");
40 if (MatchedTransitiveCallExpr) {
41 diag(MatchedTransitiveCallExpr->getExprLoc(),
42 "result from function %0 is unused but represents an error value")
43 << MatchedTransitiveCallExpr->getDirectCallee();