13#ifndef LLVM_CLANG_STATICANALYZER_CORE_CHECKER_H
14#define LLVM_CLANG_STATICANALYZER_CORE_CHECKER_H
20#include "llvm/Support/Casting.h"
28template <
typename DECL>
30 template <
typename CHECKER>
33 ((
const CHECKER *)checker)->checkASTDecl(cast<DECL>(D), mgr, BR);
36 static bool _handlesDecl(
const Decl *D) {
40 template <
typename CHECKER>
49 template <
typename CHECKER>
52 ((
const CHECKER *)checker)->checkASTCodeBody(D, mgr, BR);
56 template <
typename CHECKER>
59 _checkBody<CHECKER>));
64 template <
typename CHECKER>
65 static void _checkEndOfTranslationUnit(
void *checker,
69 ((
const CHECKER *)checker)->checkEndOfTranslationUnit(TU, mgr, BR);
73 template <
typename CHECKER>
77 _checkEndOfTranslationUnit<CHECKER>));
81template <
typename STMT>
83 template <
typename CHECKER>
85 ((
const CHECKER *)checker)->checkPreStmt(cast<STMT>(S),
C);
88 static bool _handlesStmt(
const Stmt *S) {
92 template <
typename CHECKER>
100template <
typename STMT>
102 template <
typename CHECKER>
104 ((
const CHECKER *)checker)->checkPostStmt(cast<STMT>(S),
C);
107 static bool _handlesStmt(
const Stmt *S) {
111 template <
typename CHECKER>
114 _checkStmt<CHECKER>),
120 template <
typename CHECKER>
121 static void _checkObjCMessage(
void *checker,
const ObjCMethodCall &msg,
123 ((
const CHECKER *)checker)->checkPreObjCMessage(msg,
C);
127 template <
typename CHECKER>
135 template <
typename CHECKER>
136 static void _checkObjCMessage(
void *checker,
const ObjCMethodCall &msg,
138 ((
const CHECKER *)checker)->checkObjCMessageNil(msg,
C);
142 template <
typename CHECKER>
150 template <
typename CHECKER>
151 static void _checkObjCMessage(
void *checker,
const ObjCMethodCall &msg,
153 ((
const CHECKER *)checker)->checkPostObjCMessage(msg,
C);
157 template <
typename CHECKER>
165 template <
typename CHECKER>
166 static void _checkCall(
void *checker,
const CallEvent &msg,
168 ((
const CHECKER *)checker)->checkPreCall(msg,
C);
172 template <
typename CHECKER>
180 template <
typename CHECKER>
181 static void _checkCall(
void *checker,
const CallEvent &msg,
183 ((
const CHECKER *)checker)->checkPostCall(msg,
C);
187 template <
typename CHECKER>
195 template <
typename CHECKER>
196 static void _checkLocation(
void *checker,
197 const SVal &location,
bool isLoad,
const Stmt *S,
199 ((
const CHECKER *)checker)->checkLocation(location, isLoad, S,
C);
203 template <
typename CHECKER>
211 template <
typename CHECKER>
212 static void _checkBind(
void *checker,
215 ((
const CHECKER *)checker)->checkBind(location, val, S,
C);
219 template <
typename CHECKER>
227 template <
typename CHECKER>
228 static void _checkEndAnalysis(
void *checker,
ExplodedGraph &G,
230 ((
const CHECKER *)checker)->checkEndAnalysis(G, BR, Eng);
234 template <
typename CHECKER>
242 template <
typename CHECKER>
244 ((
const CHECKER *)checker)->checkBeginFunction(
C);
248 template <
typename CHECKER>
251 checker, _checkBeginFunction<CHECKER>));
256 template <
typename CHECKER>
257 static void _checkEndFunction(
void *checker,
const ReturnStmt *RS,
259 ((
const CHECKER *)checker)->checkEndFunction(RS,
C);
263 template <
typename CHECKER>
271 template <
typename CHECKER>
272 static void _checkBranchCondition(
void *checker,
const Stmt *
Condition,
278 template <
typename CHECKER>
282 _checkBranchCondition<CHECKER>));
287 template <
typename CHECKER>
290 ((
const CHECKER *)checker)->checkNewAllocator(Call,
C);
294 template <
typename CHECKER>
298 _checkNewAllocator<CHECKER>));
303 template <
typename CHECKER>
306 ((
const CHECKER *)checker)->checkLiveSymbols(state, SR);
310 template <
typename CHECKER>
318 template <
typename CHECKER>
319 static void _checkDeadSymbols(
void *checker,
321 ((
const CHECKER *)checker)->checkDeadSymbols(SR,
C);
325 template <
typename CHECKER>
333 template <
typename CHECKER>
335 _checkRegionChanges(
void *checker,
342 return ((
const CHECKER *) checker)->checkRegionChanges(state, invalidated,
348 template <
typename CHECKER>
352 _checkRegionChanges<CHECKER>));
357 template <
typename CHECKER>
359 _checkPointerEscape(
void *
Checker,
373 for (InvalidatedSymbols::const_iterator I = Escaped.begin(),
374 E = Escaped.end(); I != E; ++I)
379 RegularEscape.insert(*I);
381 if (RegularEscape.empty())
391 template <
typename CHECKER>
395 _checkPointerEscape<CHECKER>));
400 template <
typename CHECKER>
402 _checkConstPointerEscape(
void *
Checker,
413 for (InvalidatedSymbols::const_iterator I = Escaped.begin(),
414 E = Escaped.end(); I != E; ++I)
419 ConstEscape.insert(*I);
421 if (ConstEscape.empty())
431 template <
typename CHECKER>
435 _checkConstPointerEscape<CHECKER>));
440template <
typename EVENT>
442 template <
typename CHECKER>
443 static void _checkEvent(
void *checker,
const void *event) {
444 ((
const CHECKER *)checker)->checkEvent(*(
const EVENT *)event);
447 template <
typename CHECKER>
459 template <
typename CHECKER>
464 return ((
const CHECKER *)checker)->evalAssume(state, cond, assumption);
468 template <
typename CHECKER>
476 template <
typename CHECKER>
483 template <
typename CHECKER>
494 friend class ::clang::ento::CheckerManager;
502 const char *NL,
const char *Sep)
const { }
506raw_ostream&
operator<<(raw_ostream &Out,
const CheckerBase &Checker);
516template <
typename CHECK1,
typename... CHECKs>
519 template <
typename CHECKER>
521 CHECK1::_register(checker, mgr);
526template <
typename CHECK1>
529 template <
typename CHECKER>
531 CHECK1::_register(checker, mgr);
535template <
typename EVENT>
541 template <
typename CHECKER>
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN)
Defines the clang::LangOptions interface.
Decl - This represents one declaration (or definition), e.g.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Stmt - This represents one statement.
The top declaration context.
BugReporter is a utility class for generating PathDiagnostics for analysis.
Represents the memory allocation call in a C++ new-expression.
Represents an abstract call to a function or method along a particular path.
CheckerNameRef getCheckerName() const
virtual void printState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep) const
See CheckerManager::runCheckersForPrintState.
StringRef getTagDescription() const override
void _registerForLiveSymbols(CheckLiveSymbolsFunc checkfn)
void _registerForEndOfTranslationUnit(CheckEndOfTranslationUnit checkfn)
void _registerForBeginFunction(CheckBeginFunctionFunc checkfn)
void _registerForNewAllocator(CheckNewAllocatorFunc checkfn)
void _registerForPreCall(CheckCallFunc checkfn)
void _registerForObjCMessageNil(CheckObjCMessageFunc checkfn)
void _registerForDecl(CheckDeclFunc checkfn, HandlesDeclFunc isForDeclFn)
void _registerForPreObjCMessage(CheckObjCMessageFunc checkfn)
CheckerFn< void(const void *event)> CheckEventFunc
void _registerListenerForEvent(CheckEventFunc checkfn)
void _registerForEvalAssume(EvalAssumeFunc checkfn)
void _registerForEndAnalysis(CheckEndAnalysisFunc checkfn)
void _registerForBody(CheckDeclFunc checkfn)
void _registerForDeadSymbols(CheckDeadSymbolsFunc checkfn)
void _registerForPostObjCMessage(CheckObjCMessageFunc checkfn)
void _registerForRegionChanges(CheckRegionChangesFunc checkfn)
void _registerForBind(CheckBindFunc checkfn)
void _registerForPointerEscape(CheckPointerEscapeFunc checkfn)
void _registerForPreStmt(CheckStmtFunc checkfn, HandlesStmtFunc isForStmtFn)
void _registerForPostStmt(CheckStmtFunc checkfn, HandlesStmtFunc isForStmtFn)
void _registerForBranchCondition(CheckBranchConditionFunc checkfn)
void _dispatchEvent(const EVENT &event) const
void _registerForEvalCall(EvalCallFunc checkfn)
void _registerForEndFunction(CheckEndFunctionFunc checkfn)
void _registerDispatcherForEvent()
void _registerForLocation(CheckLocationFunc checkfn)
void _registerForPostCall(CheckCallFunc checkfn)
This wrapper is used to ensure that only StringRefs originating from the CheckerRegistry are used as ...
Tag that can use a checker name as a message provider (see SimpleProgramPointTag).
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
void dispatchEvent(const EVENT &event) const
Represents any expression that calls an Objective-C method.
Information about invalidation for a particular region/symbol.
@ TK_PreserveContents
Tells that a region's contents is not changed.
@ TK_SuppressEscape
Suppress pointer-escaping of a region.
bool hasTrait(SymbolRef Sym, InvalidationKinds IK) const
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.
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
static void _register(CHECKER *checker, CheckerManager &mgr)
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
raw_ostream & operator<<(raw_ostream &Out, const CheckerBase &Checker)
Dump checker name to stream.
@ C
Languages that the frontend can parse and compile.
We dereferenced a location that may be null.