Static Value-Flow Analysis
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< CVarCPtSet
 
typedef PTData< CVar, Set< CVar >, CVar, CPtSetPTDataTy
 
typedef MutablePTData< CVar, Set< CVar >, CVar, CPtSetMutPTDataTy
 
typedef Map< NodeID, PointsToPtrToBVPtsMap
 
typedef Map< NodeID, NodeSetPtrToNSMap
 map a pointer to its BitVector points-to representation More...
 
typedef Map< NodeID, CPtSetPtrToCPtsMap
 
- Public Types inherited from SVF::PointerAnalysis
enum  PTATY {
  Andersen_BASE , Andersen_WPA , AndersenSCD_WPA , AndersenSFR_WPA ,
  AndersenWaveDiff_WPA , Steensgaard_WPA , CSCallString_WPA , CSSummary_WPA ,
  FSDATAFLOW_WPA , FSSPARSE_WPA , VFS_WPA , FSCS_WPA ,
  CFLFICI_WPA , CFLFSCI_WPA , CFLFSCS_WPA , TypeCPP_WPA ,
  FieldS_DDA , FlowS_DDA , PathS_DDA , Cxt_DDA ,
  Default_PTA
}
 Pointer analysis type list. More...
 
enum  PTAImplTy { BaseImpl , BVDataImpl , CondImpl }
 Implementation type: BVDataPTAImpl or CondPTAImpl. More...
 
typedef Set< const CallICFGNode * > CallSiteSet
 Indirect call edges type, map a callsite to a set of callees. More...
 
typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
 
typedef Set< const SVFFunction * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSetCallEdgeMap
 
typedef SCCDetection< PTACallGraph * > CallGraphSCC
 
typedef Set< const SVFGlobalValue * > VTableSet
 
typedef Set< const SVFFunction * > VFunSet
 

Public Member Functions

 CondPTAImpl (SVFIR *pag, PointerAnalysis::PTATY type)
 map a pointer to its conditional points-to set More...
 
virtual ~CondPTAImpl ()
 Destructor. More...
 
void destroy ()
 Release memory. More...
 
PTDataTygetPTDataTy () const
 Get points-to data. More...
 
MutPTDataTygetMutPTDataTy () const
 
bool hasPtsMap (void) const
 
const MutPTDataTy::PtsMapgetPtsMap () const
 
- Public Member Functions inherited from SVF::PointerAnalysis
ICFGgetICFG () const
 Get ICFG. More...
 
u32_t getNumOfResolvedIndCallEdge () const
 Return number of resolved indirect call edges. More...
 
PTACallGraphgetCallGraph () const
 Return call graph. More...
 
CallGraphSCCgetCallGraphSCC () const
 Return call graph SCC. More...
 
 PointerAnalysis (SVFIR *pag, PTATY ty=Default_PTA, bool alias_check=true)
 Constructor. More...
 
PTATY getAnalysisTy () const
 Type of pointer analysis. More...
 
PTAImplTy getImplTy () const
 Return implementation type of the pointer analysis. More...
 
bool printStat ()
 Whether print statistics. More...
 
void disablePrintStat ()
 Whether print statistics. More...
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite. More...
 
bool hasIndCSCallees (const CallICFGNode *cs) const
 
const FunctionSetgetIndCSCallees (const CallICFGNode *cs) const
 
virtual void resolveIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve indirect call edges. More...
 
void callGraphSCCDetection ()
 PTACallGraph SCC related methods. More...
 
NodeID getCallGraphSCCRepNode (NodeID id) const
 Get SCC rep node of a SVFG node. More...
 
bool inSameCallGraphSCC (const SVFFunction *fun1, const SVFFunction *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. More...
 
bool isInRecursion (const SVFFunction *fun) const
 
bool isLocalVarInRecursiveFun (NodeID id) const
 Whether a local variable is in function recursions. More...
 
virtual const std::string PTAName () const
 Return PTA name. More...
 
CommonCHGraphgetCHGraph () const
 get CHGraph More...
 
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. More...
 
SVFIRgetPAG () const
 
PTAStatgetStat () const
 Get PTA stat. More...
 
SVFModulegetModule () const
 Module. More...
 
OrderedNodeSetgetAllValidPtrs ()
 Get all Valid Pointers for resolution. More...
 
virtual ~PointerAnalysis ()
 Destructor. More...
 
virtual void initialize ()
 Initialization of a pointer analysis, including building symbol table and SVFIR etc. More...
 
virtual void analyze ()=0
 Start Analysis here (main part of pointer analysis). It needs to be implemented in child class. More...
 
virtual void computeDDAPts (NodeID)
 Compute points-to results on-demand, overridden by derived classes. More...
 
void printIndCSTargets (const CallICFGNode *cs, const FunctionSet &targets)
 Print targets of a function pointer. More...
 
virtual void dumpAllPts ()
 
virtual void dumpPts (NodeID ptr, const PointsTo &pts)
 
void printIndCSTargets ()
 
void dumpAllTypes ()
 
void dumpStat ()
 Dump the statistics. More...
 
bool containBlackHoleNode (const PointsTo &pts)
 Determine whether a points-to contains a black hole or constant node. More...
 
bool containConstantNode (const PointsTo &pts)
 
virtual bool isBlkObjOrConstantObj (NodeID ptd) const
 
bool isHeapMemObj (NodeID id) const
 Whether this object is heap or array. More...
 
bool isArrayMemObj (NodeID id) const
 
bool isFIObjNode (NodeID id) const
 
NodeID getBaseObjVar (NodeID id)
 
NodeID getFIObjVar (NodeID id)
 
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 
virtual const NodeBSgetAllFieldsObjVars (NodeID id)
 
void setObjFieldInsensitive (NodeID id)
 
bool isFieldInsensitive (NodeID id) const
 

Static Public Member Functions

static bool classof (const PointerAnalysis *pta)
 
PTDataTyptD
 Points-to data. More...
 
bool normalized
 Normalized flag. More...
 
PtrToBVPtsMap ptrToBVPtsMap
 Normal points-to representation (without conditions) More...
 
PtrToNSMap objToNSRevPtsMap
 Normal points-to representation (without conditions) More...
 
PtrToCPtsMap ptrToCPtsMap
 Conditional points-to representation (with conditions) More...
 
virtual const CPtSetgetPts (CVar id)
 
virtual const Set< CVar > & getRevPts (CVar nodeId)
 
virtual void clearPts ()
 Clear all data. More...
 
bool overlap (const CPtSet &cpts1, const CPtSet &cpts2) const
 Whether cpts1 and cpts2 have overlap points-to targets. More...
 
void expandFIObjs (const CPtSet &cpts, CPtSet &expandedCpts)
 Expand all fields of an aggregate in all points-to sets. More...
 
virtual void dumpCPts ()
 Print out conditional pts. More...
 
virtual PointsTo getBVPointsTo (const CPtSet &cpts) const
 Given a conditional pts return its bit vector points-to. More...
 
virtual PointsTogetPts (NodeID ptr)
 Given a pointer return its bit vector points-to. More...
 
virtual const CPtSetgetCondPointsTo (NodeID ptr)
 Given a pointer return its conditional points-to. More...
 
virtual NodeSetgetRevPts (NodeID obj)
 Given an object return all pointers points to this object. More...
 
virtual AliasResult alias (const SVFValue *V1, const SVFValue *V2)
 Interface expose to users of our pointer analysis, given Value infos. More...
 
virtual AliasResult alias (NodeID node1, NodeID node2)
 Interface expose to users of our pointer analysis, given two pointers. More...
 
virtual AliasResult alias (const CVar &var1, const CVar &var2)
 Interface expose to users of our pointer analysis, given conditional variables. More...
 
virtual AliasResult alias (const CPtSet &pts1, const CPtSet &pts2)
 Interface expose to users of our pointer analysis, given two conditional points-to sets. More...
 
bool containBlackHoleNode (const CPtSet &cpts)
 Test blk node for cpts. More...
 
bool containConstantNode (const CPtSet &cpts)
 Test constant node for cpts. More...
 
virtual bool isCondCompatible (const Cond &cxt1, const Cond &cxt2, bool singleton) const =0
 Whether two conditions are compatible (to be implemented by child class) More...
 
void dumpTopLevelPtsTo ()
 Dump points-to information of top-level pointers. More...
 
virtual void finalize ()
 Finalization of pointer analysis, and normalize points-to information to Bit Vector representation. More...
 
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. More...
 
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. More...
 
virtual void normalizePointsTo ()
 Normalize points-to information to BitVector/conditional representation. More...
 

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 CallSiteToFunPtrMapgetIndirectCallsites () const
 Return all indirect callsites. More...
 
NodeID getFunPtr (const CallICFGNode *cs) const
 Return function pointer PAGNode at a callsite cs. More...
 
virtual void validateTests ()
 Alias check functions to verify correctness of pointer analysis. More...
 
virtual void validateSuccessTests (std::string fun)
 
virtual void validateExpectedFailureTests (std::string fun)
 
void resetObjFieldSensitive ()
 Reset all object node as field-sensitive. More...
 
- Protected Attributes inherited from SVF::PointerAnalysis
bool print_stat
 User input flags. More...
 
bool alias_validation
 Flag for validating points-to/alias results. More...
 
u32_t OnTheFlyIterBudgetForStat
 Flag for iteration budget for on-the-fly statistics. More...
 
SVFModulesvfMod
 Module. More...
 
PTATY ptaTy
 Pointer analysis Type. More...
 
PTAImplTy ptaImplTy
 PTA implementation type. More...
 
PTAStatstat
 Statistics. More...
 
PTACallGraphcallgraph
 Call graph used for pointer analysis. More...
 
CallGraphSCCcallGraphSCC
 SCC for PTACallGraph. More...
 
ICFGicfg
 Interprocedural control-flow graph. More...
 
CommonCHGraphchgraph
 CHGraph. More...
 
- Static Protected Attributes inherited from SVF::PointerAnalysis
static SVFIRpag = nullptr
 SVFIR. More...
 

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 244 of file PointerAnalysisImpl.h.

Member Typedef Documentation

◆ CPtSet

template<class Cond >
typedef CondStdSet<CVar> SVF::CondPTAImpl< Cond >::CPtSet

Definition at line 249 of file PointerAnalysisImpl.h.

◆ CVar

template<class Cond >
typedef CondVar<Cond> SVF::CondPTAImpl< Cond >::CVar

Definition at line 248 of file PointerAnalysisImpl.h.

◆ MutPTDataTy

template<class Cond >
typedef MutablePTData<CVar, Set<CVar>, CVar, CPtSet> SVF::CondPTAImpl< Cond >::MutPTDataTy

Definition at line 251 of file PointerAnalysisImpl.h.

◆ PTDataTy

template<class Cond >
typedef PTData<CVar, Set<CVar>, CVar, CPtSet> SVF::CondPTAImpl< Cond >::PTDataTy

Definition at line 250 of file PointerAnalysisImpl.h.

◆ PtrToBVPtsMap

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

Definition at line 252 of file PointerAnalysisImpl.h.

◆ PtrToCPtsMap

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

Definition at line 254 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 253 of file PointerAnalysisImpl.h.

Constructor & Destructor Documentation

◆ CondPTAImpl()

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

map a pointer to its conditional points-to set

Constructor

Definition at line 257 of file PointerAnalysisImpl.h.

257  : PointerAnalysis(pag, type), normalized(false)
258  {
259  if (type == PathS_DDA || type == Cxt_DDA)
260  ptD = new MutPTDataTy();
261  else
262  assert(false && "no points-to data available");
263 
265  }
newitem type
Definition: cJSON.cpp:2739
bool normalized
Normalized flag.
MutablePTData< CVar, Set< CVar >, CVar, CPtSet > MutPTDataTy
PTDataTy * ptD
Points-to data.
@ Cxt_DDA
context sensitive DDA
@ PathS_DDA
Guarded value-flow DDA.
PointerAnalysis(SVFIR *pag, PTATY ty=Default_PTA, bool alias_check=true)
Constructor.
PTAImplTy ptaImplTy
PTA implementation type.
@ CondImpl
Represents CondPTAImpl.
static SVFIR * pag
SVFIR.

◆ ~CondPTAImpl()

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

Destructor.

Definition at line 268 of file PointerAnalysisImpl.h.

269  {
270  destroy();
271  }
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 381 of file PointerAnalysisImpl.h.

382  {
383  return ptD->addPts(id,ptd);
384  }
virtual bool addPts(const Key &var, const Data &element)=0
Adds element to the points-to set associated with var.

◆ 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 519 of file PointerAnalysisImpl.h.

520  {
521  CPtSet cpts1;
522  expandFIObjs(pts1,cpts1);
523  CPtSet cpts2;
524  expandFIObjs(pts2,cpts2);
525  if (containBlackHoleNode(cpts1) || containBlackHoleNode(cpts2))
526  return AliasResult::MayAlias;
527  else if(this->getAnalysisTy()==PathS_DDA && contains(cpts1,cpts2) && contains(cpts2,cpts1))
528  {
529  return AliasResult::MustAlias;
530  }
531  else if(overlap(cpts1,cpts2))
532  return AliasResult::MayAlias;
533  else
534  return AliasResult::NoAlias;
535  }
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:530
@ MayAlias
Definition: SVFType.h:529
@ NoAlias
Definition: SVFType.h:528

◆ 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 514 of file PointerAnalysisImpl.h.

515  {
516  return alias(getPts(var1),getPts(var2));
517  }
virtual AliasResult alias(const SVFValue *V1, const SVFValue *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 SVFValue V1,
const SVFValue V2 
)
inlinevirtual

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

Implements SVF::PointerAnalysis.

Definition at line 504 of file PointerAnalysisImpl.h.

505  {
506  return alias(pag->getValueNode(V1),pag->getValueNode(V2));
507  }
NodeID getValueNode(const SVFValue *V)
Definition: IRGraph.h:137

◆ 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 509 of file PointerAnalysisImpl.h.

510  {
511  return alias(getCondPointsTo(node1),getCondPointsTo(node2));
512  }
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 273 of file PointerAnalysisImpl.h.

274  {
275  return pta->getImplTy() == CondImpl;
276  }

◆ clearPts()

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

Clear all data.

Definition at line 323 of file PointerAnalysisImpl.h.

324  {
325  ptD->clear();
326  }
virtual void clear()=0
Clears all points-to sets as if nothing is stored.

◆ containBlackHoleNode()

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

Test blk node for cpts.

Definition at line 537 of file PointerAnalysisImpl.h.

538  {
539  for(typename CPtSet::const_iterator cit = cpts.begin(), ecit=cpts.end(); cit!=ecit; ++cit)
540  {
541  if(cit->get_id() == pag->getBlackHoleNode())
542  return true;
543  }
544  return false;
545  }
OrderedSet< Element >::const_iterator const_iterator
NodeID getBlackHoleNode() const
Definition: IRGraph.h:161

◆ containConstantNode()

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

Test constant node for cpts.

Definition at line 547 of file PointerAnalysisImpl.h.

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

◆ contains()

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

Definition at line 404 of file PointerAnalysisImpl.h.

405  {
406  if (cpts1.empty() || cpts2.empty())
407  return false;
408 
409  for (typename CPtSet::const_iterator it2 = cpts2.begin(); it2 != cpts2.end(); ++it2)
410  {
411  bool hasObj = false;
412  for (typename CPtSet::const_iterator it1 = cpts1.begin(); it1 != cpts1.end(); ++it1)
413  {
414  if(isSameVar(*it1,*it2))
415  {
416  hasObj = true;
417  break;
418  }
419  }
420  if(hasObj == false)
421  return false;
422  }
423  return true;
424  }
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 279 of file PointerAnalysisImpl.h.

280  {
281  delete ptD;
282  ptD = nullptr;
283  }

◆ dumpCPts()

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

Print out conditional pts.

Reimplemented from SVF::PointerAnalysis.

Definition at line 472 of file PointerAnalysisImpl.h.

473  {
474  ptD->dumpPTData();
475  }
virtual void dumpPTData()=0
Dump stored keys and points-to sets.

◆ 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 560 of file PointerAnalysisImpl.h.

561  {
562  for (OrderedNodeSet::iterator nIter = this->getAllValidPtrs().begin(); nIter != this->getAllValidPtrs().end(); ++nIter)
563  {
564  const PAGNode* node = this->getPAG()->getGNode(*nIter);
565  if (this->getPAG()->isValidTopLevelPtr(node))
566  {
567  if (SVFUtil::isa<DummyObjVar>(node))
568  {
569  SVFUtil::outs() << "##<Blackhole or constant> id:" << node->getId();
570  }
571  else if (!SVFUtil::isa<DummyValVar>(node))
572  {
573  SVFUtil::outs() << "##<" << node->getValue()->getName() << "> ";
574  //SVFUtil::outs() << "Source Loc: " << SVFUtil::getSourceLoc(node->getValue());
575  }
576 
577  const PointsTo& pts = getPts(node->getId());
578  SVFUtil::outs() << "\nNodeID " << node->getId() << " ";
579  if (pts.empty())
580  {
581  SVFUtil::outs() << "\t\tPointsTo: {empty}\n\n";
582  }
583  else
584  {
585  SVFUtil::outs() << "\t\tPointsTo: { ";
586  for (PointsTo::iterator it = pts.begin(), eit = pts.end(); it != eit; ++it)
587  SVFUtil::outs() << *it << " ";
588  SVFUtil::outs() << "}\n\n";
589  }
590  }
591  }
592 
593  SVFUtil::outs().flush();
594  }
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:653
SVFIR * getPAG() const
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
const_iterator iterator
Definition: PointsTo.h:40
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50
SVFVar PAGNode
Definition: IRGraph.h:42

◆ 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 343 of file PointerAnalysisImpl.h.

344  {
345  expandedCpts = cpts;;
346  for(typename CPtSet::const_iterator cit = cpts.begin(), ecit=cpts.end(); cit!=ecit; ++cit)
347  {
348  if(pag->getBaseObjVar(cit->get_id())==cit->get_id())
349  {
350  NodeBS& fields = pag->getAllFieldsObjVars(cit->get_id());
351  for(NodeBS::iterator it = fields.begin(), eit = fields.end(); it!=eit; ++it)
352  {
353  CVar cvar(cit->get_cond(),*it);
354  expandedCpts.set(cvar);
355  }
356  }
357  }
358  }
CondVar< Cond > CVar
NodeBS & getAllFieldsObjVars(const MemObj *obj)
Get all fields of an object.
Definition: SVFIR.cpp:477
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
Definition: SVFIR.h:455
SparseBitVectorIterator iterator
SparseBitVector NodeBS
Definition: GeneralType.h:62

◆ 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 363 of file PointerAnalysisImpl.h.

364  {
367  }
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 477 of file PointerAnalysisImpl.h.

478  {
479  PointsTo pts;
480  for(typename CPtSet::const_iterator cit = cpts.begin(), ecit=cpts.end(); cit!=ecit; ++cit)
481  pts.set(cit->get_id());
482  return pts;
483  }

◆ 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 491 of file PointerAnalysisImpl.h.

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

◆ getMutPTDataTy()

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

Definition at line 291 of file PointerAnalysisImpl.h.

292  {
293  MutPTDataTy* mut = SVFUtil::dyn_cast<MutPTDataTy>(ptD);
294  assert(mut && "BVDataPTAImpl::getMutPTDataTy: not a MutPTDataTy!");
295  return mut;
296  }

◆ getPTDataTy()

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

Get points-to data.

Definition at line 286 of file PointerAnalysisImpl.h.

287  {
288  return ptD;
289  }

◆ 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 312 of file PointerAnalysisImpl.h.

313  {
314  return ptD->getPts(id);
315  }
virtual const DataSet & getPts(const Key &var)=0
Get points-to set of var.

◆ 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 485 of file PointerAnalysisImpl.h.

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

◆ getPtsMap()

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

Definition at line 303 of file PointerAnalysisImpl.h.

304  {
305  if (MutPTDataTy *m = SVFUtil::dyn_cast<MutPTDataTy>(ptD)) return m->getPtsMap();
306  assert(false && "CondPTAImpl::getPtsMap: not a PTData with a PtsMap!");
307  exit(1);
308  }

◆ getRevPts() [1/2]

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

Definition at line 316 of file PointerAnalysisImpl.h.

317  {
318  return ptD->getRevPts(nodeId);
319  }
virtual const KeySet & getRevPts(const Data &datum)=0
Get reverse points-to set of a datum.

◆ 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 497 of file PointerAnalysisImpl.h.

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

◆ hasPtsMap()

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

Definition at line 298 of file PointerAnalysisImpl.h.

299  {
300  return SVFUtil::isa<MutPTDataTy>(ptD);
301  }

◆ 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 427 of file PointerAnalysisImpl.h.

428  {
429  if(var1.get_id() != var2.get_id())
430  return false;
431 
433  bool singleton = !(isHeapMemObj(var1.get_id()) || isLocalVarInRecursiveFun(var1.get_id()));
434  return isCondCompatible(var1.get_cond(),var2.get_cond(),singleton);
435  }
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 389 of file PointerAnalysisImpl.h.

390  {
391  if(isSameVar(var1,var2))
392  return true;
393 
394  bool singleton = !(isHeapMemObj(var1.get_id()) || isLocalVarInRecursiveFun(var1.get_id()));
395  if(isCondCompatible(var1.get_cond(),var2.get_cond(),singleton) == false)
396  return false;
397 
398  const CPtSet& cpts1 = getPts(var1);
399  const CPtSet& cpts2 = getPts(var2);
400  return (contains(cpts1,cpts2) && contains(cpts2,cpts1));
401  }

◆ normalizePointsTo()

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

Normalize points-to information to BitVector/conditional representation.

Definition at line 439 of file PointerAnalysisImpl.h.

440  {
441  normalized = true;
442  if (hasPtsMap())
443  {
444  const typename MutPTDataTy::PtsMap& ptsMap = getPtsMap();
445  for(typename MutPTDataTy::PtsMap::const_iterator it = ptsMap.begin(), eit=ptsMap.end(); it!=eit; ++it)
446  {
447  for(typename CPtSet::const_iterator cit = it->second.begin(), ecit=it->second.end(); cit!=ecit; ++cit)
448  {
449  ptrToBVPtsMap[(it->first).get_id()].set(cit->get_id());
450  objToNSRevPtsMap[cit->get_id()].insert((it->first).get_id());
451  ptrToCPtsMap[(it->first).get_id()].set(*cit);
452  }
453  }
454  }
455  else
456  {
457  assert(false && "CondPTAImpl::NormalizePointsTo: could not normalize points-to sets");
458  }
459  }
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 329 of file PointerAnalysisImpl.h.

330  {
331  for (typename CPtSet::const_iterator it1 = cpts1.begin(); it1 != cpts1.end(); ++it1)
332  {
333  for (typename CPtSet::const_iterator it2 = cpts2.begin(); it2 != cpts2.end(); ++it2)
334  {
335  if(isSameVar(*it1,*it2))
336  return true;
337  }
338  }
339  return false;
340  }

◆ 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 371 of file PointerAnalysisImpl.h.

372  {
373  return ptD->unionPts(id, target);
374  }
virtual bool unionPts(const Key &dstVar, const Key &srcVar)=0
Performs pts(dstVar) = pts(dstVar) U pts(srcVar).

◆ unionPts() [2/2]

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

Definition at line 376 of file PointerAnalysisImpl.h.

377  {
378  return ptD->unionPts(id,ptd);
379  }

Member Data Documentation

◆ normalized

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

Normalized flag.

Definition at line 463 of file PointerAnalysisImpl.h.

◆ objToNSRevPtsMap

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

Normal points-to representation (without conditions)

Definition at line 467 of file PointerAnalysisImpl.h.

◆ ptD

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

Points-to data.

Definition at line 461 of file PointerAnalysisImpl.h.

◆ ptrToBVPtsMap

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

Normal points-to representation (without conditions)

Definition at line 465 of file PointerAnalysisImpl.h.

◆ ptrToCPtsMap

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

Conditional points-to representation (with conditions)

Definition at line 469 of file PointerAnalysisImpl.h.


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