14 #ifndef LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H 15 #define LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H 21 #include "llvm/ADT/ArrayRef.h" 22 #include "llvm/ADT/DenseMap.h" 23 #include "llvm/ADT/SmallVector.h" 24 #include "llvm/ADT/StringRef.h" 29 class AnalyzerOptions;
33 class LocationContext;
35 class TranslationUnitDecl;
39 class AnalysisManager;
44 class CheckerRegistry;
47 class ExplodedNodeSet;
50 struct NodeBuilderContext;
52 class RegionAndSymbolInvalidationTraits;
58 template <
typename RET,
typename... Ps>
60 using Func = RET (*)(
void *, Ps...);
70 return Fn(Checker, ps...);
99 friend class ::clang::ento::CheckerRegistry;
103 explicit CheckName(StringRef Name) : Name(Name) {}
124 : LangOpts(langOpts), AOptions(AOptions) {}
131 bool hasPathSensitiveCheckers()
const;
133 void finishedCheckerRegistration();
151 template <
typename CHECKER,
typename... AT>
156 return static_cast<CHECKER *
>(ref);
159 checker->Name = CurrentCheckName;
160 CheckerDtors.push_back(
CheckerDtor(checker, destruct<CHECKER>));
161 CHECKER::_register(checker, *
this);
192 runCheckersForStmt(
true, Dst, Src, S, Eng);
205 bool wasInlined =
false) {
206 runCheckersForStmt(
false, Dst, Src, S, Eng, wasInlined);
210 void runCheckersForStmt(
bool isPreVisit,
213 bool wasInlined =
false);
228 bool wasInlined =
false) {
247 bool wasInlined =
false);
252 runCheckersForCallEvent(
true, Dst, Src, Call, Eng);
258 bool wasInlined =
false) {
259 runCheckersForCallEvent(
false, Dst, Src, Call, Eng,
267 bool wasInlined =
false);
303 void runCheckersForBranchCondition(
const Stmt *condition,
312 bool wasInlined =
false);
376 SVal Cond,
bool Assumption);
399 const char *NL,
const char *Sep);
531 template <
typename EVENT>
533 EventInfo &info = Events[getTag<EVENT>()];
534 info.Checkers.push_back(checkfn);
537 template <
typename EVENT>
539 EventInfo &info = Events[getTag<EVENT>()];
540 info.HasDispatcher =
true;
543 template <
typename EVENT>
545 EventsTy::const_iterator I = Events.find(getTag<EVENT>());
546 if (I == Events.end())
548 const EventInfo &info = I->second;
549 for (
const auto Checker : info.Checkers)
558 template <
typename CHECKER>
559 static void destruct(
void *obj) {
delete static_cast<CHECKER *
>(obj); }
561 template <
typename T>
562 static void *getTag() {
static int tag;
return &tag; }
564 llvm::DenseMap<CheckerTag, CheckerRef> CheckerTags;
566 std::vector<CheckerDtor> CheckerDtors;
568 struct DeclCheckerInfo {
572 std::vector<DeclCheckerInfo> DeclCheckers;
574 std::vector<CheckDeclFunc> BodyCheckers;
577 using CachedDeclCheckersMapTy = llvm::DenseMap<unsigned, CachedDeclCheckers>;
578 CachedDeclCheckersMapTy CachedDeclCheckersMap;
580 struct StmtCheckerInfo {
585 std::vector<StmtCheckerInfo> StmtCheckers;
588 using CachedStmtCheckersMapTy = llvm::DenseMap<unsigned, CachedStmtCheckers>;
589 CachedStmtCheckersMapTy CachedStmtCheckersMap;
596 const std::vector<CheckObjCMessageFunc> &
599 std::vector<CheckObjCMessageFunc> PreObjCMessageCheckers;
600 std::vector<CheckObjCMessageFunc> PostObjCMessageCheckers;
601 std::vector<CheckObjCMessageFunc> ObjCMessageNilCheckers;
603 std::vector<CheckCallFunc> PreCallCheckers;
604 std::vector<CheckCallFunc> PostCallCheckers;
606 std::vector<CheckLocationFunc> LocationCheckers;
608 std::vector<CheckBindFunc> BindCheckers;
610 std::vector<CheckEndAnalysisFunc> EndAnalysisCheckers;
612 std::vector<CheckBeginFunctionFunc> BeginFunctionCheckers;
613 std::vector<CheckEndFunctionFunc> EndFunctionCheckers;
615 std::vector<CheckBranchConditionFunc> BranchConditionCheckers;
617 std::vector<CheckNewAllocatorFunc> NewAllocatorCheckers;
619 std::vector<CheckLiveSymbolsFunc> LiveSymbolsCheckers;
621 std::vector<CheckDeadSymbolsFunc> DeadSymbolsCheckers;
623 std::vector<CheckRegionChangesFunc> RegionChangesCheckers;
625 std::vector<CheckPointerEscapeFunc> PointerEscapeCheckers;
627 std::vector<EvalAssumeFunc> EvalAssumeCheckers;
629 std::vector<EvalCallFunc> EvalCallCheckers;
631 std::vector<CheckEndOfTranslationUnit> EndOfTranslationUnitCheckers;
635 bool HasDispatcher =
false;
637 EventInfo() =
default;
640 using EventsTy = llvm::DenseMap<EventTag, EventInfo>;
648 #endif // LLVM_CLANG_STATICANALYZER_CORE_CHECKERMANAGER_H
void _dispatchEvent(const EVENT &event) const
Stmt - This represents one statement.
Information about invalidation for a particular region/symbol.
Decl - This represents one declaration (or definition), e.g.
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
The pointer has been passed to a function indirectly.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void runCheckersForObjCMessageNil(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng)
Run checkers for visiting an obj-c message to nil.
A pointer escapes due to binding its value to a location that the analyzer cannot track...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void runCheckersForPostObjCMessage(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting obj-c messages.
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
#define CHECKER(FULLNAME, CLASS, DESCFILE, HELPTEXT, GROUPINDEX, HIDDEN)
Represents any expression that calls an Objective-C method.
bool(*)(const Stmt *D) HandlesStmtFunc
void runCheckersForPreCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng)
Run checkers for pre-visiting obj-c messages.
void setCurrentCheckName(CheckName name)
void runCheckersForPostCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const CallEvent &Call, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting obj-c messages.
CheckName getCurrentCheckName() const
CheckerFn(CheckerBase *checker, Func fn)
StringRef getName() const
void runCheckersForPostStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng, bool wasInlined=false)
Run checkers for post-visiting Stmts.
Defines the clang::LangOptions interface.
void runCheckersForPreObjCMessage(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const ObjCMethodCall &msg, ExprEngine &Eng)
Run checkers for pre-visiting obj-c messages.
The pointer has been passed to a function call directly.
RET operator()(Ps... ps) const
The reason for pointer escape is unknown.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
CHECKER * registerChecker(AT... Args)
Used to register checkers.
BugReporter is a utility class for generating PathDiagnostics for analysis.
void _registerListenerForEvent(CheckEventFunc checkfn)
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
CheckerManager(const LangOptions &langOpts, AnalyzerOptions &AOptions)
A class responsible for cleaning up unused symbols.
void _registerDispatcherForEvent()
void runCheckersForPreStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, ExprEngine &Eng)
Run checkers for pre-visiting Stmts.
Dataflow Directional Tag Classes.
Represents an abstract call to a function or method along a particular path.
AnalyzerOptions & getAnalyzerOptions()
PointerEscapeKind
Describes the different reasons a pointer escapes during analysis.
bool(*)(const Decl *D) HandlesDeclFunc
The top declaration context.
const LangOptions & getLangOpts() const