10 class MainCallChecker :
public Checker<check::PreStmt<CallExpr>> {
11 mutable std::unique_ptr<BugType> BT;
18 void MainCallChecker::checkPreStmt(
const CallExpr *CE,
31 if (II->
isStr(
"main")) {
37 BT.reset(
new BugType(
this,
"call to main",
"example analyzer plugin"));
39 std::unique_ptr<BugReport> report =
40 llvm::make_unique<BugReport>(*BT, BT->getName(), N);
49 "example.MainCallChecker",
"Disallows calls to functions called main",
Manages a set of available checkers for running a static analysis.
Represents a function declaration or definition.
ExplodedNode * generateErrorNode(ProgramStateRef State=nullptr, const ProgramPointTag *Tag=nullptr)
Generate a transition to a node that will be used to report an error.
void addChecker(InitializationFunction Fn, ShouldRegisterFunction sfn, StringRef FullName, StringRef Desc, StringRef DocsUri, bool IsHidden)
Adds a checker to the registry.
#define CLANG_ANALYZER_API_VERSION_STRING
SVal getSVal(const Stmt *S) const
Get the value of arbitrary expressions at this point in the path.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
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.
This represents one expression.
void clang_registerCheckers(CheckerRegistry ®istry)
const char clang_analyzerAPIVersionString[]
void emitReport(std::unique_ptr< BugReport > R)
Emit the diagnostics report.
Dataflow Directional Tag Classes.
const FunctionDecl * getAsFunctionDecl() const
getAsFunctionDecl - If this SVal is a MemRegionVal and wraps a CodeTextRegion wrapping a FunctionDecl...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).