10class MainCallChecker :
public Checker<check::PreStmt<CallExpr>> {
11 mutable std::unique_ptr<BugType> BT;
18void MainCallChecker::checkPreStmt(
const CallExpr *CE,
21 const FunctionDecl *FD =
C.getSVal(Callee).getAsFunctionDecl();
31 if (II->
isStr(
"main")) {
37 BT.reset(
new BugType(
this,
"call to main",
"example analyzer plugin"));
40 std::make_unique<PathSensitiveBugReport>(*BT, BT->getDescription(), N);
41 report->addRange(
Callee->getSourceRange());
42 C.emitReport(std::move(report));
49 "example.MainCallChecker",
"Disallows calls to functions called main",
#define CLANG_ANALYZER_API_VERSION_STRING
void clang_registerCheckers(CheckerRegistry ®istry)
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, bool IsHidden)
Adds a checker to the registry.
The JSON file list parser is used to communicate input to InstallAPI.