23#include "llvm/Support/ErrorHandling.h"
30class AnalysisOrderChecker
32 check::PreStmt<CastExpr>, check::PostStmt<CastExpr>,
33 check::PreStmt<ArraySubscriptExpr>,
34 check::PostStmt<ArraySubscriptExpr>, check::PreStmt<CXXNewExpr>,
35 check::PostStmt<CXXNewExpr>, check::PreStmt<CXXDeleteExpr>,
36 check::PostStmt<CXXDeleteExpr>, check::PreStmt<CXXConstructExpr>,
37 check::PostStmt<CXXConstructExpr>, check::PreStmt<OffsetOfExpr>,
38 check::PostStmt<OffsetOfExpr>, check::PreCall, check::PostCall,
39 check::EndFunction, check::EndAnalysis, check::NewAllocator,
40 check::Bind, check::PointerEscape, check::RegionChanges,
41 check::LiveSymbols, eval::Call> {
44 StringRef CallbackName)
const {
49 bool isCallbackEnabled(
CheckerContext &
C, StringRef CallbackName)
const {
51 return isCallbackEnabled(Opts, CallbackName);
54 bool isCallbackEnabled(
ProgramStateRef State, StringRef CallbackName)
const {
56 .getAnalysisManager().getAnalyzerOptions();
57 return isCallbackEnabled(Opts, CallbackName);
62 if (isCallbackEnabled(
C,
"PreStmtCastExpr"))
68 if (isCallbackEnabled(
C,
"PostStmtCastExpr"))
75 if (isCallbackEnabled(
C,
"PreStmtArraySubscriptExpr"))
76 llvm::errs() <<
"PreStmt<ArraySubscriptExpr>\n";
81 if (isCallbackEnabled(
C,
"PostStmtArraySubscriptExpr"))
82 llvm::errs() <<
"PostStmt<ArraySubscriptExpr>\n";
86 if (isCallbackEnabled(
C,
"PreStmtCXXNewExpr"))
87 llvm::errs() <<
"PreStmt<CXXNewExpr>\n";
91 if (isCallbackEnabled(
C,
"PostStmtCXXNewExpr"))
92 llvm::errs() <<
"PostStmt<CXXNewExpr>\n";
96 if (isCallbackEnabled(
C,
"PreStmtCXXDeleteExpr"))
97 llvm::errs() <<
"PreStmt<CXXDeleteExpr>\n";
101 if (isCallbackEnabled(
C,
"PostStmtCXXDeleteExpr"))
102 llvm::errs() <<
"PostStmt<CXXDeleteExpr>\n";
106 if (isCallbackEnabled(
C,
"PreStmtCXXConstructExpr"))
107 llvm::errs() <<
"PreStmt<CXXConstructExpr>\n";
111 if (isCallbackEnabled(
C,
"PostStmtCXXConstructExpr"))
112 llvm::errs() <<
"PostStmt<CXXConstructExpr>\n";
116 if (isCallbackEnabled(
C,
"PreStmtOffsetOfExpr"))
117 llvm::errs() <<
"PreStmt<OffsetOfExpr>\n";
121 if (isCallbackEnabled(
C,
"PostStmtOffsetOfExpr"))
122 llvm::errs() <<
"PostStmt<OffsetOfExpr>\n";
126 if (isCallbackEnabled(
C,
"EvalCall")) {
127 llvm::errs() <<
"EvalCall";
128 if (
const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(
Call.getDecl()))
129 llvm::errs() <<
" (" << ND->getQualifiedNameAsString() <<
')';
130 llvm::errs() <<
" {argno: " <<
Call.getNumArgs() <<
'}';
131 llvm::errs() <<
" [" <<
Call.getKindAsString() <<
']';
132 llvm::errs() <<
'\n';
139 if (isCallbackEnabled(
C,
"PreCall")) {
140 llvm::errs() <<
"PreCall";
141 if (
const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(
Call.getDecl()))
142 llvm::errs() <<
" (" << ND->getQualifiedNameAsString() <<
')';
143 llvm::errs() <<
" [" <<
Call.getKindAsString() <<
']';
144 llvm::errs() <<
'\n';
149 if (isCallbackEnabled(
C,
"PostCall")) {
150 llvm::errs() <<
"PostCall";
151 if (
const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(
Call.getDecl()))
152 llvm::errs() <<
" (" << ND->getQualifiedNameAsString() <<
')';
153 llvm::errs() <<
" [" <<
Call.getKindAsString() <<
']';
154 llvm::errs() <<
'\n';
159 if (isCallbackEnabled(
C,
"EndFunction")) {
160 llvm::errs() <<
"EndFunction\nReturnStmt: " << (S ?
"yes" :
"no") <<
"\n";
164 llvm::errs() <<
"CFGElement: ";
165 CFGStmtMap *Map =
C.getCurrentAnalysisDeclContext()->getCFGStmtMap();
169 llvm::errs() <<
"CFGStmt\n";
171 llvm::errs() <<
"CFGAutomaticObjDtor\n";
178 llvm::errs() <<
"EndAnalysis\n";
183 if (isCallbackEnabled(
C,
"NewAllocator"))
184 llvm::errs() <<
"NewAllocator\n";
188 if (isCallbackEnabled(
C,
"Bind"))
189 llvm::errs() <<
"Bind\n";
193 if (isCallbackEnabled(State,
"LiveSymbols"))
194 llvm::errs() <<
"LiveSymbols\n";
203 if (isCallbackEnabled(State,
"RegionChanges"))
204 llvm::errs() <<
"RegionChanges\n";
212 if (isCallbackEnabled(State,
"PointerEscape"))
213 llvm::errs() <<
"PointerEscape\n";
227bool ento::shouldRegisterAnalysisOrderChecker(
const CheckerManager &mgr) {
Defines the clang::Expr interface and subclasses for C++ expressions.
Stores options for the analyzer from the command line.
bool getCheckerBooleanOption(StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const
Interprets an option's string value as a boolean.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Represents C++ object destructor implicitly generated for automatic object or temporary bound to cons...
Represents a top-level expression in a basic block.
std::optional< T > getAs() const
Convert to the specified CFGElement type, returning std::nullopt if this CFGElement is not of the des...
CFGBlock * getBlock(Stmt *S)
Returns the CFGBlock the specified Stmt* appears in.
Represents a call to a C++ constructor.
Represents a delete expression for memory deallocation and destructor calls, e.g.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
static const char * getCastKindName(CastKind CK)
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
This represents a decl that may have a name.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Stmt - This represents one statement.
BugReporter is a utility class for generating PathDiagnostics for analysis.
const AnalyzerOptions & getAnalyzerOptions()
Represents the memory allocation call in a C++ new-expression.
Represents an abstract call to a function or method along a particular path.
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
A class responsible for cleaning up unused symbols.
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
llvm::DenseSet< SymbolRef > InvalidatedSymbols
The JSON file list parser is used to communicate input to InstallAPI.