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