diff options
Diffstat (limited to 'include/clang/Analysis')
-rw-r--r-- | include/clang/Analysis/PathSensitive/ExplodedGraph.h | 23 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GREngine.h | 17 |
2 files changed, 24 insertions, 16 deletions
diff --git a/include/clang/Analysis/PathSensitive/ExplodedGraph.h b/include/clang/Analysis/PathSensitive/ExplodedGraph.h index dc96c1c5a4..e69acda3e3 100644 --- a/include/clang/Analysis/PathSensitive/ExplodedGraph.h +++ b/include/clang/Analysis/PathSensitive/ExplodedGraph.h @@ -43,15 +43,15 @@ protected: friend class GRBranchNodeBuilderImpl; class NodeGroup { - enum { Size1 = 0x0, SizeOther = 0x1, Infeasible = 0x2, Flags = 0x3 }; + enum { Size1 = 0x0, SizeOther = 0x1, AuxFlag = 0x2, Mask = 0x3 }; uintptr_t P; unsigned getKind() const { - return P & Flags; + return P & Mask; } void* getPtr() const { - return reinterpret_cast<void*>(P & ~Flags); + return reinterpret_cast<void*>(P & ~Mask); } ExplodedNodeImpl* getNode() const { @@ -73,15 +73,14 @@ protected: void addNode(ExplodedNodeImpl* N); - void setInfeasibleFlag() { - P |= Infeasible; + void setFlag() { + P |= AuxFlag; } - bool getInfeasibleFlag() const { - return P & Infeasible ? true : false; + bool getFlag() const { + return P & AuxFlag ? true : false; } - }; - + }; /// Location - The program location (within a function body) associated /// with this node. @@ -105,7 +104,7 @@ protected: /// addPredeccessor - Adds a predecessor to the current node, and /// in tandem add this node as a successor of the other node. void addPredecessor(ExplodedNodeImpl* V) { - assert (!V->isInfeasible()); + assert (!V->isSink()); Preds.addNode(V); V->Succs.addNode(this); } @@ -129,8 +128,8 @@ public: bool succ_empty() const { return Succs.empty(); } bool pred_empty() const { return Preds.size(); } - bool isInfeasible() const { return Preds.getInfeasibleFlag(); } - void setInfeasible() { Preds.setInfeasibleFlag(); } + bool isSink() const { return Preds.getFlag(); } + void markAsSink() { Preds.setFlag(); } }; diff --git a/include/clang/Analysis/PathSensitive/GREngine.h b/include/clang/Analysis/PathSensitive/GREngine.h index 33976fa884..8c3fc12bb9 100644 --- a/include/clang/Analysis/PathSensitive/GREngine.h +++ b/include/clang/Analysis/PathSensitive/GREngine.h @@ -112,7 +112,7 @@ public: const ExplodedGraphImpl& getGraph() const { return *Eng.G; } inline ExplodedNodeImpl* getLastNode() { - return LastNode ? (LastNode->isInfeasible() ? NULL : LastNode) : NULL; + return LastNode ? (LastNode->isSink() ? NULL : LastNode) : NULL; } ExplodedNodeImpl* generateNodeImpl(Stmt* S, void* State, @@ -178,9 +178,10 @@ public: ~GRBranchNodeBuilderImpl(); + ExplodedNodeImpl* getPredecessor() const { return Pred; } const ExplodedGraphImpl& getGraph() const { return *Eng.G; } - void generateNodeImpl(void* State, bool branch); + ExplodedNodeImpl* generateNodeImpl(void* State, bool branch); void markInfeasible(bool branch) { if (branch) GeneratedTrue = true; @@ -203,10 +204,18 @@ public: const GraphTy& getGraph() const { return static_cast<const GraphTy&>(NB.getGraph()); } + + NodeTy* getPredecessor() const { + return static_cast<NodeTy*>(NB.getPredecessor()); + } + + StateTy getState() const { + return getPredecessor()->getState(); + } - inline void generateNode(StateTy State, bool branch) { + inline NodeTy* generateNode(StateTy State, bool branch) { void *state = GRTrait<StateTy>::toPtr(State); - NB.generateNodeImpl(state, branch); + return static_cast<NodeTy*>(NB.generateNodeImpl(state, branch)); } inline void markInfeasible(bool branch) { |