From 35ff5b0ee677a1d14b2a8107d3c6f4e6785d6d4d Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 7 Jan 2008 22:22:13 +0000 Subject: [PATCH] Added more boilerplate for processing end-of-paths. llvm-svn: 45724 --- clang/Analysis/ReachabilityEngine.cpp | 6 ++++- .../PathSensitive/ReachabilityEngine.h | 24 +++++++------------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/clang/Analysis/ReachabilityEngine.cpp b/clang/Analysis/ReachabilityEngine.cpp index 02804b10dd2b..679be51351e8 100644 --- a/clang/Analysis/ReachabilityEngine.cpp +++ b/clang/Analysis/ReachabilityEngine.cpp @@ -130,7 +130,11 @@ void ReachabilityEngineImpl::ProcessBlkBlk(const BlkBlkEdge& E, if (Blk == &cfg.getExit()) { assert (cfg.getExit().size() == 0 && "EXIT block cannot contain Stmts."); // Process the End-Of-Path. - ProcessEOP(Blk, Pred); + void* State = ProcessEOP(Blk, Pred->State); + bool IsNew; + ExplodedNodeImpl* V = G->getNodeImpl(BlkStmtEdge(Blk,NULL),State,&IsNew); + V->addUntypedPredecessor(Pred); + if (IsNew) G->addEndOfPath(V); return; } diff --git a/clang/include/clang/Analysis/PathSensitive/ReachabilityEngine.h b/clang/include/clang/Analysis/PathSensitive/ReachabilityEngine.h index d53c7f102f1b..d4b5f38da98f 100644 --- a/clang/include/clang/Analysis/PathSensitive/ReachabilityEngine.h +++ b/clang/include/clang/Analysis/PathSensitive/ReachabilityEngine.h @@ -102,7 +102,7 @@ protected: void ProcessBlkStmt(const BlkStmtEdge& E, ExplodedNodeImpl* Pred); void ProcessStmtBlk(const StmtBlkEdge& E, ExplodedNodeImpl* Pred); - virtual void ProcessEOP(CFGBlock* Blk, ExplodedNodeImpl* Pred); + virtual void* ProcessEOP(CFGBlock* Blk, void* State); virtual void ProcessStmt(Stmt* S, ExplodedNodeImpl* Pred); virtual void ProcessTerminator(Stmt* Terminator, ExplodedNodeImpl* Pred); @@ -136,16 +136,10 @@ protected: return (void*) getCheckerState()->getInitialState(); } - virtual void ProcessEOP(CFGBlock* Blk, ExplodedNodeImpl* Pred) { - assert (false && "Not implemented yet."); + virtual void* ProcessEOP(CFGBlock* Blk, void* State) { // FIXME: Perform dispatch to adjust state. -// ExplodedNodeImpl* V = G->getNodeImpl(BlkStmtEdge(Blk,NULL), -// Pred->State).first; - -// V->addPredecessor(Pred); -// Graph.addEndOfPath(V); + return State; } - virtual void ProcessStmt(Stmt* S, ExplodedNodeImpl* Pred) { CurrentBlkExpr = S; @@ -170,14 +164,12 @@ public: ReachabilityEngine(CFG& cfg, reng::WorkList* wlist) : ReachabilityEngineImpl(cfg,wlist) {} - /// getGraph - Returns the exploded graph. Ownership of the graph remains - /// with the ReachabilityEngine object. - GraphTy* getGraph() const { return static_cast(G.get()); } + /// getGraph - Returns the exploded graph. + GraphTy& getGraph() { return *static_cast(G.get()); } - /// getCheckerState - Returns the internal checker state. Ownership is not - /// transferred to the caller. - CheckerTy* getCheckerState() const { - return static_cast(G.get())->getCheckerState(); + /// getCheckerState - Returns the internal checker state. + CheckerTy& getCheckerState() { + return *static_cast(G.get())->getCheckerState(); } /// takeGraph - Returns the exploded graph. Ownership of the graph is