Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
SVF::CondPTAImpl< Cond > Class Template Referenceabstract

#include <PointerAnalysisImpl.h>

Inheritance diagram for SVF::CondPTAImpl< Cond >:
SVF::PointerAnalysis

Public Types

typedef CondVar< Cond > CVar
 
typedef CondStdSet< CVar > CPtSet
 
typedef PTData< CVar, Set< CVar >, CVar, CPtSet > PTDataTy
 
typedef MutablePTData< CVar, Set< CVar >, CVar, CPtSet > MutPTDataTy
 
typedef Map< NodeID, PointsTo > PtrToBVPtsMap
 
typedef Map< NodeID, NodeSet > PtrToNSMap
 map a pointer to its BitVector points-to representation
 
typedef Map< NodeID, CPtSet > PtrToCPtsMap
 
- Public Types inherited from SVF::PointerAnalysis
typedef Set< const CallICFGNode * > CallSiteSet
 Indirect call edges type, map a callsite to a set of callees.
 
typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
 
typedef Set< const FunObjVar * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
 
typedef SCCDetection< CallGraph * > CallGraphSCC
 
typedef Set< const GlobalObjVar * > VTableSet
 
typedef Set< const FunObjVar * > VFunSet
 

Public Member Functions

 CondPTAImpl (SVFIR *pag, PTATY type)
 map a pointer to its conditional points-to set
 
virtual ~CondPTAImpl ()
 Destructor.
 
void destroy ()
 Release memory.
 
PTDataTy * getPTDataTy () const
 Get points-to data.
 
MutPTDataTy * getMutPTDataTy () const
 
bool hasPtsMap (void) const
 
const MutPTDataTy::PtsMap & getPtsMap () const
 
- Public Member Functions inherited from SVF::PointerAnalysis
ICFG * getICFG () const
 Get ICFG.
 
u32_t getNumOfResolvedIndCallEdge () const
 Return number of resolved indirect call edges.
 
CallGraph * getCallGraph () const
 Return call graph.
 
CallGraphSCC * getCallGraphSCC () const
 Return call graph SCC.
 
 PointerAnalysis (SVFIR *pag, PTATY ty=PTATY::Default_PTA, bool alias_check=true)
 Constructor.
 
PTATY getAnalysisTy () const
 Type of pointer analysis.
 
PTAImplTy getImplTy () const
 Return implementation type of the pointer analysis.
 
bool printStat ()
 Whether print statistics.
 
void disablePrintStat ()
 Whether print statistics.
 
CallEdgeMap & getIndCallMap ()
 Get callees from an indirect callsite.
 
bool hasIndCSCallees (const CallICFGNode *cs) const
 
const FunctionSet & getIndCSCallees (const CallICFGNode *cs) const
 
virtual void resolveIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve indirect call edges.
 
void callGraphSCCDetection ()
 PTACallGraph SCC related methods.
 
NodeID getCallGraphSCCRepNode (NodeID id) const
 Get SCC rep node of a SVFG node.
 
bool inSameCallGraphSCC (const FunObjVar *fun1, const FunObjVar *fun2)
 Return TRUE if this edge is inside a PTACallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG.
 
bool isInRecursion (const FunObjVar *fun) const
 
bool isLocalVarInRecursiveFun (NodeID id) const
 Whether a local variable is in function recursions.
 
virtual const std::string PTAName () const
 Return PTA name.
 
CommonCHGraph * getCHGraph () const
 get CHGraph
 
void getVFnsFromCHA (const CallICFGNode *cs, VFunSet &vfns)
 
void getVFnsFromPts (const CallICFGNode *cs, const PointsTo &target, VFunSet &vfns)
 
void connectVCallToVFns (const CallICFGNode *cs, const VFunSet &vfns, CallEdgeMap &newEdges)
 
virtual void resolveCPPIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve cpp indirect call edges.
 
SVFIR * getPAG () const
 
PTAStat * getStat () const
 Get PTA stat.
 
OrderedNodeSet & getAllValidPtrs ()
 Get all Valid Pointers for resolution.
 
virtual void initialize ()
 Initialization of a pointer analysis, including building symbol table and SVFIR etc.
 
virtual void analyze ()=0
 Start Analysis here (main part of pointer analysis). It needs to be implemented in child class.
 
virtual void computeDDAPts (NodeID)
 Compute points-to results on-demand, overridden by derived classes.
 
virtual NodeBS getMayAliases (NodeID node)
 
bool mayAlias (const SVFVar *V1, const SVFVar *V2)
 Convenience bool wrappers: return true if the two operands may/must/partial alias.
 
bool mayAlias (NodeID node1, NodeID node2)
 
void printIndCSTargets (const CallICFGNode *cs, const FunctionSet &targets)
 Print targets of a function pointer.
 
virtual void dumpAllPts ()
 
virtual void dumpPts (NodeID ptr, const PointsTo &pts)
 
void printIndCSTargets ()
 
void dumpAllTypes ()
 
void dumpStat ()
 Dump the statistics.
 
bool containBlackHoleNode (const PointsTo &pts)
 Determine whether a points-to contains a black hole or constant node.
 
bool containConstantNode (const PointsTo &pts)
 
virtual bool isBlkObjOrConstantObj (NodeID ptd) const
 
bool isHeapMemObj (NodeID id) const
 Whether this object is heap or array.
 
bool isArrayMemObj (NodeID id) const
 
bool isFIObjNode (NodeID id) const
 
NodeID getBaseObjVarID (NodeID id)
 
NodeID getFIObjVar (NodeID id)
 
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 
virtual const NodeBS & getAllFieldsObjVars (NodeID id)
 
void setObjFieldInsensitive (NodeID id)
 
bool isFieldInsensitive (NodeID id) const
 

Static Public Member Functions

static bool classof (const PointerAnalysis *pta)
 
PTDataTy * ptD
 Points-to data.
 
bool normalized
 Normalized flag.
 
PtrToBVPtsMap ptrToBVPtsMap
 Normal points-to representation (without conditions)
 
PtrToNSMap objToNSRevPtsMap
 Normal points-to representation (without conditions)
 
PtrToCPtsMap ptrToCPtsMap
 Conditional points-to representation (with conditions)
 
virtual const CPtSet & getPts (CVar id)
 
virtual const Set< CVar > & getRevPts (CVar nodeId)
 
virtual void clearPts ()
 Clear all data.
 
bool overlap (const CPtSet &cpts1, const CPtSet &cpts2) const
 Whether cpts1 and cpts2 have overlap points-to targets.
 
void expandFIObjs (const CPtSet &cpts, CPtSet &expandedCpts)
 Expand all fields of an aggregate in all points-to sets.
 
virtual void dumpCPts ()
 Print out conditional pts.
 
virtual PointsTo getBVPointsTo (const CPtSet &cpts) const
 Given a conditional pts return its bit vector points-to.
 
virtual PointsTo & getPts (NodeID ptr)
 Given a pointer return its bit vector points-to.
 
virtual const CPtSet & getCondPointsTo (NodeID ptr)
 Given a pointer return its conditional points-to.
 
virtual NodeSet & getRevPts (NodeID obj)
 Given an object return all pointers points to this object.
 
virtual AliasResult alias (const SVFVar *V1, const SVFVar *V2)
 Interface expose to users of our pointer analysis, given Value infos.
 
virtual AliasResult alias (NodeID node1, NodeID node2)
 Interface expose to users of our pointer analysis, given two pointers.
 
virtual AliasResult alias (const CVar &var1, const CVar &var2)
 Interface expose to users of our pointer analysis, given conditional variables.
 
virtual AliasResult alias (const CPtSet &pts1, const CPtSet &pts2)
 Interface expose to users of our pointer analysis, given two conditional points-to sets.
 
bool containBlackHoleNode (const CPtSet &cpts)
 Test blk node for cpts.
 
bool containConstantNode (const CPtSet &cpts)
 Test constant node for cpts.
 
virtual bool isCondCompatible (const Cond &cxt1, const Cond &cxt2, bool singleton) const =0
 Whether two conditions are compatible (to be implemented by child class)
 
void dumpTopLevelPtsTo ()
 Dump points-to information of top-level pointers.
 
virtual void finalize ()
 Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.
 
virtual bool unionPts (CVar id, const CPtSet &target)
 
virtual bool unionPts (CVar id, CVar ptd)
 
virtual bool addPts (CVar id, CVar ptd)
 
bool mustAlias (const CVar &var1, const CVar &var2)
 Internal interface to be used for conditional points-to set queries.
 
bool contains (const CPtSet &cpts1, const CPtSet &cpts2)
 
bool isSameVar (const CVar &var1, const CVar &var2) const
 Whether two pointers/objects are the same one by considering their conditions.
 
virtual void normalizePointsTo ()
 Normalize points-to information to BitVector/conditional representation.
 

Additional Inherited Members

- Static Public Attributes inherited from SVF::PointerAnalysis
static const std::string aliasTestMayAlias = "MAYALIAS"
 
static const std::string aliasTestMayAliasMangled = "_Z8MAYALIASPvS_"
 
static const std::string aliasTestNoAlias = "NOALIAS"
 
static const std::string aliasTestNoAliasMangled = "_Z7NOALIASPvS_"
 
static const std::string aliasTestPartialAlias = "PARTIALALIAS"
 
static const std::string aliasTestPartialAliasMangled = "_Z12PARTIALALIASPvS_"
 
static const std::string aliasTestMustAlias = "MUSTALIAS"
 
static const std::string aliasTestMustAliasMangled = "_Z9MUSTALIASPvS_"
 
static const std::string aliasTestFailMayAlias = "EXPECTEDFAIL_MAYALIAS"
 
static const std::string aliasTestFailMayAliasMangled = "_Z21EXPECTEDFAIL_MAYALIASPvS_"
 
static const std::string aliasTestFailNoAlias = "EXPECTEDFAIL_NOALIAS"
 
static const std::string aliasTestFailNoAliasMangled = "_Z20EXPECTEDFAIL_NOALIASPvS_"
 
- Protected Member Functions inherited from SVF::PointerAnalysis
const CallSiteToFunPtrMap & getIndirectCallsites () const
 Return all indirect callsites.
 
NodeID getFunPtr (const CallICFGNode *cs) const
 Return function pointer PAGNode at a callsite cs.
 
virtual void validateTests ()
 Alias check functions to verify correctness of pointer analysis.
 
virtual void validateSuccessTests (std::string fun)
 
virtual void validateExpectedFailureTests (std::string fun)
 
void resetObjFieldSensitive ()
 Reset all object node as field-sensitive.
 
- Protected Attributes inherited from SVF::PointerAnalysis
bool print_stat
 User input flags.
 
bool alias_validation
 Flag for validating points-to/alias results.
 
u32_t OnTheFlyIterBudgetForStat
 Flag for iteration budget for on-the-fly statistics.
 
PTATY ptaTy
 Pointer analysis Type.
 
PTAImplTy ptaImplTy
 PTA implementation type.
 
PTAStat * stat
 Statistics.
 
CallGraph * callgraph
 Call graph used for pointer analysis.
 
CallGraphSCC * callGraphSCC
 SCC for PTACallGraph.
 
ICFG * icfg
 Interprocedural control-flow graph.
 
CommonCHGraph * chgraph
 CHGraph.
 
- Static Protected Attributes inherited from SVF::PointerAnalysis
static SVFIR * pag = nullptr
 SVFIR.
 

Detailed Description

template<class Cond>
class SVF::CondPTAImpl< Cond >

Pointer analysis implementation which uses conditional points-to map data structure (context/path sensitive analysis)

Definition at line 255 of file PointerAnalysisImpl.h.

Member Typedef Documentation

◆ CPtSet

Definition at line 260 of file PointerAnalysisImpl.h.

◆ CVar

Definition at line 259 of file PointerAnalysisImpl.h.

◆ MutPTDataTy

Definition at line 262 of file PointerAnalysisImpl.h.

◆ PTDataTy

Definition at line 261 of file PointerAnalysisImpl.h.

◆ PtrToBVPtsMap

template<class Cond >
typedef Map<NodeID,PointsTo> SVF::CondPTAImpl< Cond >::PtrToBVPtsMap

Definition at line 263 of file PointerAnalysisImpl.h.

◆ PtrToCPtsMap

template<class Cond >
typedef Map<NodeID,CPtSet> SVF::CondPTAImpl< Cond >::PtrToCPtsMap

Definition at line 265 of file PointerAnalysisImpl.h.

◆ PtrToNSMap

template<class Cond >
typedef Map<NodeID, NodeSet> SVF::CondPTAImpl< Cond >::PtrToNSMap

map a pointer to its BitVector points-to representation

Definition at line 264 of file PointerAnalysisImpl.h.

Constructor & Destructor Documentation

◆ CondPTAImpl()

template<class Cond >
SVF::CondPTAImpl< Cond >::CondPTAImpl ( SVFIR *  pag,
PTATY  type 
)
inline

map a pointer to its conditional points-to set

Constructor

Definition at line 268 of file PointerAnalysisImpl.h.

269 {
271 ptD = new MutPTDataTy();
272 else
273 assert(false && "no points-to data available");
274
276 }
newitem type
Definition cJSON.cpp:2739
bool normalized
Normalized flag.
MutablePTData< CVar, Set< CVar >, CVar, CPtSet > MutPTDataTy
PTDataTy * ptD
Points-to data.
PTAImplTy ptaImplTy
PTA implementation type.
PointerAnalysis(SVFIR *pag, PTATY ty=PTATY::Default_PTA, bool alias_check=true)
Constructor.
static SVFIR * pag
SVFIR.
@ CondImpl
Represents CondPTAImpl.
Definition PTATY.h:43
@ Cxt_DDA
context sensitive DDA
Definition PTATY.h:32
@ PathS_DDA
Guarded value-flow DDA.
Definition PTATY.h:31
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~CondPTAImpl()

template<class Cond >
virtual SVF::CondPTAImpl< Cond >::~CondPTAImpl ( )
inlinevirtual

Destructor.

Definition at line 279 of file PointerAnalysisImpl.h.

280 {
281 destroy();
282 }
void destroy()
Release memory.

Member Function Documentation

◆ addPts()

template<class Cond >
virtual bool SVF::CondPTAImpl< Cond >::addPts ( CVar  id,
CVar  ptd 
)
inlineprotectedvirtual

Definition at line 392 of file PointerAnalysisImpl.h.

393 {
394 return ptD->addPts(id,ptd);
395 }

◆ alias() [1/4]

template<class Cond >
virtual AliasResult SVF::CondPTAImpl< Cond >::alias ( const CPtSet &  pts1,
const CPtSet &  pts2 
)
inlinevirtual

Interface expose to users of our pointer analysis, given two conditional points-to sets.

Definition at line 530 of file PointerAnalysisImpl.h.

531 {
538 else if(this->getAnalysisTy() == PTATY::PathS_DDA && contains(cpts1,cpts2) && contains(cpts2,cpts1))
539 {
541 }
542 else if(overlap(cpts1,cpts2))
544 else
546 }
CondStdSet< CVar > CPtSet
bool contains(const CPtSet &cpts1, const CPtSet &cpts2)
void expandFIObjs(const CPtSet &cpts, CPtSet &expandedCpts)
Expand all fields of an aggregate in all points-to sets.
bool containBlackHoleNode(const CPtSet &cpts)
Test blk node for cpts.
bool overlap(const CPtSet &cpts1, const CPtSet &cpts2) const
Whether cpts1 and cpts2 have overlap points-to targets.
PTATY getAnalysisTy() const
Type of pointer analysis.
@ MustAlias
Definition SVFType.h:622
@ MayAlias
Definition SVFType.h:621
@ NoAlias
Definition SVFType.h:620

◆ alias() [2/4]

template<class Cond >
virtual AliasResult SVF::CondPTAImpl< Cond >::alias ( const CVar &  var1,
const CVar &  var2 
)
inlinevirtual

Interface expose to users of our pointer analysis, given conditional variables.

Definition at line 525 of file PointerAnalysisImpl.h.

526 {
527 return alias(getPts(var1),getPts(var2));
528 }
virtual AliasResult alias(const SVFVar *V1, const SVFVar *V2)
Interface expose to users of our pointer analysis, given Value infos.
virtual const CPtSet & getPts(CVar id)

◆ alias() [3/4]

template<class Cond >
virtual AliasResult SVF::CondPTAImpl< Cond >::alias ( const SVFVar *  V1,
const SVFVar *  V2 
)
inlinevirtual

Interface expose to users of our pointer analysis, given Value infos.

Implements SVF::PointerAnalysis.

Definition at line 515 of file PointerAnalysisImpl.h.

516 {
517 return alias(V1->getId(), V2->getId());
518 }

◆ alias() [4/4]

template<class Cond >
virtual AliasResult SVF::CondPTAImpl< Cond >::alias ( NodeID  node1,
NodeID  node2 
)
inlinevirtual

Interface expose to users of our pointer analysis, given two pointers.

Implements SVF::PointerAnalysis.

Definition at line 520 of file PointerAnalysisImpl.h.

521 {
523 }
virtual const CPtSet & getCondPointsTo(NodeID ptr)
Given a pointer return its conditional points-to.

◆ classof()

template<class Cond >
static bool SVF::CondPTAImpl< Cond >::classof ( const PointerAnalysis *  pta)
inlinestatic

Definition at line 284 of file PointerAnalysisImpl.h.

285 {
286 return pta->getImplTy() == PTAImplTy::CondImpl;
287 }

◆ clearPts()

template<class Cond >
virtual void SVF::CondPTAImpl< Cond >::clearPts ( )
inlinevirtual

Clear all data.

Definition at line 334 of file PointerAnalysisImpl.h.

335 {
336 ptD->clear();
337 }

◆ containBlackHoleNode()

template<class Cond >
bool SVF::CondPTAImpl< Cond >::containBlackHoleNode ( const CPtSet &  cpts)
inline

Test blk node for cpts.

Definition at line 548 of file PointerAnalysisImpl.h.

549 {
550 for(typename CPtSet::const_iterator cit = cpts.begin(), ecit=cpts.end(); cit!=ecit; ++cit)
551 {
552 if(cit->get_id() == pag->getBlackHoleNode())
553 return true;
554 }
555 return false;
556 }
OrderedSet< Element >::const_iterator const_iterator
NodeID getBlackHoleNode() const
Definition IRGraph.h:246

◆ containConstantNode()

template<class Cond >
bool SVF::CondPTAImpl< Cond >::containConstantNode ( const CPtSet &  cpts)
inline

Test constant node for cpts.

Definition at line 558 of file PointerAnalysisImpl.h.

559 {
560 for(typename CPtSet::const_iterator cit = cpts.begin(), ecit=cpts.end(); cit!=ecit; ++cit)
561 {
562 if(cit->get_id() == pag->getConstantNode())
563 return true;
564 }
565 return false;
566 }
NodeID getConstantNode() const
Definition IRGraph.h:250

◆ contains()

template<class Cond >
bool SVF::CondPTAImpl< Cond >::contains ( const CPtSet &  cpts1,
const CPtSet &  cpts2 
)
inlineprotected

Definition at line 415 of file PointerAnalysisImpl.h.

416 {
417 if (cpts1.empty() || cpts2.empty())
418 return false;
419
420 for (typename CPtSet::const_iterator it2 = cpts2.begin(); it2 != cpts2.end(); ++it2)
421 {
422 bool hasObj = false;
423 for (typename CPtSet::const_iterator it1 = cpts1.begin(); it1 != cpts1.end(); ++it1)
424 {
425 if(isSameVar(*it1,*it2))
426 {
427 hasObj = true;
428 break;
429 }
430 }
431 if(hasObj == false)
432 return false;
433 }
434 return true;
435 }
bool isSameVar(const CVar &var1, const CVar &var2) const
Whether two pointers/objects are the same one by considering their conditions.

◆ destroy()

template<class Cond >
void SVF::CondPTAImpl< Cond >::destroy ( )
inline

Release memory.

Definition at line 290 of file PointerAnalysisImpl.h.

291 {
292 delete ptD;
293 ptD = nullptr;
294 }

◆ dumpCPts()

template<class Cond >
virtual void SVF::CondPTAImpl< Cond >::dumpCPts ( )
inlinevirtual

Print out conditional pts.

Reimplemented from SVF::PointerAnalysis.

Definition at line 483 of file PointerAnalysisImpl.h.

484 {
485 ptD->dumpPTData();
486 }

◆ dumpTopLevelPtsTo()

template<class Cond >
void SVF::CondPTAImpl< Cond >::dumpTopLevelPtsTo ( )
inlinevirtual

Dump points-to information of top-level pointers.

Reimplemented from SVF::PointerAnalysis.

Definition at line 571 of file PointerAnalysisImpl.h.

572 {
573 for (OrderedNodeSet::iterator nIter = this->getAllValidPtrs().begin(); nIter != this->getAllValidPtrs().end(); ++nIter)
574 {
575 const SVFVar* node = this->getPAG()->getSVFVar(*nIter);
576 if (this->getPAG()->isValidTopLevelPtr(node))
577 {
578 if (SVFUtil::isa<DummyObjVar>(node))
579 {
580 SVFUtil::outs() << "##<Blackhole or constant> id:" << node->getId();
581 }
582 else if (!SVFUtil::isa<DummyValVar>(node))
583 {
584 SVFUtil::outs() << "##<" << node->toString() << "> ";
585 //SVFUtil::outs() << "Source Loc: " << SVFUtil::getSourceLoc(node->getValue());
586 }
587
588 const PointsTo& pts = getPts(node->getId());
589 SVFUtil::outs() << "\nNodeID " << node->getId() << " ";
590 if (pts.empty())
591 {
592 SVFUtil::outs() << "\t\tPointsTo: {empty}\n\n";
593 }
594 else
595 {
596 SVFUtil::outs() << "\t\tPointsTo: { ";
597 for (PointsTo::iterator it = pts.begin(), eit = pts.end(); it != eit; ++it)
598 SVFUtil::outs() << *it << " ";
599 SVFUtil::outs() << "}\n\n";
600 }
601 }
602 }
603
604 SVFUtil::outs().flush();
605 }
SVFIR * getPAG() const
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
const_iterator iterator
Definition PointsTo.h:41
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
Definition SVFIR.h:135
NodeID getId() const
Get ID.
Definition SVFValue.h:158
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:58

◆ expandFIObjs()

template<class Cond >
void SVF::CondPTAImpl< Cond >::expandFIObjs ( const CPtSet &  cpts,
CPtSet &  expandedCpts 
)
inline

Expand all fields of an aggregate in all points-to sets.

Definition at line 354 of file PointerAnalysisImpl.h.

355 {
356 expandedCpts = cpts;;
357 for(typename CPtSet::const_iterator cit = cpts.begin(), ecit=cpts.end(); cit!=ecit; ++cit)
358 {
359 if(pag->getBaseObjVarID(cit->get_id())==cit->get_id())
360 {
361 NodeBS& fields = pag->getAllFieldsObjVars(cit->get_id());
362 for(NodeBS::iterator it = fields.begin(), eit = fields.end(); it!=eit; ++it)
363 {
364 CVar cvar(cit->get_cond(),*it);
365 expandedCpts.set(cvar);
366 }
367 }
368 }
369 }
NodeID getBaseObjVarID(NodeID id) const
Base and Offset methods for Value and Object node.
Definition SVFIR.h:554
NodeBS & getAllFieldsObjVars(const BaseObjVar *obj)
Get all fields of an object.
Definition SVFIR.cpp:573
SparseBitVectorIterator iterator
SparseBitVector NodeBS
Definition GeneralType.h:82

◆ finalize()

template<class Cond >
virtual void SVF::CondPTAImpl< Cond >::finalize ( )
inlineprotectedvirtual

Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.

Reimplemented from SVF::PointerAnalysis.

Reimplemented in SVF::ContextDDA.

Definition at line 374 of file PointerAnalysisImpl.h.

375 {
378 }
virtual void normalizePointsTo()
Normalize points-to information to BitVector/conditional representation.
virtual void finalize()
Finalization of a pointer analysis, including checking alias correctness.

◆ getBVPointsTo()

template<class Cond >
virtual PointsTo SVF::CondPTAImpl< Cond >::getBVPointsTo ( const CPtSet &  cpts) const
inlinevirtual

Given a conditional pts return its bit vector points-to.

Definition at line 488 of file PointerAnalysisImpl.h.

489 {
490 PointsTo pts;
491 for(typename CPtSet::const_iterator cit = cpts.begin(), ecit=cpts.end(); cit!=ecit; ++cit)
492 pts.set(cit->get_id());
493 return pts;
494 }

◆ getCondPointsTo()

template<class Cond >
virtual const CPtSet & SVF::CondPTAImpl< Cond >::getCondPointsTo ( NodeID  ptr)
inlinevirtual

Given a pointer return its conditional points-to.

Definition at line 502 of file PointerAnalysisImpl.h.

503 {
504 assert(normalized && "Pts of all context-vars have to be merged/normalized. Want to use getPts(CVar cvar)??");
505 return ptrToCPtsMap[ptr];
506 }
PtrToCPtsMap ptrToCPtsMap
Conditional points-to representation (with conditions)

◆ getMutPTDataTy()

template<class Cond >
MutPTDataTy * SVF::CondPTAImpl< Cond >::getMutPTDataTy ( ) const
inline

Definition at line 302 of file PointerAnalysisImpl.h.

303 {
304 MutPTDataTy* mut = SVFUtil::dyn_cast<MutPTDataTy>(ptD);
305 assert(mut && "BVDataPTAImpl::getMutPTDataTy: not a MutPTDataTy!");
306 return mut;
307 }

◆ getPTDataTy()

template<class Cond >
PTDataTy * SVF::CondPTAImpl< Cond >::getPTDataTy ( ) const
inline

Get points-to data.

Definition at line 297 of file PointerAnalysisImpl.h.

298 {
299 return ptD;
300 }

◆ getPts() [1/2]

template<class Cond >
virtual const CPtSet & SVF::CondPTAImpl< Cond >::getPts ( CVar  id)
inlinevirtual

Get points-to and reverse points-to

Definition at line 323 of file PointerAnalysisImpl.h.

324 {
325 return ptD->getPts(id);
326 }

◆ getPts() [2/2]

template<class Cond >
virtual PointsTo & SVF::CondPTAImpl< Cond >::getPts ( NodeID  ptr)
inlinevirtual

Given a pointer return its bit vector points-to.

Implements SVF::PointerAnalysis.

Definition at line 496 of file PointerAnalysisImpl.h.

497 {
498 assert(normalized && "Pts of all context-var have to be merged/normalized. Want to use getPts(CVar cvar)??");
499 return ptrToBVPtsMap[ptr];
500 }
PtrToBVPtsMap ptrToBVPtsMap
Normal points-to representation (without conditions)

◆ getPtsMap()

template<class Cond >
const MutPTDataTy::PtsMap & SVF::CondPTAImpl< Cond >::getPtsMap ( ) const
inline

Definition at line 314 of file PointerAnalysisImpl.h.

315 {
316 if (MutPTDataTy *m = SVFUtil::dyn_cast<MutPTDataTy>(ptD)) return m->getPtsMap();
317 assert(false && "CondPTAImpl::getPtsMap: not a PTData with a PtsMap!");
318 exit(1);
319 }

◆ getRevPts() [1/2]

template<class Cond >
virtual const Set< CVar > & SVF::CondPTAImpl< Cond >::getRevPts ( CVar  nodeId)
inlinevirtual

Definition at line 327 of file PointerAnalysisImpl.h.

328 {
329 return ptD->getRevPts(nodeId);
330 }

◆ getRevPts() [2/2]

template<class Cond >
virtual NodeSet & SVF::CondPTAImpl< Cond >::getRevPts ( NodeID  obj)
inlinevirtual

Given an object return all pointers points to this object.

Implements SVF::PointerAnalysis.

Definition at line 508 of file PointerAnalysisImpl.h.

509 {
510 assert(normalized && "Pts of all context-var have to be merged/normalized. Want to use getPts(CVar cvar)??");
511 return objToNSRevPtsMap[obj];
512 }
PtrToNSMap objToNSRevPtsMap
Normal points-to representation (without conditions)

◆ hasPtsMap()

template<class Cond >
bool SVF::CondPTAImpl< Cond >::hasPtsMap ( void  ) const
inline

Definition at line 309 of file PointerAnalysisImpl.h.

310 {
311 return SVFUtil::isa<MutPTDataTy>(ptD);
312 }

◆ isCondCompatible()

template<class Cond >
virtual bool SVF::CondPTAImpl< Cond >::isCondCompatible ( const Cond &  cxt1,
const Cond &  cxt2,
bool  singleton 
) const
pure virtual

Whether two conditions are compatible (to be implemented by child class)

Implemented in SVF::ContextDDA.

◆ isSameVar()

template<class Cond >
bool SVF::CondPTAImpl< Cond >::isSameVar ( const CVar &  var1,
const CVar &  var2 
) const
inlineprotected

Whether two pointers/objects are the same one by considering their conditions.

we distinguish context sensitive memory allocation here

Definition at line 438 of file PointerAnalysisImpl.h.

439 {
440 if(var1.get_id() != var2.get_id())
441 return false;
442
444 bool singleton = !(isHeapMemObj(var1.get_id()) || isLocalVarInRecursiveFun(var1.get_id()));
445 return isCondCompatible(var1.get_cond(),var2.get_cond(),singleton);
446 }
virtual bool isCondCompatible(const Cond &cxt1, const Cond &cxt2, bool singleton) const =0
Whether two conditions are compatible (to be implemented by child class)
bool isLocalVarInRecursiveFun(NodeID id) const
Whether a local variable is in function recursions.
bool isHeapMemObj(NodeID id) const
Whether this object is heap or array.

◆ mustAlias()

template<class Cond >
bool SVF::CondPTAImpl< Cond >::mustAlias ( const CVar &  var1,
const CVar &  var2 
)
inlineprotected

Internal interface to be used for conditional points-to set queries.

Definition at line 400 of file PointerAnalysisImpl.h.

401 {
402 if(isSameVar(var1,var2))
403 return true;
404
405 bool singleton = !(isHeapMemObj(var1.get_id()) || isLocalVarInRecursiveFun(var1.get_id()));
406 if(isCondCompatible(var1.get_cond(),var2.get_cond(),singleton) == false)
407 return false;
408
409 const CPtSet& cpts1 = getPts(var1);
410 const CPtSet& cpts2 = getPts(var2);
411 return (contains(cpts1,cpts2) && contains(cpts2,cpts1));
412 }

◆ normalizePointsTo()

template<class Cond >
virtual void SVF::CondPTAImpl< Cond >::normalizePointsTo ( )
inlineprotectedvirtual

Normalize points-to information to BitVector/conditional representation.

Definition at line 450 of file PointerAnalysisImpl.h.

451 {
452 normalized = true;
453 if (hasPtsMap())
454 {
455 const typename MutPTDataTy::PtsMap& ptsMap = getPtsMap();
456 for(typename MutPTDataTy::PtsMap::const_iterator it = ptsMap.begin(), eit=ptsMap.end(); it!=eit; ++it)
457 {
458 for(typename CPtSet::const_iterator cit = it->second.begin(), ecit=it->second.end(); cit!=ecit; ++cit)
459 {
460 ptrToBVPtsMap[(it->first).get_id()].set(cit->get_id());
461 objToNSRevPtsMap[cit->get_id()].insert((it->first).get_id());
462 ptrToCPtsMap[(it->first).get_id()].set(*cit);
463 }
464 }
465 }
466 else
467 {
468 assert(false && "CondPTAImpl::NormalizePointsTo: could not normalize points-to sets");
469 }
470 }
bool hasPtsMap(void) const
const MutPTDataTy::PtsMap & getPtsMap() const
Map< Key, DataSet > PtsMap

◆ overlap()

template<class Cond >
bool SVF::CondPTAImpl< Cond >::overlap ( const CPtSet &  cpts1,
const CPtSet &  cpts2 
) const
inline

Whether cpts1 and cpts2 have overlap points-to targets.

Definition at line 340 of file PointerAnalysisImpl.h.

341 {
342 for (typename CPtSet::const_iterator it1 = cpts1.begin(); it1 != cpts1.end(); ++it1)
343 {
344 for (typename CPtSet::const_iterator it2 = cpts2.begin(); it2 != cpts2.end(); ++it2)
345 {
346 if(isSameVar(*it1,*it2))
347 return true;
348 }
349 }
350 return false;
351 }

◆ unionPts() [1/2]

template<class Cond >
virtual bool SVF::CondPTAImpl< Cond >::unionPts ( CVar  id,
const CPtSet &  target 
)
inlineprotectedvirtual

Union/add points-to, and add the reverse points-to for node collapse purpose To be noted that adding reverse pts might incur 10% total overhead during solving

Definition at line 382 of file PointerAnalysisImpl.h.

383 {
384 return ptD->unionPts(id, target);
385 }

◆ unionPts() [2/2]

template<class Cond >
virtual bool SVF::CondPTAImpl< Cond >::unionPts ( CVar  id,
CVar  ptd 
)
inlineprotectedvirtual

Definition at line 387 of file PointerAnalysisImpl.h.

388 {
389 return ptD->unionPts(id,ptd);
390 }

Member Data Documentation

◆ normalized

template<class Cond >
bool SVF::CondPTAImpl< Cond >::normalized
protected

Normalized flag.

Definition at line 474 of file PointerAnalysisImpl.h.

◆ objToNSRevPtsMap

template<class Cond >
PtrToNSMap SVF::CondPTAImpl< Cond >::objToNSRevPtsMap
protected

Normal points-to representation (without conditions)

Definition at line 478 of file PointerAnalysisImpl.h.

◆ ptD

template<class Cond >
PTDataTy* SVF::CondPTAImpl< Cond >::ptD
protected

Points-to data.

Definition at line 472 of file PointerAnalysisImpl.h.

◆ ptrToBVPtsMap

template<class Cond >
PtrToBVPtsMap SVF::CondPTAImpl< Cond >::ptrToBVPtsMap
protected

Normal points-to representation (without conditions)

Definition at line 476 of file PointerAnalysisImpl.h.

◆ ptrToCPtsMap

template<class Cond >
PtrToCPtsMap SVF::CondPTAImpl< Cond >::ptrToCPtsMap
protected

Conditional points-to representation (with conditions)

Definition at line 480 of file PointerAnalysisImpl.h.


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