13class MainCallChecker :
public Checker<check::PreStmt<CallExpr>> {
15 const BugType BT{
this,
"call to main",
"example analyzer plugin"};
18 void checkPreStmt(
const CallExpr *CE, CheckerContext &
C)
const;
22void MainCallChecker::checkPreStmt(
const CallExpr *CE,
25 const FunctionDecl *FD =
C.getSVal(Callee).getAsFunctionDecl();
35 if (II->
isStr(
"main")) {
36 ExplodedNode *N =
C.generateErrorNode();
41 std::make_unique<PathSensitiveBugReport>(BT, BT.
getDescription(), N);
42 report->addRange(
Callee->getSourceRange());
43 C.emitReport(std::move(report));
49 Registry.addChecker<MainCallChecker>(
"example.MainCallChecker",
50 "Example Description");
void clang_registerCheckers(CheckerRegistry &Registry)
const char clang_analyzerAPIVersionString[]
#define CLANG_ANALYZER_API_VERSION_STRING
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getDescription() const
Manages a set of available checkers for running a static analysis.
Simple checker classes that implement one frontend (i.e.
The JSON file list parser is used to communicate input to InstallAPI.