10#include "clang/AST/ASTContext.h"
11#include "clang/ASTMatchers/ASTMatchFinder.h"
20 callee(functionDecl(hasAnyName(
"::system",
"::popen",
"::_popen"))
25 unless(callExpr(callee(functionDecl(hasName(
"::system"))),
27 hasArgument(0, nullPointerConstant()))))
33 const auto *Fn = Result.Nodes.getNodeAs<FunctionDecl>(
"func");
34 const auto *
E = Result.Nodes.getNodeAs<CallExpr>(
"expr");
36 diag(
E->getExprLoc(),
"calling %0 uses a command processor") << Fn;
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.