diff options
Diffstat (limited to 'include/clang/StaticAnalyzer/Core/CheckerManager.h')
| -rw-r--r-- | include/clang/StaticAnalyzer/Core/CheckerManager.h | 83 |
1 files changed, 55 insertions, 28 deletions
diff --git a/include/clang/StaticAnalyzer/Core/CheckerManager.h b/include/clang/StaticAnalyzer/Core/CheckerManager.h index e3e4c49f71e11..d215f992e68ef 100644 --- a/include/clang/StaticAnalyzer/Core/CheckerManager.h +++ b/include/clang/StaticAnalyzer/Core/CheckerManager.h @@ -19,6 +19,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/FoldingSet.h" #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h" +#include "clang/Analysis/ProgramPoint.h" #include <vector> namespace clang { @@ -38,8 +39,8 @@ namespace ento { class ExplodedNodeSet; class ExplodedGraph; class ProgramState; - class EndOfFunctionNodeBuilder; - class BranchNodeBuilder; + class NodeBuilder; + struct NodeBuilderContext; class MemRegion; class SymbolReaper; @@ -51,6 +52,19 @@ public: template <typename T> class CheckerFn; +template <typename RET, typename P1, typename P2, typename P3, typename P4, + typename P5> +class CheckerFn<RET(P1, P2, P3, P4, P5)> { + typedef RET (*Func)(void *, P1, P2, P3, P4, P5); + Func Fn; +public: + CheckerBase *Checker; + CheckerFn(CheckerBase *checker, Func fn) : Fn(fn), Checker(checker) { } + RET operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const { + return Fn(Checker, p1, p2, p3, p4, p5); + } +}; + template <typename RET, typename P1, typename P2, typename P3, typename P4> class CheckerFn<RET(P1, P2, P3, P4)> { typedef RET (*Func)(void *, P1, P2, P3, P4); @@ -114,7 +128,7 @@ public: void finishedCheckerRegistration(); - const LangOptions &getLangOptions() const { return LangOpts; } + const LangOptions &getLangOpts() const { return LangOpts; } typedef CheckerBase *CheckerRef; typedef const void *CheckerTag; @@ -179,14 +193,16 @@ public: void runCheckersForPostStmt(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, const Stmt *S, - ExprEngine &Eng) { - runCheckersForStmt(/*isPreVisit=*/false, Dst, Src, S, Eng); + ExprEngine &Eng, + bool wasInlined = false) { + runCheckersForStmt(/*isPreVisit=*/false, Dst, Src, S, Eng, wasInlined); } /// \brief Run checkers for visiting Stmts. void runCheckersForStmt(bool isPreVisit, ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, - const Stmt *S, ExprEngine &Eng); + const Stmt *S, ExprEngine &Eng, + bool wasInlined = false); /// \brief Run checkers for pre-visiting obj-c messages. void runCheckersForPreObjCMessage(ExplodedNodeSet &Dst, @@ -213,33 +229,39 @@ public: /// \brief Run checkers for load/store of a location. void runCheckersForLocation(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, - SVal location, bool isLoad, - const Stmt *S, + SVal location, + bool isLoad, + const Stmt *NodeEx, + const Stmt *BoundEx, ExprEngine &Eng); /// \brief Run checkers for binding of a value to a location. void runCheckersForBind(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, SVal location, SVal val, - const Stmt *S, ExprEngine &Eng); + const Stmt *S, ExprEngine &Eng, + ProgramPoint::Kind PointKind); /// \brief Run checkers for end of analysis. void runCheckersForEndAnalysis(ExplodedGraph &G, BugReporter &BR, ExprEngine &Eng); /// \brief Run checkers for end of path. - void runCheckersForEndPath(EndOfFunctionNodeBuilder &B, ExprEngine &Eng); + void runCheckersForEndPath(NodeBuilderContext &BC, + ExplodedNodeSet &Dst, + ExprEngine &Eng); /// \brief Run checkers for branch condition. void runCheckersForBranchCondition(const Stmt *condition, - BranchNodeBuilder &B, ExprEngine &Eng); + ExplodedNodeSet &Dst, ExplodedNode *Pred, + ExprEngine &Eng); /// \brief Run checkers for live symbols. /// /// Allows modifying SymbolReaper object. For example, checkers can explicitly /// register symbols of interest as live. These symbols will not be marked /// dead and removed. - void runCheckersForLiveSymbols(const ProgramState *state, + void runCheckersForLiveSymbols(ProgramStateRef state, SymbolReaper &SymReaper); /// \brief Run checkers for dead symbols. @@ -253,7 +275,7 @@ public: ExprEngine &Eng); /// \brief True if at least one checker wants to check region changes. - bool wantsRegionChangeUpdate(const ProgramState *state); + bool wantsRegionChangeUpdate(ProgramStateRef state); /// \brief Run checkers for region changes. /// @@ -264,15 +286,18 @@ public: /// For example, in the case of a function call, these would be arguments. /// \param Regions The transitive closure of accessible regions, /// i.e. all regions that may have been touched by this change. - const ProgramState * - runCheckersForRegionChanges(const ProgramState *state, + /// \param The call expression wrapper if the regions are invalidated by a + /// call. + ProgramStateRef + runCheckersForRegionChanges(ProgramStateRef state, const StoreManager::InvalidatedSymbols *invalidated, ArrayRef<const MemRegion *> ExplicitRegions, - ArrayRef<const MemRegion *> Regions); + ArrayRef<const MemRegion *> Regions, + const CallOrObjCMessage *Call); /// \brief Run checkers for handling assumptions on symbolic values. - const ProgramState *runCheckersForEvalAssume(const ProgramState *state, - SVal Cond, bool Assumption); + ProgramStateRef runCheckersForEvalAssume(ProgramStateRef state, + SVal Cond, bool Assumption); /// \brief Run checkers for evaluating a call. void runCheckersForEvalCall(ExplodedNodeSet &Dst, @@ -293,7 +318,7 @@ public: /// \param State The state being printed /// \param NL The preferred representation of a newline. /// \param Sep The preferred separator between different kinds of data. - void runCheckersForPrintState(raw_ostream &Out, const ProgramState *State, + void runCheckersForPrintState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep); //===----------------------------------------------------------------------===// @@ -320,7 +345,8 @@ public: typedef CheckerFn<void (const ObjCMessage &, CheckerContext &)> CheckObjCMessageFunc; - typedef CheckerFn<void (const SVal &location, bool isLoad, const Stmt *S, + typedef CheckerFn<void (const SVal &location, bool isLoad, + const Stmt *S, CheckerContext &)> CheckLocationFunc; @@ -331,26 +357,27 @@ public: typedef CheckerFn<void (ExplodedGraph &, BugReporter &, ExprEngine &)> CheckEndAnalysisFunc; - typedef CheckerFn<void (EndOfFunctionNodeBuilder &, ExprEngine &)> + typedef CheckerFn<void (CheckerContext &)> CheckEndPathFunc; - typedef CheckerFn<void (const Stmt *, BranchNodeBuilder &, ExprEngine &)> + typedef CheckerFn<void (const Stmt *, CheckerContext &)> CheckBranchConditionFunc; typedef CheckerFn<void (SymbolReaper &, CheckerContext &)> CheckDeadSymbolsFunc; - typedef CheckerFn<void (const ProgramState *,SymbolReaper &)> CheckLiveSymbolsFunc; + typedef CheckerFn<void (ProgramStateRef,SymbolReaper &)> CheckLiveSymbolsFunc; - typedef CheckerFn<const ProgramState * (const ProgramState *, + typedef CheckerFn<ProgramStateRef (ProgramStateRef, const StoreManager::InvalidatedSymbols *symbols, - ArrayRef<const MemRegion *> ExplicitRegions, - ArrayRef<const MemRegion *> Regions)> + ArrayRef<const MemRegion *> ExplicitRegions, + ArrayRef<const MemRegion *> Regions, + const CallOrObjCMessage *Call)> CheckRegionChangesFunc; - typedef CheckerFn<bool (const ProgramState *)> WantsRegionChangeUpdateFunc; + typedef CheckerFn<bool (ProgramStateRef)> WantsRegionChangeUpdateFunc; - typedef CheckerFn<const ProgramState * (const ProgramState *, + typedef CheckerFn<ProgramStateRef (ProgramStateRef, const SVal &cond, bool assumption)> EvalAssumeFunc; |
