diff options
author | Anna Zaks <ganna@apple.com> | 2011-10-25 19:56:48 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-10-25 19:56:48 +0000 |
commit | af498a28797c075c48d7e943df5f5a8e78ed8eb0 (patch) | |
tree | 49186d578c20198b3b26cad2a5a743e037db8aa0 /include/clang/StaticAnalyzer/Core | |
parent | 7fe3878a36750515fb9772414ecb2489cf149d19 (diff) |
[analyze] Convert EndOfPath callback to use CheckerContext
Get rid of the EndOfPathBuilder completely.
Use the generic NodeBuilder to generate nodes.
Enqueue the end of path frontier explicitly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142943 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/StaticAnalyzer/Core')
5 files changed, 15 insertions, 62 deletions
diff --git a/include/clang/StaticAnalyzer/Core/Checker.h b/include/clang/StaticAnalyzer/Core/Checker.h index 2e270000c7..181080a213 100644 --- a/include/clang/StaticAnalyzer/Core/Checker.h +++ b/include/clang/StaticAnalyzer/Core/Checker.h @@ -199,9 +199,9 @@ public: class EndPath { template <typename CHECKER> - static void _checkEndPath(void *checker, EndOfFunctionNodeBuilder &B, - ExprEngine &Eng) { - ((const CHECKER *)checker)->checkEndPath(B, Eng); + static void _checkEndPath(void *checker, + CheckerContext &C) { + ((const CHECKER *)checker)->checkEndPath(C); } public: diff --git a/include/clang/StaticAnalyzer/Core/CheckerManager.h b/include/clang/StaticAnalyzer/Core/CheckerManager.h index 6da75a948a..e74bd8b826 100644 --- a/include/clang/StaticAnalyzer/Core/CheckerManager.h +++ b/include/clang/StaticAnalyzer/Core/CheckerManager.h @@ -39,8 +39,8 @@ namespace ento { class ExplodedNodeSet; class ExplodedGraph; class ProgramState; - class EndOfFunctionNodeBuilder; class NodeBuilder; + struct NodeBuilderContext; class MemRegion; class SymbolReaper; @@ -230,7 +230,9 @@ public: 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, @@ -334,7 +336,7 @@ public: typedef CheckerFn<void (ExplodedGraph &, BugReporter &, ExprEngine &)> CheckEndAnalysisFunc; - typedef CheckerFn<void (EndOfFunctionNodeBuilder &, ExprEngine &)> + typedef CheckerFn<void (CheckerContext &)> CheckEndPathFunc; typedef CheckerFn<void (const Stmt *, NodeBuilder &, ExplodedNode *Pred, diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h index dad77dad3b..5fddb75d1f 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h @@ -171,9 +171,9 @@ public: struct NodeBuilderContext { CoreEngine &Eng; const CFGBlock *Block; - ExplodedNode *ContextPred; + ExplodedNode *Pred; NodeBuilderContext(CoreEngine &E, const CFGBlock *B, ExplodedNode *N) - : Eng(E), Block(B), ContextPred(N) { assert(B); assert(!N->isSink()); } + : Eng(E), Block(B), Pred(N) { assert(B); assert(!N->isSink()); } /// \brief Return the CFGBlock associated with this builder. const CFGBlock *getBlock() const { return Block; } @@ -182,10 +182,9 @@ struct NodeBuilderContext { /// visited on the exploded graph path. unsigned getCurrentBlockCount() const { return Eng.WList->getBlockCounter().getNumVisited( - ContextPred->getLocationContext()->getCurrentStackFrame(), + Pred->getLocationContext()->getCurrentStackFrame(), Block->getBlockID()); } - }; /// \class NodeBuilder @@ -289,15 +288,6 @@ public: void addNodes(ExplodedNode *N) { Frontier.Add(N); } }; -class CommonNodeBuilder { -protected: - ExplodedNode *Pred; - CoreEngine &Eng; - - CommonNodeBuilder(CoreEngine* E, ExplodedNode *P) : Pred(P), Eng(*E) {} - BlockCounter getBlockCounter() const { return Eng.WList->getBlockCounter(); } -}; - /// \class StmtNodeBuilder /// \brief This builder class is useful for generating nodes that resulted from /// visiting a statement. The main difference from it's parent NodeBuilder is @@ -523,47 +513,6 @@ public: const PP_T &getProgramPoint() const { return cast<PP_T>(pp); } }; -class EndOfFunctionNodeBuilder : public CommonNodeBuilder { - const CFGBlock &B; - const ProgramPointTag *Tag; - -public: - bool hasGeneratedNode; - -public: - EndOfFunctionNodeBuilder(const CFGBlock *b, ExplodedNode *N, CoreEngine* e, - const ProgramPointTag *tag = 0) - : CommonNodeBuilder(e, N), B(*b), Tag(tag), hasGeneratedNode(false) {} - - ~EndOfFunctionNodeBuilder(); - - EndOfFunctionNodeBuilder withCheckerTag(const ProgramPointTag *tag) { - return EndOfFunctionNodeBuilder(&B, Pred, &Eng, tag); - } - - WorkList &getWorkList() { return *Eng.WList; } - - ExplodedNode *getPredecessor() const { return Pred; } - - unsigned getCurrentBlockCount() const { - return getBlockCounter().getNumVisited( - Pred->getLocationContext()->getCurrentStackFrame(), - B.getBlockID()); - } - - ExplodedNode *generateNode(const ProgramState *State, - ExplodedNode *P = 0, - const ProgramPointTag *tag = 0); - - void GenerateCallExitNode(const ProgramState *state); - - const CFGBlock *getBlock() const { return &B; } - - const ProgramState *getState() const { - return getPredecessor()->getState(); - } -}; - class CallEnterNodeBuilder { CoreEngine &Eng; diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index 0fb8dad650..325d824090 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -124,6 +124,8 @@ public: const Stmt *getStmt() const; void GenerateAutoTransition(ExplodedNode *N); + void enqueueEndOfPath(ExplodedNodeSet &S); + void GenerateCallExitNode(ExplodedNode *N); /// ViewGraph - Visualize the ExplodedGraph created by executing the /// simulation. @@ -181,7 +183,7 @@ public: /// ProcessEndPath - Called by CoreEngine. Used to generate end-of-path /// nodes when the control reaches the end of a function. - void processEndOfFunction(EndOfFunctionNodeBuilder& builder); + void processEndOfFunction(NodeBuilderContext& BC); /// Generate the entry node of the callee. void processCallEnter(CallEnterNodeBuilder &builder); diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h index 8989a723e5..c35e6cca41 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h @@ -82,7 +82,7 @@ public: /// Called by CoreEngine. Used to generate end-of-path /// nodes when the control reaches the end of a function. - virtual void processEndOfFunction(EndOfFunctionNodeBuilder& builder) = 0; + virtual void processEndOfFunction(NodeBuilderContext& BC) = 0; // Generate the entry node of the callee. virtual void processCallEnter(CallEnterNodeBuilder &builder) = 0; |