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) {}
125 : Context(Context), LangOpts(Context.getLangOpts()), AOptions(AOptions) {}
132 bool hasPathSensitiveCheckers()
const;
134 void finishedCheckerRegistration();
153 template <
typename CHECKER,
typename... AT>
158 return static_cast<CHECKER *
>(ref);
161 checker->Name = CurrentCheckName;
162 CheckerDtors.push_back(
CheckerDtor(checker, destruct<CHECKER>));
163 CHECKER::_register(checker, *
this);
194 runCheckersForStmt(
true, Dst, Src, S, Eng);
207 bool wasInlined =
false) {
208 runCheckersForStmt(
false, Dst, Src, S, Eng, wasInlined);
212 void runCheckersForStmt(
bool isPreVisit,
215 bool wasInlined =
false);
230 bool wasInlined =
false) {
249 bool wasInlined =
false);
254 runCheckersForCallEvent(
true, Dst, Src, Call, Eng);
260 bool wasInlined =
false) {
261 runCheckersForCallEvent(
false, Dst, Src, Call, Eng,
269 bool wasInlined =
false);
305 void runCheckersForBranchCondition(
const Stmt *condition,
314 bool wasInlined =
false);
378 SVal Cond,
bool Assumption);
401 const char *NL,
const char *Sep);
533 template <
typename EVENT>
535 EventInfo &info = Events[&EVENT::Tag];
536 info.Checkers.push_back(checkfn);
539 template <
typename EVENT>
541 EventInfo &info = Events[&EVENT::Tag];
542 info.HasDispatcher =
true;
545 template <
typename EVENT>
547 EventsTy::const_iterator I = Events.find(&EVENT::Tag);
548 if (I == Events.end())
550 const EventInfo &info = I->second;
551 for (
const auto Checker : info.Checkers)
560 template <
typename CHECKER>
561 static void destruct(
void *obj) {
delete static_cast<CHECKER *
>(obj); }
563 template <
typename T>
564 static void *getTag() {
static int tag;
return &tag; }
566 llvm::DenseMap<CheckerTag, CheckerRef> CheckerTags;
568 std::vector<CheckerDtor> CheckerDtors;
570 struct DeclCheckerInfo {
574 std::vector<DeclCheckerInfo> DeclCheckers;
576 std::vector<CheckDeclFunc> BodyCheckers;
579 using CachedDeclCheckersMapTy = llvm::DenseMap<unsigned, CachedDeclCheckers>;
580 CachedDeclCheckersMapTy CachedDeclCheckersMap;
582 struct StmtCheckerInfo {
587 std::vector<StmtCheckerInfo> StmtCheckers;
590 using CachedStmtCheckersMapTy = llvm::DenseMap<unsigned, CachedStmtCheckers>;
591 CachedStmtCheckersMapTy CachedStmtCheckersMap;
598 const std::vector<CheckObjCMessageFunc> &
601 std::vector<CheckObjCMessageFunc> PreObjCMessageCheckers;
602 std::vector<CheckObjCMessageFunc> PostObjCMessageCheckers;
603 std::vector<CheckObjCMessageFunc> ObjCMessageNilCheckers;
605 std::vector<CheckCallFunc> PreCallCheckers;
606 std::vector<CheckCallFunc> PostCallCheckers;
608 std::vector<CheckLocationFunc> LocationCheckers;
610 std::vector<CheckBindFunc> BindCheckers;
612 std::vector<CheckEndAnalysisFunc> EndAnalysisCheckers;
614 std::vector<CheckBeginFunctionFunc> BeginFunctionCheckers;
615 std::vector<CheckEndFunctionFunc> EndFunctionCheckers;
617 std::vector<CheckBranchConditionFunc> BranchConditionCheckers;
619 std::vector<CheckNewAllocatorFunc> NewAllocatorCheckers;
621 std::vector<CheckLiveSymbolsFunc> LiveSymbolsCheckers;
623 std::vector<CheckDeadSymbolsFunc> DeadSymbolsCheckers;
625 std::vector<CheckRegionChangesFunc> RegionChangesCheckers;
627 std::vector<CheckPointerEscapeFunc> PointerEscapeCheckers;
629 std::vector<EvalAssumeFunc> EvalAssumeCheckers;
631 std::vector<EvalCallFunc> EvalCallCheckers;
633 std::vector<CheckEndOfTranslationUnit> EndOfTranslationUnitCheckers;
637 bool HasDispatcher =
false;
639 EventInfo() =
default;
642 using EventsTy = llvm::DenseMap<EventTag, EventInfo>;
650 #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...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CheckerManager(ASTContext &Context, AnalyzerOptions &AOptions)
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
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;...
BugReporter is a utility class for generating PathDiagnostics for analysis.
void _registerListenerForEvent(CheckEventFunc checkfn)
CHECKER * registerChecker(AT &&... Args)
Used to register checkers.
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...
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.
#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI)
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.
Stores options for the analyzer from the command line.
bool(*)(const Decl *D) HandlesDeclFunc
The top declaration context.
ASTContext & getASTContext()
const LangOptions & getLangOpts() const