47 const CallExpr *Call =
nullptr;
48 StringRef Recommendation;
50 if ((Call = Result.Nodes.getNodeAs<CallExpr>(
"allocation")))
51 Recommendation =
"consider a container or a smart pointer";
52 else if ((Call = Result.Nodes.getNodeAs<CallExpr>(
"realloc")))
53 Recommendation =
"consider std::vector or std::string";
54 else if ((Call = Result.Nodes.getNodeAs<CallExpr>(
"free")))
55 Recommendation =
"use RAII";
57 assert(Call &&
"Unhandled binding in the Matcher");
59 diag(Call->getBeginLoc(),
"do not manage memory manually; %0")
60 << Recommendation << SourceRange(Call->getBeginLoc(), Call->getEndLoc());