Static Value-Flow Analysis
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
SVF::ProgSlice Class Reference

#include <ProgSlice.h>

Public Types

typedef Set< const SVFGNode * > SVFGNodeSet
 
typedef SVFGNodeSet::const_iterator SVFGNodeSetIter
 
typedef SaberCondAllocator::Condition Condition
 
typedef Map< const SVFGNode *, ConditionSVFGNodeToCondMap
 map a SVFGNode to its condition during value-flow guard computation More...
 
typedef FIFOWorkList< const SVFGNode * > VFWorkList
 worklist for value-flow guard computation More...
 
typedef FIFOWorkList< const SVFBasicBlock * > CFWorkList
 worklist for control-flow guard computation More...
 
typedef SaberCondAllocator::SVFGNodeToSVFGNodeSetMap SVFGNodeToSVFGNodeSetMap
 

Public Member Functions

 ProgSlice (const SVFGNode *src, SaberCondAllocator *pa, const SVFG *graph)
 Constructor. More...
 
virtual ~ProgSlice ()
 Destructor. More...
 
u32_t getForwardSliceSize () const
 
u32_t getBackwardSliceSize () const
 
void addToForwardSlice (const SVFGNode *node)
 Forward and backward slice operations. More...
 
void addToBackwardSlice (const SVFGNode *node)
 
bool inForwardSlice (const SVFGNode *node)
 
bool inBackwardSlice (const SVFGNode *node)
 
SVFGNodeSetIter forwardSliceBegin () const
 
SVFGNodeSetIter forwardSliceEnd () const
 
SVFGNodeSetIter backwardSliceBegin () const
 
SVFGNodeSetIter backwardSliceEnd () const
 
const SVFGNodegetSource () const
 root and sink operations More...
 
void addToSinks (const SVFGNode *node)
 
const SVFGNodeSetgetSinks () const
 
SVFGNodeSetIter sinksBegin () const
 
SVFGNodeSetIter sinksEnd () const
 
void setPartialReachable ()
 
void setAllReachable ()
 
bool setReachGlobal ()
 
bool isPartialReachable () const
 
bool isAllReachable () const
 
bool isReachGlobal () const
 
bool AllPathReachableSolve ()
 Guarded reachability solve. More...
 
bool isSatisfiableForAll ()
 
bool isSatisfiableForPairs ()
 
const CallICFGNodegetCallSite (const SVFGEdge *edge) const
 Get callsite ID and get returnsiteID from SVFGEdge. More...
 
const CallICFGNodegetRetSite (const SVFGEdge *edge) const
 
Condition condAnd (const Condition &lhs, const Condition &rhs)
 Condition operations. More...
 
Condition condOr (const Condition &lhs, const Condition &rhs)
 
Condition condNeg (const Condition &cond)
 
Condition getTrueCond () const
 
Condition getFalseCond () const
 
std::string dumpCond (const Condition &cond) const
 
std::string evalFinalCond () const
 Evaluate final condition. More...
 
void evalFinalCond2Event (GenericBug::EventStack &eventStack) const
 Add final condition to eventStack. More...
 

Protected Member Functions

const SVFGgetSVFG () const
 
void destroy ()
 Release memory. More...
 
void clearCFCond ()
 Clear Control flow conditions before each VF computation. More...
 
Condition getVFCond (const SVFGNode *node) const
 Get/set VF (value-flow) and CF (control-flow) conditions. More...
 
bool setVFCond (const SVFGNode *node, const Condition &cond)
 
Condition ComputeIntraVFGGuard (const SVFBasicBlock *src, const SVFBasicBlock *dst)
 Compute guards for value-flows. More...
 
Condition ComputeInterCallVFGGuard (const SVFBasicBlock *src, const SVFBasicBlock *dst, const SVFBasicBlock *callBB)
 
Condition ComputeInterRetVFGGuard (const SVFBasicBlock *src, const SVFBasicBlock *dst, const SVFBasicBlock *retBB)
 
bool isEquivalentBranchCond (const Condition &lhs, const Condition &rhs) const
 
const SVFBasicBlockgetSVFGNodeBB (const SVFGNode *node) const
 
const SVFGNodegetCurSVFGNode () const
 Get/set current SVFG node. More...
 
void setCurSVFGNode (const SVFGNode *node)
 
void setFinalCond (const Condition &cond)
 Set final condition after all path reachability analysis. More...
 
Condition computeInvalidCondFromRemovedSUVFEdge (const SVFGNode *cur)
 Compute invalid branch condition stemming from removed strong update value-flow edges. More...
 
const SVFGNodeToSVFGNodeSetMapgetRemovedSUVFEdges () const
 

Private Attributes

SVFGNodeSet forwardslice
 the forward slice More...
 
SVFGNodeSet backwardslice
 the backward slice More...
 
SVFGNodeSet sinks
 a set of sink nodes More...
 
const SVFGNoderoot
 root node on the slice More...
 
SVFGNodeToCondMap svfgNodeToCondMap
 map a SVFGNode to its path condition starting from root More...
 
bool partialReachable
 reachable from some paths More...
 
bool fullReachable
 reachable from all paths More...
 
bool reachGlob
 Whether slice reach a global. More...
 
SaberCondAllocatorpathAllocator
 path condition allocator More...
 
const SVFGNode_curSVFGNode
 current svfg node during guard computation More...
 
Condition finalCond
 final condition More...
 
const SVFGsvfg
 SVFG. More...
 

Detailed Description

Definition at line 49 of file ProgSlice.h.

Member Typedef Documentation

◆ CFWorkList

worklist for control-flow guard computation

Definition at line 59 of file ProgSlice.h.

◆ Condition

Definition at line 55 of file ProgSlice.h.

◆ SVFGNodeSet

Definition at line 53 of file ProgSlice.h.

◆ SVFGNodeSetIter

typedef SVFGNodeSet::const_iterator SVF::ProgSlice::SVFGNodeSetIter

Definition at line 54 of file ProgSlice.h.

◆ SVFGNodeToCondMap

map a SVFGNode to its condition during value-flow guard computation

Definition at line 56 of file ProgSlice.h.

◆ SVFGNodeToSVFGNodeSetMap

Definition at line 61 of file ProgSlice.h.

◆ VFWorkList

worklist for value-flow guard computation

Definition at line 58 of file ProgSlice.h.

Constructor & Destructor Documentation

◆ ProgSlice()

SVF::ProgSlice::ProgSlice ( const SVFGNode src,
SaberCondAllocator pa,
const SVFG graph 
)
inline

Constructor.

Definition at line 65 of file ProgSlice.h.

65  :
66  root(src), partialReachable(false), fullReachable(false), reachGlob(false),
67  pathAllocator(pa), _curSVFGNode(nullptr), finalCond(pa->getFalseCond()), svfg(graph)
68  {
69  }
Condition finalCond
final condition
Definition: ProgSlice.h:321
bool partialReachable
reachable from some paths
Definition: ProgSlice.h:316
const SVFG * svfg
SVFG.
Definition: ProgSlice.h:322
bool fullReachable
reachable from all paths
Definition: ProgSlice.h:317
SaberCondAllocator * pathAllocator
path condition allocator
Definition: ProgSlice.h:319
bool reachGlob
Whether slice reach a global.
Definition: ProgSlice.h:318
const SVFGNode * root
root node on the slice
Definition: ProgSlice.h:314
const SVFGNode * _curSVFGNode
current svfg node during guard computation
Definition: ProgSlice.h:320

◆ ~ProgSlice()

virtual SVF::ProgSlice::~ProgSlice ( )
inlinevirtual

Destructor.

Definition at line 72 of file ProgSlice.h.

73  {
74  destroy();
75  }
void destroy()
Release memory.
Definition: ProgSlice.cpp:246

Member Function Documentation

◆ addToBackwardSlice()

void SVF::ProgSlice::addToBackwardSlice ( const SVFGNode node)
inline

Definition at line 91 of file ProgSlice.h.

92  {
93  backwardslice.insert(node);
94  }
SVFGNodeSet backwardslice
the backward slice
Definition: ProgSlice.h:312

◆ addToForwardSlice()

void SVF::ProgSlice::addToForwardSlice ( const SVFGNode node)
inline

Forward and backward slice operations.

Definition at line 87 of file ProgSlice.h.

88  {
89  forwardslice.insert(node);
90  }
SVFGNodeSet forwardslice
the forward slice
Definition: ProgSlice.h:311

◆ addToSinks()

void SVF::ProgSlice::addToSinks ( const SVFGNode node)
inline

Definition at line 127 of file ProgSlice.h.

128  {
129  sinks.insert(node);
130  }
SVFGNodeSet sinks
a set of sink nodes
Definition: ProgSlice.h:313

◆ AllPathReachableSolve()

bool ProgSlice::AllPathReachableSolve ( )

Guarded reachability solve.

Compute path conditions for nodes on the backward slice path condition of each node is calculated starting from root node (source) Given a SVFGNode n, its path condition C is allocated (path_i stands for one of m program paths reaches n)

C = \bigvee Guard(path_i), 0 < i < m Guard(path_i) = \bigwedge VFGGuard(x,y), suppose (x,y) are two SVFGNode nodes on path_i

mark source node conditions to be true

clean up the control flow conditions for next round guard computation

Definition at line 43 of file ProgSlice.cpp.

44 {
45  const SVFGNode* source = getSource();
46  VFWorkList worklist;
47  worklist.push(source);
49  setVFCond(source,getTrueCond());
50 
51  while(!worklist.empty())
52  {
53  const SVFGNode* node = worklist.pop();
54  setCurSVFGNode(node);
55 
57  Condition cond = getVFCond(node);
58  for(SVFGNode::const_iterator it = node->OutEdgeBegin(), eit = node->OutEdgeEnd(); it!=eit; ++it)
59  {
60  const SVFGEdge* edge = (*it);
61  const SVFGNode* succ = edge->getDstNode();
62  if(inBackwardSlice(succ))
63  {
64  Condition vfCond;
65  const SVFBasicBlock* nodeBB = getSVFGNodeBB(node);
66  const SVFBasicBlock* succBB = getSVFGNodeBB(succ);
68  clearCFCond();
69 
70  if(edge->isCallVFGEdge())
71  {
72  vfCond = ComputeInterCallVFGGuard(nodeBB,succBB, getCallSite(edge)->getParent());
73  }
74  else if(edge->isRetVFGEdge())
75  {
76  vfCond = ComputeInterRetVFGGuard(nodeBB,succBB, getRetSite(edge)->getParent());
77  }
78  else
79  vfCond = ComputeIntraVFGGuard(nodeBB,succBB);
80  vfCond = condAnd(vfCond, condNeg(invalidCond));
81  Condition succPathCond = condAnd(cond, vfCond);
82  if(setVFCond(succ, condOr(getVFCond(succ), succPathCond) ))
83  worklist.push(succ);
84  }
85 
86  DBOUT(DSaber, outs() << " node (" << node->getId() <<
87  ") --> " << "succ (" << succ->getId() << ") condition: " << getVFCond(succ) << "\n");
88  }
89  }
90 
91  return isSatisfiableForAll();
92 }
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition: SVFType.h:484
#define DSaber
Definition: SVFType.h:504
NodeType * getDstNode() const
Definition: GenericGraph.h:101
iterator OutEdgeEnd()
Definition: GenericGraph.h:458
iterator OutEdgeBegin()
iterators
Definition: GenericGraph.h:454
bool inBackwardSlice(const SVFGNode *node)
Definition: ProgSlice.h:99
const CallICFGNode * getRetSite(const SVFGEdge *edge) const
Definition: ProgSlice.cpp:187
Condition condNeg(const Condition &cond)
Definition: ProgSlice.h:190
Condition condOr(const Condition &lhs, const Condition &rhs)
Definition: ProgSlice.h:186
Condition getTrueCond() const
Definition: ProgSlice.h:194
bool isSatisfiableForAll()
Definition: ProgSlice.cpp:142
FIFOWorkList< const SVFGNode * > VFWorkList
worklist for value-flow guard computation
Definition: ProgSlice.h:58
Condition ComputeInterCallVFGGuard(const SVFBasicBlock *src, const SVFBasicBlock *dst, const SVFBasicBlock *callBB)
Definition: ProgSlice.h:256
const CallICFGNode * getCallSite(const SVFGEdge *edge) const
Get callsite ID and get returnsiteID from SVFGEdge.
Definition: ProgSlice.cpp:179
SaberCondAllocator::Condition Condition
Definition: ProgSlice.h:55
void clearCFCond()
Clear Control flow conditions before each VF computation.
Definition: ProgSlice.h:221
bool setVFCond(const SVFGNode *node, const Condition &cond)
Definition: ProgSlice.h:238
Condition ComputeInterRetVFGGuard(const SVFBasicBlock *src, const SVFBasicBlock *dst, const SVFBasicBlock *retBB)
Definition: ProgSlice.h:260
const SVFBasicBlock * getSVFGNodeBB(const SVFGNode *node) const
Definition: ProgSlice.h:274
Condition computeInvalidCondFromRemovedSUVFEdge(const SVFGNode *cur)
Compute invalid branch condition stemming from removed strong update value-flow edges.
Definition: ProgSlice.cpp:108
const SVFGNode * getSource() const
root and sink operations
Definition: ProgSlice.h:123
Condition condAnd(const Condition &lhs, const Condition &rhs)
Condition operations.
Definition: ProgSlice.h:182
Condition ComputeIntraVFGGuard(const SVFBasicBlock *src, const SVFBasicBlock *dst)
Compute guards for value-flows.
Definition: ProgSlice.h:252
Condition getVFCond(const SVFGNode *node) const
Get/set VF (value-flow) and CF (control-flow) conditions.
Definition: ProgSlice.h:229
void setCurSVFGNode(const SVFGNode *node)
Definition: ProgSlice.h:290
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
bool isRetVFGEdge() const
Definition: VFGEdge.h:88
bool isCallVFGEdge() const
Definition: VFGEdge.h:84
VFGEdge::VFGEdgeSetTy::const_iterator const_iterator
Definition: VFGNode.h:55
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ backwardSliceBegin()

SVFGNodeSetIter SVF::ProgSlice::backwardSliceBegin ( ) const
inline

Definition at line 111 of file ProgSlice.h.

112  {
113  return backwardslice.begin();
114  }

◆ backwardSliceEnd()

SVFGNodeSetIter SVF::ProgSlice::backwardSliceEnd ( ) const
inline

Definition at line 115 of file ProgSlice.h.

116  {
117  return backwardslice.end();
118  }

◆ clearCFCond()

void SVF::ProgSlice::clearCFCond ( )
inlineprotected

Clear Control flow conditions before each VF computation.

TODO: how to clean z3 memory

Definition at line 221 of file ProgSlice.h.

222  {
225  }

◆ ComputeInterCallVFGGuard()

Condition SVF::ProgSlice::ComputeInterCallVFGGuard ( const SVFBasicBlock src,
const SVFBasicBlock dst,
const SVFBasicBlock callBB 
)
inlineprotected

Definition at line 256 of file ProgSlice.h.

257  {
258  return pathAllocator->ComputeInterCallVFGGuard(src,dst,callBB);
259  }
virtual Condition ComputeInterCallVFGGuard(const SVFBasicBlock *src, const SVFBasicBlock *dst, const SVFBasicBlock *callBB)

◆ ComputeInterRetVFGGuard()

Condition SVF::ProgSlice::ComputeInterRetVFGGuard ( const SVFBasicBlock src,
const SVFBasicBlock dst,
const SVFBasicBlock retBB 
)
inlineprotected

Definition at line 260 of file ProgSlice.h.

261  {
262  return pathAllocator->ComputeInterRetVFGGuard(src,dst,retBB);
263  }
virtual Condition ComputeInterRetVFGGuard(const SVFBasicBlock *src, const SVFBasicBlock *dst, const SVFBasicBlock *retBB)

◆ ComputeIntraVFGGuard()

Condition SVF::ProgSlice::ComputeIntraVFGGuard ( const SVFBasicBlock src,
const SVFBasicBlock dst 
)
inlineprotected

Compute guards for value-flows.

Definition at line 252 of file ProgSlice.h.

253  {
254  return pathAllocator->ComputeIntraVFGGuard(src,dst);
255  }
virtual Condition ComputeIntraVFGGuard(const SVFBasicBlock *src, const SVFBasicBlock *dst)
Guard Computation for a value-flow (between two basic blocks)

◆ computeInvalidCondFromRemovedSUVFEdge()

ProgSlice::Condition ProgSlice::computeInvalidCondFromRemovedSUVFEdge ( const SVFGNode cur)
protected

Compute invalid branch condition stemming from removed strong update value-flow edges.

Compute invalid branch condition stemming from removed strong update value-flow edges

Fix issue: https://github.com/SVF-tools/SVF/issues/1306 Line 11->13 is removed due to a strong update at Line 13, which means Line 11 is unreachable to Line 13 on the value flow graph. However on the control flow graph they are still considered as reachable, making the vf guard on Line 11 -> Line 15 a true condition (should consider the infeasible branch Line 11 -> Line 13) Therefore, we collect this infeasible branch condition (condition on Line 11 -> Line 13, a == b) as an invalid condition (invalidCond), and add the negation of invalidCond when computing value flow guard starting from the source of the SU. In this example, we add a != b on Line 11 -> Line 15.

Parameters
curcurrent SVFG node
Returns
invalid branch condition

Definition at line 108 of file ProgSlice.cpp.

109 {
110  Set<const SVFBasicBlock*> validOutBBs; // the BBs of valid successors
111  for(SVFGNode::const_iterator it = cur->OutEdgeBegin(), eit = cur->OutEdgeEnd(); it!=eit; ++it)
112  {
113  const SVFGEdge* edge = (*it);
114  const SVFGNode* succ = edge->getDstNode();
115  if(inBackwardSlice(succ))
116  {
117  validOutBBs.insert(getSVFGNodeBB(succ));
118  }
119  }
120  Condition invalidCond = getFalseCond();
121  auto suVFEdgesIt = getRemovedSUVFEdges().find(cur);
122  if (suVFEdgesIt != getRemovedSUVFEdges().end())
123  {
124  for (const auto &succ: suVFEdgesIt->second)
125  {
126  if (!validOutBBs.count(getSVFGNodeBB(succ)))
127  {
128  // removed vfg node does not reside in the BBs of valid successors
129  const SVFBasicBlock *nodeBB = getSVFGNodeBB(cur);
130  const SVFBasicBlock *succBB = getSVFGNodeBB(succ);
131  clearCFCond();
132  invalidCond = condOr(invalidCond, ComputeIntraVFGGuard(nodeBB, succBB));
133  }
134  }
135  }
136  return invalidCond;
137 }
const SVFGNodeToSVFGNodeSetMap & getRemovedSUVFEdges() const
Definition: ProgSlice.h:305
Condition getFalseCond() const
Definition: ProgSlice.h:198
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96

◆ condAnd()

Condition SVF::ProgSlice::condAnd ( const Condition lhs,
const Condition rhs 
)
inline

Condition operations.

Definition at line 182 of file ProgSlice.h.

183  {
184  return pathAllocator->condAnd(lhs,rhs);
185  }
Condition condAnd(const Condition &lhs, const Condition &rhs)
Condition operations.

◆ condNeg()

Condition SVF::ProgSlice::condNeg ( const Condition cond)
inline

Definition at line 190 of file ProgSlice.h.

191  {
192  return pathAllocator->condNeg(cond);
193  }
Condition condNeg(const Condition &cond)

◆ condOr()

Condition SVF::ProgSlice::condOr ( const Condition lhs,
const Condition rhs 
)
inline

Definition at line 186 of file ProgSlice.h.

187  {
188  return pathAllocator->condOr(lhs,rhs);
189  }
Condition condOr(const Condition &lhs, const Condition &rhs)

◆ destroy()

void ProgSlice::destroy ( )
protected

Release memory.

Definition at line 246 of file ProgSlice.cpp.

247 {
248 }

◆ dumpCond()

std::string SVF::ProgSlice::dumpCond ( const Condition cond) const
inline

Definition at line 202 of file ProgSlice.h.

203  {
204  return pathAllocator->dumpCond(cond);
205  }
std::string dumpCond(const Condition &cond) const

◆ evalFinalCond()

std::string ProgSlice::evalFinalCond ( ) const

Evaluate final condition.

Evaluate Atoms of a condition TODO: for now we only evaluate one path, evaluate every single path

Atom – a propositional variable: a, b, c Literal – an atom or its negation: a, ~a Clause – A disjunction of some literals: a \vee b CNF formula – a conjunction of some clauses: (a \vee b ) \wedge (c \vee d)

print leak path after eliminating duplicated element

Definition at line 220 of file ProgSlice.cpp.

221 {
222  std::string str;
223  std::stringstream rawstr(str);
224  Set<std::string> locations;
226 
227  for(NodeBS::iterator it = elems.begin(), eit = elems.end(); it!=eit; ++it)
228  {
229  const ICFGNode* tinst = pathAllocator->getCondInst(*it);
230  if(pathAllocator->isNegCond(*it))
231  locations.insert(tinst->getSourceLoc()+"|False");
232  else
233  locations.insert(tinst->getSourceLoc()+"|True");
234  }
235 
237  for(Set<std::string>::iterator iter = locations.begin(), eiter = locations.end();
238  iter!=eiter; ++iter)
239  {
240  rawstr << "\t\t --> (" << *iter << ") \n";
241  }
242 
243  return rawstr.str();
244 }
const char *const string
Definition: cJSON.h:172
virtual const std::string getSourceLoc() const
Definition: GenericGraph.h:281
NodeBS exactCondElem(const Condition &cond)
Iterator every element of the condition.
const ICFGNode * getCondInst(u32_t id) const
Get/Set instruction based on Z3 expression id.
bool isNegCond(u32_t id) const
iterator end() const
iterator begin() const

◆ evalFinalCond2Event()

void ProgSlice::evalFinalCond2Event ( GenericBug::EventStack eventStack) const

Add final condition to eventStack.

Definition at line 196 of file ProgSlice.cpp.

197 {
199  for(NodeBS::iterator it = elems.begin(), eit = elems.end(); it!=eit; ++it)
200  {
201  const ICFGNode* tinst = pathAllocator->getCondInst(*it);
202  if(pathAllocator->isNegCond(*it))
203  eventStack.push_back(SVFBugEvent(
204  SVFBugEvent::Branch|((((u32_t)false) << 4) & BRANCHFLAGMASK), tinst));
205  else
206  eventStack.push_back(SVFBugEvent(
207  SVFBugEvent::Branch|((((u32_t)true) << 4) & BRANCHFLAGMASK), tinst));
208  }
209 }
unsigned u32_t
Definition: CommandLine.h:18
#define BRANCHFLAGMASK
Definition: SVFBugReport.h:40

◆ forwardSliceBegin()

SVFGNodeSetIter SVF::ProgSlice::forwardSliceBegin ( ) const
inline

Definition at line 103 of file ProgSlice.h.

104  {
105  return forwardslice.begin();
106  }

◆ forwardSliceEnd()

SVFGNodeSetIter SVF::ProgSlice::forwardSliceEnd ( ) const
inline

Definition at line 107 of file ProgSlice.h.

108  {
109  return forwardslice.end();
110  }

◆ getBackwardSliceSize()

u32_t SVF::ProgSlice::getBackwardSliceSize ( ) const
inline

Definition at line 81 of file ProgSlice.h.

82  {
83  return backwardslice.size();
84  }

◆ getCallSite()

const CallICFGNode * ProgSlice::getCallSite ( const SVFGEdge edge) const

Get callsite ID and get returnsiteID from SVFGEdge.

Definition at line 179 of file ProgSlice.cpp.

180 {
181  assert(edge->isCallVFGEdge() && "not a call svfg edge?");
182  if(const CallDirSVFGEdge* callEdge = SVFUtil::dyn_cast<CallDirSVFGEdge>(edge))
183  return getSVFG()->getCallSite(callEdge->getCallSiteId());
184  else
185  return getSVFG()->getCallSite(SVFUtil::cast<CallIndSVFGEdge>(edge)->getCallSiteId());
186 }
const SVFG * getSVFG() const
Definition: ProgSlice.h:213
const CallICFGNode * getCallSite(CallSiteID id) const
Definition: VFG.h:182

◆ getCurSVFGNode()

const SVFGNode* SVF::ProgSlice::getCurSVFGNode ( ) const
inlineprotected

Get/set current SVFG node.

Definition at line 286 of file ProgSlice.h.

287  {
288  return _curSVFGNode;
289  }

◆ getFalseCond()

Condition SVF::ProgSlice::getFalseCond ( ) const
inline

Definition at line 198 of file ProgSlice.h.

199  {
200  return pathAllocator->getFalseCond();
201  }
Condition getFalseCond() const

◆ getForwardSliceSize()

u32_t SVF::ProgSlice::getForwardSliceSize ( ) const
inline

Definition at line 77 of file ProgSlice.h.

78  {
79  return forwardslice.size();
80  }

◆ getRemovedSUVFEdges()

const SVFGNodeToSVFGNodeSetMap& SVF::ProgSlice::getRemovedSUVFEdges ( ) const
inlineprotected

Definition at line 305 of file ProgSlice.h.

306  {
308  }
SVFGNodeToSVFGNodeSetMap & getRemovedSUVFEdges()

◆ getRetSite()

const CallICFGNode * ProgSlice::getRetSite ( const SVFGEdge edge) const

Definition at line 187 of file ProgSlice.cpp.

188 {
189  assert(edge->isRetVFGEdge() && "not a return svfg edge?");
190  if(const RetDirSVFGEdge* callEdge = SVFUtil::dyn_cast<RetDirSVFGEdge>(edge))
191  return getSVFG()->getCallSite(callEdge->getCallSiteId());
192  else
193  return getSVFG()->getCallSite(SVFUtil::cast<RetIndSVFGEdge>(edge)->getCallSiteId());
194 }

◆ getSinks()

const SVFGNodeSet& SVF::ProgSlice::getSinks ( ) const
inline

Definition at line 131 of file ProgSlice.h.

132  {
133  return sinks;
134  }

◆ getSource()

const SVFGNode* SVF::ProgSlice::getSource ( ) const
inline

root and sink operations

Definition at line 123 of file ProgSlice.h.

124  {
125  return root;
126  }

◆ getSVFG()

const SVFG* SVF::ProgSlice::getSVFG ( ) const
inlineprotected

Definition at line 213 of file ProgSlice.h.

214  {
215  return svfg;
216  }

◆ getSVFGNodeBB()

const SVFBasicBlock* SVF::ProgSlice::getSVFGNodeBB ( const SVFGNode node) const
inlineprotected

Return the basic block where a SVFGNode resides in a SVFGNode may not in a basic block if it is not a program statement (e.g. PAGEdge is an global assignment or NullPtrSVFGNode)

Definition at line 274 of file ProgSlice.h.

275  {
276  const ICFGNode* icfgNode = node->getICFGNode();
277  if(SVFUtil::isa<NullPtrSVFGNode>(node) == false)
278  {
279  return icfgNode->getBB();
280  }
281  return nullptr;
282  }

◆ getTrueCond()

Condition SVF::ProgSlice::getTrueCond ( ) const
inline

Definition at line 194 of file ProgSlice.h.

195  {
196  return pathAllocator->getTrueCond();
197  }
Condition getTrueCond() const

◆ getVFCond()

Condition SVF::ProgSlice::getVFCond ( const SVFGNode node) const
inlineprotected

Get/set VF (value-flow) and CF (control-flow) conditions.

Definition at line 229 of file ProgSlice.h.

230  {
231  SVFGNodeToCondMap::const_iterator it = svfgNodeToCondMap.find(node);
232  if(it==svfgNodeToCondMap.end())
233  {
234  return getFalseCond();
235  }
236  return it->second;
237  }
SVFGNodeToCondMap svfgNodeToCondMap
map a SVFGNode to its path condition starting from root
Definition: ProgSlice.h:315

◆ inBackwardSlice()

bool SVF::ProgSlice::inBackwardSlice ( const SVFGNode node)
inline

Definition at line 99 of file ProgSlice.h.

100  {
101  return backwardslice.find(node)!=backwardslice.end();
102  }

◆ inForwardSlice()

bool SVF::ProgSlice::inForwardSlice ( const SVFGNode node)
inline

Definition at line 95 of file ProgSlice.h.

96  {
97  return forwardslice.find(node)!=forwardslice.end();
98  }

◆ isAllReachable()

bool SVF::ProgSlice::isAllReachable ( ) const
inline

Definition at line 159 of file ProgSlice.h.

160  {
161  return fullReachable || reachGlob;
162  }

◆ isEquivalentBranchCond()

bool SVF::ProgSlice::isEquivalentBranchCond ( const Condition lhs,
const Condition rhs 
) const
inlineprotected

Definition at line 266 of file ProgSlice.h.

267  {
268  return pathAllocator->isEquivalentBranchCond(lhs, rhs);
269  };
bool isEquivalentBranchCond(const Condition &lhs, const Condition &rhs) const
Whether lhs and rhs are equivalent branch conditions.

◆ isPartialReachable()

bool SVF::ProgSlice::isPartialReachable ( ) const
inline

Definition at line 155 of file ProgSlice.h.

156  {
157  return partialReachable || reachGlob;
158  }

◆ isReachGlobal()

bool SVF::ProgSlice::isReachGlobal ( ) const
inline

Definition at line 163 of file ProgSlice.h.

164  {
165  return reachGlob;
166  }

◆ isSatisfiableForAll()

bool ProgSlice::isSatisfiableForAll ( )

Solve by computing disjunction of conditions from all sinks (e.g., memory leak)

Definition at line 142 of file ProgSlice.cpp.

143 {
144 
145  Condition guard = getFalseCond();
146  for(SVFGNodeSetIter it = sinksBegin(), eit = sinksEnd(); it!=eit; ++it)
147  {
148  guard = condOr(guard,getVFCond(*it));
149  }
150  setFinalCond(guard);
151 
152  return pathAllocator->isAllPathReachable(guard);
153 }
SVFGNodeSetIter sinksEnd() const
Definition: ProgSlice.h:139
SVFGNodeSetIter sinksBegin() const
Definition: ProgSlice.h:135
SVFGNodeSet::const_iterator SVFGNodeSetIter
Definition: ProgSlice.h:54
void setFinalCond(const Condition &cond)
Set final condition after all path reachability analysis.
Definition: ProgSlice.h:297
bool isAllPathReachable(Condition &condition)
whether condition is satisfiable for all possible boolean guards

◆ isSatisfiableForPairs()

bool ProgSlice::isSatisfiableForPairs ( )

Solve by analysing each pair of sinks (e.g., double free)

Definition at line 158 of file ProgSlice.cpp.

159 {
160 
161  for(SVFGNodeSetIter it = sinksBegin(), eit = sinksEnd(); it!=eit; ++it)
162  {
163  for(SVFGNodeSetIter sit = it, esit = sinksEnd(); sit!=esit; ++sit)
164  {
165  if(*it == *sit)
166  continue;
167  Condition guard = condAnd(getVFCond(*sit),getVFCond(*it));
168  if(!isEquivalentBranchCond(guard, getFalseCond()))
169  {
170  setFinalCond(guard);
171  return false;
172  }
173  }
174  }
175 
176  return true;
177 }
bool isEquivalentBranchCond(const Condition &lhs, const Condition &rhs) const
Definition: ProgSlice.h:266

◆ setAllReachable()

void SVF::ProgSlice::setAllReachable ( )
inline

Definition at line 147 of file ProgSlice.h.

148  {
149  fullReachable = true;
150  }

◆ setCurSVFGNode()

void SVF::ProgSlice::setCurSVFGNode ( const SVFGNode node)
inlineprotected

Definition at line 290 of file ProgSlice.h.

291  {
292  _curSVFGNode = node;
294  }
void setCurEvalSVFGNode(const SVFGNode *node)
Set current value for branch condition evaluation.

◆ setFinalCond()

void SVF::ProgSlice::setFinalCond ( const Condition cond)
inlineprotected

Set final condition after all path reachability analysis.

Definition at line 297 of file ProgSlice.h.

298  {
299  finalCond = cond;
300  }

◆ setPartialReachable()

void SVF::ProgSlice::setPartialReachable ( )
inline

Definition at line 143 of file ProgSlice.h.

144  {
145  partialReachable = true;
146  }

◆ setReachGlobal()

bool SVF::ProgSlice::setReachGlobal ( )
inline

Definition at line 151 of file ProgSlice.h.

152  {
153  return reachGlob = true;
154  }

◆ setVFCond()

bool SVF::ProgSlice::setVFCond ( const SVFGNode node,
const Condition cond 
)
inlineprotected

Definition at line 238 of file ProgSlice.h.

239  {
240  SVFGNodeToCondMap::iterator it = svfgNodeToCondMap.find(node);
241  // until a fixed-point is reached (condition is not changed)
242  if(it!=svfgNodeToCondMap.end() && isEquivalentBranchCond(it->second, cond))
243  return false;
244 
245  svfgNodeToCondMap[node] = cond;
246  return true;
247  }

◆ sinksBegin()

SVFGNodeSetIter SVF::ProgSlice::sinksBegin ( ) const
inline

Definition at line 135 of file ProgSlice.h.

136  {
137  return sinks.begin();
138  }

◆ sinksEnd()

SVFGNodeSetIter SVF::ProgSlice::sinksEnd ( ) const
inline

Definition at line 139 of file ProgSlice.h.

140  {
141  return sinks.end();
142  }

Member Data Documentation

◆ _curSVFGNode

const SVFGNode* SVF::ProgSlice::_curSVFGNode
private

current svfg node during guard computation

Definition at line 320 of file ProgSlice.h.

◆ backwardslice

SVFGNodeSet SVF::ProgSlice::backwardslice
private

the backward slice

Definition at line 312 of file ProgSlice.h.

◆ finalCond

Condition SVF::ProgSlice::finalCond
private

final condition

Definition at line 321 of file ProgSlice.h.

◆ forwardslice

SVFGNodeSet SVF::ProgSlice::forwardslice
private

the forward slice

Definition at line 311 of file ProgSlice.h.

◆ fullReachable

bool SVF::ProgSlice::fullReachable
private

reachable from all paths

Definition at line 317 of file ProgSlice.h.

◆ partialReachable

bool SVF::ProgSlice::partialReachable
private

reachable from some paths

Definition at line 316 of file ProgSlice.h.

◆ pathAllocator

SaberCondAllocator* SVF::ProgSlice::pathAllocator
private

path condition allocator

Definition at line 319 of file ProgSlice.h.

◆ reachGlob

bool SVF::ProgSlice::reachGlob
private

Whether slice reach a global.

Definition at line 318 of file ProgSlice.h.

◆ root

const SVFGNode* SVF::ProgSlice::root
private

root node on the slice

Definition at line 314 of file ProgSlice.h.

◆ sinks

SVFGNodeSet SVF::ProgSlice::sinks
private

a set of sink nodes

Definition at line 313 of file ProgSlice.h.

◆ svfg

const SVFG* SVF::ProgSlice::svfg
private

SVFG.

Definition at line 322 of file ProgSlice.h.

◆ svfgNodeToCondMap

SVFGNodeToCondMap SVF::ProgSlice::svfgNodeToCondMap
private

map a SVFGNode to its path condition starting from root

Definition at line 315 of file ProgSlice.h.


The documentation for this class was generated from the following files: