10 #include "clang/AST/ASTContext.h"
11 #include "clang/ASTMatchers/ASTMatchFinder.h"
19 void CommandProcessorCheck::registerMatchers(MatchFinder *Finder) {
22 callee(functionDecl(hasAnyName(
"::system",
"::popen",
"::_popen"))
27 unless(callExpr(callee(functionDecl(hasName(
"::system"))),
29 hasArgument(0, nullPointerConstant()))))
34 void CommandProcessorCheck::check(
const MatchFinder::MatchResult &Result) {
35 const auto *Fn = Result.Nodes.getNodeAs<FunctionDecl>(
"func");
36 const auto *
E = Result.Nodes.getNodeAs<CallExpr>(
"expr");
38 diag(
E->getExprLoc(),
"calling %0 uses a command processor") << Fn;