13class MainCallChecker :
public Checker<check::PreStmt<CallExpr>> {
15 const BugType BT{
this,
"call to main",
"example analyzer plugin"};
22void MainCallChecker::checkPreStmt(
const CallExpr *CE,
25 const FunctionDecl *FD =
C.getSVal(Callee).getAsFunctionDecl();
35 if (II->
isStr(
"main")) {
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");
#define CLANG_ANALYZER_API_VERSION_STRING
void clang_registerCheckers(CheckerRegistry &Registry)
const char clang_analyzerAPIVersionString[]
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
This represents one expression.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
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.
Manages a set of available checkers for running a static analysis.
void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction Sfn, StringRef FullName, StringRef Desc, StringRef DocsUri="NoDocsUri", bool IsHidden=false)
Adds a checker to the registry.
Simple checker classes that implement one frontend (i.e.
The JSON file list parser is used to communicate input to InstallAPI.