Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SVF::VFG Class Reference

#include <VFG.h>

Inheritance diagram for SVF::VFG:
SVF::GenericGraph< NodeTy, EdgeTy > SVF::SVFG SVF::SVFGOPT

Public Types

enum  VFGK { FULLSVFG , PTRONLYSVFG , FULLSVFG_OPT , PTRONLYSVFG_OPT }
 VFG kind. More...
 
typedef OrderedMap< NodeID, VFGNode * > VFGNodeIDToNodeMapTy
 
typedef Set< VFGNode * > VFGNodeSet
 
typedef Map< const ValVar *, NodeIDValVarToDefMapTy
 
typedef Map< std::pair< NodeID, const CallICFGNode * >, ActualParmVFGNode * > SVFVarToActualParmMapTy
 
typedef Map< const SVFVar *, ActualRetVFGNode * > SVFVarToActualRetMapTy
 
typedef Map< const SVFVar *, FormalParmVFGNode * > SVFVarToFormalParmMapTy
 
typedef Map< const SVFVar *, FormalRetVFGNode * > SVFVarToFormalRetMapTy
 
typedef Map< const SVFStmt *, StmtVFGNode * > SVFStmtToStmtVFGNodeMapTy
 
typedef Map< const SVFVar *, IntraPHIVFGNode * > SVFVarToPHIVFGNodeMapTy
 
typedef Map< const SVFVar *, BinaryOPVFGNode * > SVFVarToBinaryOPVFGNodeMapTy
 
typedef Map< const SVFVar *, UnaryOPVFGNode * > SVFVarToUnaryOPVFGNodeMapTy
 
typedef Map< const SVFVar *, BranchVFGNode * > SVFVarToBranchVFGNodeMapTy
 
typedef Map< const SVFVar *, CmpVFGNode * > SVFVarToCmpVFGNodeMapTy
 
typedef Map< const FunObjVar *, VFGNodeSetFunToVFGNodesMapTy
 
typedef FormalParmVFGNode::CallPESet CallPESet
 
typedef FormalRetVFGNode::RetPESet RetPESet
 
typedef VFGEdge::VFGEdgeSetTy VFGEdgeSetTy
 
typedef VFGEdge::SVFGEdgeSetTy SVFGEdgeSetTy
 
typedef VFGEdge::VFGEdgeSetTy::iterator VFGNodeIter
 
typedef VFGNodeIDToNodeMapTy::iterator iterator
 
typedef VFGNodeIDToNodeMapTy::const_iterator const_iterator
 
typedef SVFIR::SVFStmtSet SVFStmtSet
 
typedef Set< const VFGNode * > GlobalVFGNodeSet
 
typedef Set< const SVFVar * > SVFVarSet
 
- Public Types inherited from SVF::GenericGraph< NodeTy, EdgeTy >
typedef NodeTy NodeType
 
typedef EdgeTy EdgeType
 
typedef OrderedMap< NodeID, NodeType * > IDToNodeMapTy
 NodeID to GenericNode map.
 
typedef IDToNodeMapTy::iterator iterator
 Node Iterators.
 
typedef IDToNodeMapTy::const_iterator const_iterator
 

Public Member Functions

 VFG (CallGraph *callgraph, VFGK k=FULLSVFG)
 Constructor.
 
virtual ~VFG ()
 Destructor.
 
VFGK getKind () const
 Get VFG kind.
 
bool isPtrOnlySVFG () const
 Return true if this VFG only contains pointer related SVFGNodes for pointer analysis.
 
SVFIRgetPAG () const
 Return SVFIR.
 
CallGraphgetCallGraph () const
 Return PTACallGraph.
 
VFGNodegetVFGNode (NodeID id) const
 Get a VFG node.
 
bool hasVFGNode (NodeID id) const
 Whether has the VFGNode.
 
GlobalVFGNodeSetgetGlobalVFGNodes ()
 Return global stores.
 
VFGEdgegetIntraVFGEdge (const VFGNode *src, const VFGNode *dst, VFGEdge::VFGEdgeK kind)
 Get a SVFG edge according to src and dst.
 
void dump (const std::string &file, bool simple=false)
 Dump graph into dot file.
 
void view ()
 Dump graph into dot file.
 
void updateCallGraph (PointerAnalysis *pta)
 Update VFG based on pointer analysis results.
 
virtual void connectCallerAndCallee (const CallICFGNode *cs, const FunObjVar *callee, VFGEdgeSetTy &edges)
 Connect VFG nodes between caller and callee for indirect call site.
 
CallSiteID getCallSiteID (const CallICFGNode *cs, const FunObjVar *func) const
 Get callsite given a callsiteID.
 
const CallICFGNodegetCallSite (CallSiteID id) const
 
const VFGNodegetDefVFGNode (const ValVar *valVar) const
 Given a valVar, return its definition site.
 
bool hasLHSTopLevPtr (const VFGNode *node) const
 
const SVFVargetLHSTopLevPtr (const VFGNode *node) const
 
bool hasStmtVFGNode (const SVFStmt *svfStmt) const
 Existence checks for VFGNodes.
 
bool hasIntraPHIVFGNode (const SVFVar *svfVar) const
 
bool hasBinaryOPVFGNode (const SVFVar *svfVar) const
 
bool hasUnaryOPVFGNode (const SVFVar *svfVar) const
 
bool hasBranchVFGNode (const SVFVar *svfVar) const
 
bool hasCmpVFGNode (const SVFVar *svfVar) const
 
bool hasActualParmVFGNode (const SVFVar *aparm, const CallICFGNode *cs) const
 
bool hasActualRetVFGNode (const SVFVar *aret) const
 
bool hasFormalParmVFGNode (const SVFVar *fparm) const
 
bool hasFormalRetVFGNode (const SVFVar *fret) const
 
StmtVFGNodegetStmtVFGNode (const SVFStmt *svfStmt) const
 Get an VFGNode.
 
IntraPHIVFGNodegetIntraPHIVFGNode (const SVFVar *svfVar) const
 
BinaryOPVFGNodegetBinaryOPVFGNode (const SVFVar *svfVar) const
 
UnaryOPVFGNodegetUnaryOPVFGNode (const SVFVar *svfVar) const
 
BranchVFGNodegetBranchVFGNode (const SVFVar *svfVar) const
 
CmpVFGNodegetCmpVFGNode (const SVFVar *svfVar) const
 
ActualParmVFGNodegetActualParmVFGNode (const SVFVar *aparm, const CallICFGNode *cs) const
 
ActualRetVFGNodegetActualRetVFGNode (const SVFVar *aret) const
 
FormalParmVFGNodegetFormalParmVFGNode (const SVFVar *fparm) const
 
FormalRetVFGNodegetFormalRetVFGNode (const SVFVar *fret) const
 
const FunObjVarisFunEntryVFGNode (const VFGNode *node) const
 Whether a node is function entry VFGNode.
 
bool hasBlackHoleConstObjAddrAsDef (const ValVar *valVar) const
 Whether a SVFVar has a blackhole or const object as its definition.
 
VFGEdgeaddIntraDirectVFEdge (NodeID srcId, NodeID dstId)
 
VFGEdgeaddCallEdge (NodeID srcId, NodeID dstId, CallSiteID csId)
 
VFGEdgeaddRetEdge (NodeID srcId, NodeID dstId, CallSiteID csId)
 
void removeVFGEdge (VFGEdge *edge)
 Remove a SVFG edge.
 
void removeVFGNode (VFGNode *node)
 Remove a VFGNode.
 
VFGEdgehasIntraVFGEdge (VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
 Whether we has a SVFG edge.
 
VFGEdgehasInterVFGEdge (VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind, CallSiteID csId)
 
VFGEdgehasThreadVFGEdge (VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
 
bool addVFGEdge (VFGEdge *edge)
 Add VFG edge.
 
VFGNodeSetgetVFGNodes (const FunObjVar *fun)
 
bool hasVFGNodes (const FunObjVar *fun) const
 
bool VFGNodes (const FunObjVar *fun) const
 
VFGNodeSet::const_iterator getVFGNodeBegin (const FunObjVar *fun) const
 
VFGNodeSet::const_iterator getVFGNodeEnd (const FunObjVar *fun) const
 
- Public Member Functions inherited from SVF::GenericGraph< NodeTy, EdgeTy >
 GenericGraph ()
 Constructor.
 
virtual ~GenericGraph ()
 Destructor.
 
void destroy ()
 Release memory.
 
iterator begin ()
 Iterators.
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node.
 
NodeTypegetGNode (NodeID id) const
 Get a node.
 
bool hasGNode (NodeID id) const
 Has a node.
 
void removeGNode (NodeType *node)
 Delete a node.
 
u32_t getTotalNodeNum () const
 Get total number of node/edge.
 
u32_t getTotalEdgeNum () const
 
void incNodeNum ()
 Increase number of node/edge.
 
void incEdgeNum ()
 

Protected Member Functions

void destroy ()
 Clean up memory.
 
void checkIntraEdgeParents (const VFGNode *srcNode, const VFGNode *dstNode)
 sanitize Intra edges, verify that both nodes belong to the same function.
 
VFGEdgeaddInterEdgeFromAPToFP (ActualParmVFGNode *src, FormalParmVFGNode *dst, CallSiteID csId)
 Add inter VF edge from actual to formal parameters.
 
VFGEdgeaddInterEdgeFromFRToAR (FormalRetVFGNode *src, ActualRetVFGNode *dst, CallSiteID csId)
 Add inter VF edge from callee return to callsite receive parameter.
 
VFGEdgeaddInterEdgeFromAPToFP (NodeID src, NodeID dst, CallSiteID csId)
 Add inter VF edge from actual to formal parameters.
 
VFGEdgeaddInterEdgeFromFRToAR (NodeID src, NodeID dst, CallSiteID csId)
 Add inter VF edge from callee return to callsite receive parameter.
 
virtual void connectAParamAndFParam (const ValVar *csArg, const ValVar *funArg, const CallICFGNode *cbn, CallSiteID csId, VFGEdgeSetTy &edges)
 Connect VFG nodes between caller and callee for indirect call site.
 
virtual void connectFRetAndARet (const ValVar *funReturn, const ValVar *csReturn, CallSiteID csId, VFGEdgeSetTy &edges)
 Connect formal-ret and actual ret.
 
void setDef (const ValVar *valVar, const VFGNode *node)
 Given a ValVar, set/get its def VFG node (definition of top level pointers)
 
NodeID getDef (const ValVar *valVar) const
 
bool hasDef (const ValVar *valVar) const
 
void addVFGNodes ()
 Create VFG nodes.
 
virtual SVFStmt::SVFStmtSetTygetSVFStmtSet (SVFStmt::PEDGEK kind)
 Get SVFStmt set.
 
virtual bool isInterestedSVFVar (const SVFVar *node) const
 
void connectDirectVFGEdges ()
 Create edges between VFG nodes within a function.
 
void addVFGInterEdges (const CallICFGNode *cs, const FunObjVar *callee)
 Create edges between VFG nodes across functions.
 
bool isPhiCopyEdge (const SVFStmt *copy) const
 
virtual void addVFGNode (VFGNode *vfgNode, ICFGNode *icfgNode)
 Add a VFG node.
 
void addStmtVFGNode (StmtVFGNode *node, const SVFStmt *svfStmt)
 Add a VFG node for program statement.
 
void addNullPtrVFGNode (const ValVar *svfVar)
 
void addAddrVFGNode (const AddrStmt *addr)
 Add an Address VFG node.
 
void addCopyVFGNode (const CopyStmt *copy)
 Add a Copy VFG node.
 
void addGepVFGNode (const GepStmt *gep)
 Add a Gep VFG node.
 
void addLoadVFGNode (const LoadStmt *load)
 Add a Load VFG node.
 
void addStoreVFGNode (const StoreStmt *store)
 
void addActualParmVFGNode (const ValVar *aparm, const CallICFGNode *cs)
 
void addFormalParmVFGNode (const ValVar *fparm, const FunObjVar *fun, const CallPE *callPE)
 Add a formal parameter VFG node.
 
void addFormalRetVFGNode (const ValVar *uniqueFunRet, const FunObjVar *fun, RetPESet &retPEs)
 
void addActualRetVFGNode (const ValVar *ret, const CallICFGNode *cs)
 Add a callsite Receive VFG node.
 
void addIntraPHIVFGNode (const MultiOpndStmt *edge)
 Add an llvm PHI VFG node.
 
void addCmpVFGNode (const CmpStmt *edge)
 Add a Compare VFG node.
 
void addBinaryOPVFGNode (const BinaryOPStmt *edge)
 Add a BinaryOperator VFG node.
 
void addUnaryOPVFGNode (const UnaryOPStmt *edge)
 Add a UnaryOperator VFG node.
 
void addBranchVFGNode (const BranchStmt *edge)
 Add a BranchVFGNode.
 

Protected Attributes

NodeID totalVFGNode
 
ValVarToDefMapTy ValVarToDefMap
 map a pag node to its definition SVG node
 
SVFVarToActualParmMapTy SVFVarToActualParmMap
 map a SVFVar to an actual parameter
 
SVFVarToActualRetMapTy SVFVarToActualRetMap
 map a SVFVar to an actual return
 
SVFVarToFormalParmMapTy SVFVarToFormalParmMap
 map a SVFVar to a formal parameter
 
SVFVarToFormalRetMapTy SVFVarToFormalRetMap
 map a SVFVar to a formal return
 
SVFVarToPHIVFGNodeMapTy SVFVarToIntraPHIVFGNodeMap
 map a SVFVar to its PHIVFGNode
 
SVFVarToBinaryOPVFGNodeMapTy SVFVarToBinaryOPVFGNodeMap
 map a SVFVar to its BinaryOPVFGNode
 
SVFVarToUnaryOPVFGNodeMapTy SVFVarToUnaryOPVFGNodeMap
 map a SVFVar to its UnaryOPVFGNode
 
SVFVarToBranchVFGNodeMapTy SVFVarToBranchVFGNodeMap
 map a SVFVar to its BranchVFGNode
 
SVFVarToCmpVFGNodeMapTy SVFVarToCmpVFGNodeMap
 map a SVFVar to its CmpVFGNode
 
SVFStmtToStmtVFGNodeMapTy SVFStmtToStmtVFGNodeMap
 map a SVFStmt to its StmtVFGNode
 
FunToVFGNodesMapTy funToVFGNodesMap
 map a function to its VFGNodes;
 
GlobalVFGNodeSet globalVFGNodes
 set of global store VFG nodes
 
CallGraphcallgraph
 
SVFIRpag
 
VFGK kind
 
- Protected Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
IDToNodeMapTy IDToNodeMap
 node map
 

Additional Inherited Members

- Public Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
u32_t edgeNum
 total num of node
 
u32_t nodeNum
 total num of edge
 

Detailed Description

Definition at line 50 of file VFG.h.

Member Typedef Documentation

◆ CallPESet

Definition at line 75 of file VFG.h.

◆ const_iterator

typedef VFGNodeIDToNodeMapTy::const_iterator SVF::VFG::const_iterator

Definition at line 81 of file VFG.h.

◆ FunToVFGNodesMapTy

Definition at line 73 of file VFG.h.

◆ GlobalVFGNodeSet

Definition at line 83 of file VFG.h.

◆ iterator

typedef VFGNodeIDToNodeMapTy::iterator SVF::VFG::iterator

Definition at line 80 of file VFG.h.

◆ RetPESet

Definition at line 76 of file VFG.h.

◆ SVFGEdgeSetTy

Definition at line 78 of file VFG.h.

◆ SVFStmtSet

Definition at line 82 of file VFG.h.

◆ SVFStmtToStmtVFGNodeMapTy

Definition at line 67 of file VFG.h.

◆ SVFVarSet

Definition at line 84 of file VFG.h.

◆ SVFVarToActualParmMapTy

Definition at line 63 of file VFG.h.

◆ SVFVarToActualRetMapTy

Definition at line 64 of file VFG.h.

◆ SVFVarToBinaryOPVFGNodeMapTy

Definition at line 69 of file VFG.h.

◆ SVFVarToBranchVFGNodeMapTy

Definition at line 71 of file VFG.h.

◆ SVFVarToCmpVFGNodeMapTy

Definition at line 72 of file VFG.h.

◆ SVFVarToFormalParmMapTy

Definition at line 65 of file VFG.h.

◆ SVFVarToFormalRetMapTy

Definition at line 66 of file VFG.h.

◆ SVFVarToPHIVFGNodeMapTy

Definition at line 68 of file VFG.h.

◆ SVFVarToUnaryOPVFGNodeMapTy

Definition at line 70 of file VFG.h.

◆ ValVarToDefMapTy

Definition at line 62 of file VFG.h.

◆ VFGEdgeSetTy

Definition at line 77 of file VFG.h.

◆ VFGNodeIDToNodeMapTy

Definition at line 60 of file VFG.h.

◆ VFGNodeIter

typedef VFGEdge::VFGEdgeSetTy::iterator SVF::VFG::VFGNodeIter

Definition at line 79 of file VFG.h.

◆ VFGNodeSet

Definition at line 61 of file VFG.h.

Member Enumeration Documentation

◆ VFGK

VFG kind.

Enumerator
FULLSVFG 
PTRONLYSVFG 
FULLSVFG_OPT 
PTRONLYSVFG_OPT 

Definition at line 55 of file VFG.h.

56 {
58 };
@ FULLSVFG
Definition VFG.h:57
@ PTRONLYSVFG_OPT
Definition VFG.h:57
@ FULLSVFG_OPT
Definition VFG.h:57
@ PTRONLYSVFG
Definition VFG.h:57

Constructor & Destructor Documentation

◆ VFG()

VFG::VFG ( CallGraph cg,
VFGK  k = FULLSVFG 
)

Constructor.

Constructor

  • Build VFG 1) build VFG nodes statements for top level pointers (SVFStmts) 2) connect VFG edges between two statements (SVFStmts)

Definition at line 425 of file VFG.cpp.

426{
427
428 DBOUT(DGENERAL, outs() << pasMsg("\tCreate VFG Top Level Node\n"));
429 addVFGNodes();
430
431 DBOUT(DGENERAL, outs() << pasMsg("\tCreate SVFG Direct Edge\n"));
433}
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:593
#define DGENERAL
Definition SVFType.h:599
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:118
SVFIR * pag
Definition VFG.h:104
void addVFGNodes()
Create VFG nodes.
Definition VFG.cpp:447
VFGK kind
Definition VFG.h:105
NodeID totalVFGNode
Definition VFG.h:88
void connectDirectVFGEdges()
Create edges between VFG nodes within a function.
Definition VFG.cpp:707
CallGraph * callgraph
Definition VFG.h:103
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
Definition SVFUtil.cpp:101
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~VFG()

virtual SVF::VFG::~VFG ( )
inlinevirtual

Destructor.

Definition at line 115 of file VFG.h.

116 {
117 destroy();
118 }
void destroy()
Clean up memory.
Definition VFG.cpp:438

Member Function Documentation

◆ addActualParmVFGNode()

void SVF::VFG::addActualParmVFGNode ( const ValVar aparm,
const CallICFGNode cs 
)
inlineprotected

Add an actual parameter VFG node To be noted that multiple actual parameters may have same value (SVFVar) So we need to make a pair <SVFVarID,CallSiteID> to find the right VFGParmNode

do not set def here, this node is not a variable definition

Definition at line 592 of file VFG.h.

593 {
594 ActualParmVFGNode* sNode = new ActualParmVFGNode(totalVFGNode++,aparm,cs);
595 addVFGNode(sNode, const_cast<CallICFGNode*>(cs));
596 SVFVarToActualParmMap[std::make_pair(aparm->getId(),cs)] = sNode;
598 }
SVFVarToActualParmMapTy SVFVarToActualParmMap
map a SVFVar to an actual parameter
Definition VFG.h:90
virtual void addVFGNode(VFGNode *vfgNode, ICFGNode *icfgNode)
Add a VFG node.
Definition VFG.h:526

◆ addActualRetVFGNode()

void SVF::VFG::addActualRetVFGNode ( const ValVar ret,
const CallICFGNode cs 
)
inlineprotected

Add a callsite Receive VFG node.

Definition at line 631 of file VFG.h.

632 {
633 ActualRetVFGNode* sNode = new ActualRetVFGNode(totalVFGNode++,ret,cs);
634 addVFGNode(sNode, const_cast<RetICFGNode*>(cs->getRetICFGNode()));
635 setDef(ret,sNode);
637 }
void setDef(const ValVar *valVar, const VFGNode *node)
Given a ValVar, set/get its def VFG node (definition of top level pointers)
Definition VFG.h:469
SVFVarToActualRetMapTy SVFVarToActualRetMap
map a SVFVar to an actual return
Definition VFG.h:91

◆ addAddrVFGNode()

void SVF::VFG::addAddrVFGNode ( const AddrStmt addr)
inlineprotected

Add an Address VFG node.

Definition at line 554 of file VFG.h.

555 {
556 AddrVFGNode* sNode = new AddrVFGNode(totalVFGNode++,addr);
558 setDef(SVFUtil::cast<ValVar>(addr->getLHSVar()),sNode);
559 }
void addStmtVFGNode(StmtVFGNode *node, const SVFStmt *svfStmt)
Add a VFG node for program statement.
Definition VFG.h:539

◆ addBinaryOPVFGNode()

void SVF::VFG::addBinaryOPVFGNode ( const BinaryOPStmt edge)
inlineprotected

Add a BinaryOperator VFG node.

Definition at line 667 of file VFG.h.

668 {
669 BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, edge->getRes());
670 u32_t pos = 0;
671 for(auto var : edge->getOpndVars())
672 {
673 sNode->setOpVer(pos, var);
674 pos++;
675 }
676 addVFGNode(sNode,edge->getICFGNode());
677 setDef(edge->getRes(),sNode);
679 }
unsigned u32_t
Definition CommandLine.h:18
SVFVarToBinaryOPVFGNodeMapTy SVFVarToBinaryOPVFGNodeMap
map a SVFVar to its BinaryOPVFGNode
Definition VFG.h:95

◆ addBranchVFGNode()

void SVF::VFG::addBranchVFGNode ( const BranchStmt edge)
inlineprotected

Add a BranchVFGNode.

Definition at line 690 of file VFG.h.

691 {
692 BranchVFGNode* sNode = new BranchVFGNode(totalVFGNode++, edge);
693 addVFGNode(sNode,edge->getICFGNode());
694 setDef(edge->getBranchInst(),sNode);
695 SVFVarToBranchVFGNodeMap[edge->getBranchInst()] = sNode;
696 }
SVFVarToBranchVFGNodeMapTy SVFVarToBranchVFGNodeMap
map a SVFVar to its BranchVFGNode
Definition VFG.h:97

◆ addCallEdge()

VFGEdge * VFG::addCallEdge ( NodeID  srcId,
NodeID  dstId,
CallSiteID  csId 
)

Add interprocedural call edges for top level pointers

Definition at line 666 of file VFG.cpp.

667{
671 if (edge != nullptr)
672 {
673 assert(edge->isCallDirectVFGEdge() && "this should be a direct value flow edge!");
674 return nullptr;
675 }
676 else
677 {
679 return (addVFGEdge(callEdge) ? callEdge : nullptr);
680 }
681}
bool addVFGEdge(VFGEdge *edge)
Add VFG edge.
Definition VFG.h:401
VFGNode * getVFGNode(NodeID id) const
Get a VFG node.
Definition VFG.h:145
VFGEdge * hasInterVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind, CallSiteID csId)
Definition VFG.cpp:887

◆ addCmpVFGNode()

void SVF::VFG::addCmpVFGNode ( const CmpStmt edge)
inlineprotected

Add a Compare VFG node.

Definition at line 653 of file VFG.h.

654 {
655 CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, edge->getRes());
656 u32_t pos = 0;
657 for(auto var : edge->getOpndVars())
658 {
659 sNode->setOpVer(pos, var);
660 pos++;
661 }
662 addVFGNode(sNode,edge->getICFGNode());
663 setDef(edge->getRes(),sNode);
664 SVFVarToCmpVFGNodeMap[edge->getRes()] = sNode;
665 }
SVFVarToCmpVFGNodeMapTy SVFVarToCmpVFGNodeMap
map a SVFVar to its CmpVFGNode
Definition VFG.h:98

◆ addCopyVFGNode()

void SVF::VFG::addCopyVFGNode ( const CopyStmt copy)
inlineprotected

Add a Copy VFG node.

Definition at line 561 of file VFG.h.

562 {
563 CopyVFGNode* sNode = new CopyVFGNode(totalVFGNode++,copy);
565 setDef(copy->getLHSVar(),sNode);
566 }
copy
Definition cJSON.cpp:414

◆ addFormalParmVFGNode()

void SVF::VFG::addFormalParmVFGNode ( const ValVar fparm,
const FunObjVar fun,
const CallPE callPE 
)
inlineprotected

Add a formal parameter VFG node.

Definition at line 600 of file VFG.h.

601 {
602 FormalParmVFGNode* sNode = new FormalParmVFGNode(totalVFGNode++,fparm,fun);
604 sNode->setCallPE(callPE);
605
608 }
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
Definition ICFG.cpp:242
ICFG * getICFG() const
Definition SVFIR.h:229
SVFVarToFormalParmMapTy SVFVarToFormalParmMap
map a SVFVar to a formal parameter
Definition VFG.h:92

◆ addFormalRetVFGNode()

void SVF::VFG::addFormalRetVFGNode ( const ValVar uniqueFunRet,
const FunObjVar fun,
RetPESet retPEs 
)
inlineprotected

Add a callee Return VFG node To be noted that here we assume returns of a procedure have already been unified into one Otherwise, we need to handle formalRet using <SVFVarID,CallSiteID> pair to find FormalRetVFG node same as handling actual parameters

if this uniqueFunRet is a phi node, which means it will receive values from multiple return instructions of fun we will set this phi node's def later Ideally, every function uniqueFunRet should be a PhiNode (SVFIRBuilder.cpp), unless it does not have ret instruction

Definition at line 612 of file VFG.h.

613 {
614 FormalRetVFGNode *sNode = new FormalRetVFGNode(totalVFGNode++, uniqueFunRet, fun);
616 for (RetPESet::const_iterator it = retPEs.begin(), eit = retPEs.end(); it != eit; ++it)
617 sNode->addRetPE(*it);
618
624 {
625 std::string warn = fun->getName();
626 SVFUtil::writeWrnMsg(warn + " does not have any ret instruction!");
628 }
629 }
FunExitICFGNode * getFunExitICFGNode(const FunObjVar *fun)
Add a function exit node.
Definition ICFG.cpp:249
bool isPhiNode(const SVFVar *node) const
Whether this SVFVar is a result operand a of phi node.
Definition SVFIR.h:354
SVFVarToFormalRetMapTy SVFVarToFormalRetMap
map a SVFVar to a formal return
Definition VFG.h:93
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition SVFUtil.cpp:68

◆ addGepVFGNode()

void SVF::VFG::addGepVFGNode ( const GepStmt gep)
inlineprotected

Add a Gep VFG node.

Definition at line 568 of file VFG.h.

569 {
570 GepVFGNode* sNode = new GepVFGNode(totalVFGNode++,gep);
572 setDef(gep->getLHSVar(),sNode);
573 }

◆ addInterEdgeFromAPToFP() [1/2]

VFGEdge * SVF::VFG::addInterEdgeFromAPToFP ( ActualParmVFGNode src,
FormalParmVFGNode dst,
CallSiteID  csId 
)
inlineprotected

Add inter VF edge from actual to formal parameters.

Definition at line 424 of file VFG.h.

425 {
426 return addCallEdge(src->getId(),dst->getId(),csId);
427 }
VFGEdge * addCallEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
Definition VFG.cpp:666

◆ addInterEdgeFromAPToFP() [2/2]

VFGEdge * SVF::VFG::addInterEdgeFromAPToFP ( NodeID  src,
NodeID  dst,
CallSiteID  csId 
)
inlineprotected

Add inter VF edge from actual to formal parameters.

Definition at line 435 of file VFG.h.

436 {
437 return addCallEdge(src,dst,csId);
438 }

◆ addInterEdgeFromFRToAR() [1/2]

VFGEdge * SVF::VFG::addInterEdgeFromFRToAR ( FormalRetVFGNode src,
ActualRetVFGNode dst,
CallSiteID  csId 
)
inlineprotected

Add inter VF edge from callee return to callsite receive parameter.

Definition at line 429 of file VFG.h.

430 {
431 return addRetEdge(src->getId(),dst->getId(),csId);
432 }
VFGEdge * addRetEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
Definition VFG.cpp:686

◆ addInterEdgeFromFRToAR() [2/2]

VFGEdge * SVF::VFG::addInterEdgeFromFRToAR ( NodeID  src,
NodeID  dst,
CallSiteID  csId 
)
inlineprotected

Add inter VF edge from callee return to callsite receive parameter.

Definition at line 440 of file VFG.h.

441 {
442 return addRetEdge(src,dst,csId);
443 }

◆ addIntraDirectVFEdge()

VFGEdge * VFG::addIntraDirectVFEdge ( NodeID  srcId,
NodeID  dstId 
)

Add control-flow edges for top level pointers

Add def-use edges for top level pointers

Definition at line 640 of file VFG.cpp.

641{
646 if (edge != nullptr)
647 {
648 assert(edge->isDirectVFGEdge() && "this should be a direct value flow edge!");
649 return nullptr;
650 }
651 else
652 {
653 if(srcNode!=dstNode)
654 {
657 }
658 else
659 return nullptr;
660 }
661}
@ IntraDirectVF
Definition VFGEdge.h:53
void checkIntraEdgeParents(const VFGNode *srcNode, const VFGNode *dstNode)
sanitize Intra edges, verify that both nodes belong to the same function.
Definition VFG.h:413
VFGEdge * hasIntraVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
Whether we has a SVFG edge.
Definition VFG.cpp:852

◆ addIntraPHIVFGNode()

void SVF::VFG::addIntraPHIVFGNode ( const MultiOpndStmt edge)
inlineprotected

Add an llvm PHI VFG node.

Definition at line 639 of file VFG.h.

640 {
641 IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++, edge->getRes());
642 u32_t pos = 0;
643 for(auto var : edge->getOpndVars())
644 {
645 sNode->setOpVerAndBB(pos, var, edge->getICFGNode());
646 pos++;
647 }
648 addVFGNode(sNode,edge->getICFGNode());
649 setDef(edge->getRes(),sNode);
651 }
SVFVarToPHIVFGNodeMapTy SVFVarToIntraPHIVFGNodeMap
map a SVFVar to its PHIVFGNode
Definition VFG.h:94

◆ addLoadVFGNode()

void SVF::VFG::addLoadVFGNode ( const LoadStmt load)
inlineprotected

Add a Load VFG node.

Definition at line 575 of file VFG.h.

576 {
577 LoadVFGNode* sNode = new LoadVFGNode(totalVFGNode++,load);
578 addStmtVFGNode(sNode, load);
579 setDef(load->getLHSVar(),sNode);
580 }

◆ addNullPtrVFGNode()

void SVF::VFG::addNullPtrVFGNode ( const ValVar svfVar)
inlineprotected

Add a Dummy VFG node for null pointer definition To be noted for black hole pointer it has already has address edge connected

Definition at line 547 of file VFG.h.

548 {
549 NullPtrVFGNode* sNode = new NullPtrVFGNode(totalVFGNode++,svfVar);
552 }
GlobalICFGNode * getGlobalICFGNode() const
Definition ICFG.h:244

◆ addRetEdge()

VFGEdge * VFG::addRetEdge ( NodeID  srcId,
NodeID  dstId,
CallSiteID  csId 
)

Add interprocedural return edges for top level pointers

Definition at line 686 of file VFG.cpp.

687{
691 if (edge != nullptr)
692 {
693 assert(edge->isRetDirectVFGEdge() && "this should be a direct value flow edge!");
694 return nullptr;
695 }
696 else
697 {
699 return (addVFGEdge(retEdge) ? retEdge : nullptr);
700 }
701}

◆ addStmtVFGNode()

void SVF::VFG::addStmtVFGNode ( StmtVFGNode node,
const SVFStmt svfStmt 
)
inlineprotected

Add a VFG node for program statement.

Definition at line 539 of file VFG.h.

540 {
541 assert(SVFStmtToStmtVFGNodeMap.find(svfStmt)==SVFStmtToStmtVFGNodeMap.end() && "should not insert twice!");
542 SVFStmtToStmtVFGNodeMap[svfStmt] = node;
543 addVFGNode(node, svfStmt->getICFGNode());
544 }
SVFStmtToStmtVFGNodeMapTy SVFStmtToStmtVFGNodeMap
map a SVFStmt to its StmtVFGNode
Definition VFG.h:99

◆ addStoreVFGNode()

void SVF::VFG::addStoreVFGNode ( const StoreStmt store)
inlineprotected

Add a Store VFG node, To be noted store does not create a new pointer, we do not set def for any SVFIR node

Definition at line 583 of file VFG.h.

584 {
585 StoreVFGNode* sNode = new StoreVFGNode(totalVFGNode++,store);
586 addStmtVFGNode(sNode, store);
587 }

◆ addUnaryOPVFGNode()

void SVF::VFG::addUnaryOPVFGNode ( const UnaryOPStmt edge)
inlineprotected

Add a UnaryOperator VFG node.

Definition at line 681 of file VFG.h.

682 {
683 UnaryOPVFGNode* sNode = new UnaryOPVFGNode(totalVFGNode++, edge->getRes());
684 sNode->setOpVer(0, edge->getOpVar());
685 addVFGNode(sNode,edge->getICFGNode());
686 setDef(edge->getRes(),sNode);
688 }
SVFVarToUnaryOPVFGNodeMapTy SVFVarToUnaryOPVFGNodeMap
map a SVFVar to its UnaryOPVFGNode
Definition VFG.h:96

◆ addVFGEdge()

bool SVF::VFG::addVFGEdge ( VFGEdge edge)
inline

Add VFG edge.

Definition at line 401 of file VFG.h.

402 {
403 bool added1 = edge->getDstNode()->addIncomingEdge(edge);
404 bool added2 = edge->getSrcNode()->addOutgoingEdge(edge);
405 bool both_added = added1 & added2;
406 assert(both_added && "VFGEdge not added??");
407 return both_added;
408 }

◆ addVFGInterEdges()

void SVF::VFG::addVFGInterEdges ( const CallICFGNode cs,
const FunObjVar callee 
)
protected

Create edges between VFG nodes across functions.

◆ addVFGNode()

virtual void SVF::VFG::addVFGNode ( VFGNode vfgNode,
ICFGNode icfgNode 
)
inlineprotectedvirtual

Add a VFG node.

Definition at line 526 of file VFG.h.

527 {
528 addGNode(vfgNode->getId(), vfgNode);
529 vfgNode->setICFGNode(icfgNode);
530 icfgNode->addVFGNode(vfgNode);
531
532 if(const FunObjVar* fun = icfgNode->getFun())
533 funToVFGNodesMap[fun].insert(vfgNode);
534 else
535 globalVFGNodes.insert(vfgNode);
536 }
void addGNode(NodeID id, NodeType *node)
Add a Node.
GlobalVFGNodeSet globalVFGNodes
set of global store VFG nodes
Definition VFG.h:102
FunToVFGNodesMapTy funToVFGNodesMap
map a function to its VFGNodes;
Definition VFG.h:100

◆ addVFGNodes()

void VFG::addVFGNodes ( )
protected

Create VFG nodes.

Create VFG nodes for top level pointers

for external function we do not create acutalRet VFGNode they are in the formal of AddrVFGNode if the external function returns an allocated memory if fun has body, it may also exist in isExtCall, e.g., xmalloc() in bzip2, spec2000.

Definition at line 447 of file VFG.cpp.

448{
449
450 // initialize dummy definition null pointers in order to uniform the construction
451 // to be noted for black hole pointer it has already has address edge connected,
452 // and its definition will be set when processing addr SVFIR edge.
454
455 // initialize address nodes
457 for (SVFStmt::SVFStmtSetTy::iterator iter = addrs.begin(), eiter =
458 addrs.end(); iter != eiter; ++iter)
459 {
460 addAddrVFGNode(SVFUtil::cast<AddrStmt>(*iter));
461 }
462
463 // initialize copy nodes
465 for (SVFStmt::SVFStmtSetTy::iterator iter = copys.begin(), eiter =
466 copys.end(); iter != eiter; ++iter)
467 {
468 const CopyStmt* edge = SVFUtil::cast<CopyStmt>(*iter);
469 assert(!isPhiCopyEdge(edge) && "Copy edges can not be a PhiNode (or from PhiNode)");
471 }
472
473 // initialize gep nodes
475 for (SVFStmt::SVFStmtSetTy::iterator iter = ngeps.begin(), eiter =
476 ngeps.end(); iter != eiter; ++iter)
477 {
478 addGepVFGNode(SVFUtil::cast<GepStmt>(*iter));
479 }
480
481 // initialize load nodes
483 for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
484 loads.end(); iter != eiter; ++iter)
485 {
486 addLoadVFGNode(SVFUtil::cast<LoadStmt>(*iter));
487 }
488
489 // initialize store nodes
491 for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
492 stores.end(); iter != eiter; ++iter)
493 {
494 addStoreVFGNode(SVFUtil::cast<StoreStmt>(*iter));
495 }
496
498 for (SVFStmt::SVFStmtSetTy::iterator iter = forks.begin(), eiter =
499 forks.end(); iter != eiter; ++iter)
500 {
501 TDForkPE* forkedge = SVFUtil::cast<TDForkPE>(*iter);
502 for(u32_t i = 0; i < forkedge->getOpVarNum(); i++)
503 addActualParmVFGNode(forkedge->getOpVar(i), forkedge->getOpCallICFGNode(i));
504 }
505
506 // initialize actual parameter nodes
507 for(SVFIR::CSToArgsListMap::iterator it = pag->getCallSiteArgsMap().begin(), eit = pag->getCallSiteArgsMap().end(); it !=eit; ++it)
508 {
509
510 for(SVFIR::ValVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
511 {
512 const ValVar* svfVar = *pit;
515 }
516 }
517
518 // initialize actual return nodes (callsite return)
519 for(SVFIR::CSToRetMap::iterator it = pag->getCallSiteRets().begin(), eit = pag->getCallSiteRets().end(); it !=eit; ++it)
520 {
521
525 if(isInterestedSVFVar(it->second) == false || hasDef(it->second))
526 continue;
527
528 addActualRetVFGNode(it->second,it->first->getCallICFGNode());
529 }
530
531 // initialize formal parameter nodes
532 for(SVFIR::FunToArgsListMap::iterator it = pag->getFunArgsMap().begin(), eit = pag->getFunArgsMap().end(); it !=eit; ++it)
533 {
534 const FunObjVar* func = it->first;
535
536 for(SVFIR::ValVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
537 {
538 const ValVar* param = *pit;
539 if (isInterestedSVFVar(param) == false || hasBlackHoleConstObjAddrAsDef(param))
540 continue;
541
542 const CallPE* callPE = pag->getCallPEForFormalParm(param);
543 addFormalParmVFGNode(param,func,callPE);
544 }
545
546 if (func->isVarArg())
547 {
550 continue;
551
554 }
555 }
556
557 // initialize formal return nodes (callee return)
558 for (SVFIR::FunToRetMap::iterator it = pag->getFunRets().begin(), eit = pag->getFunRets().end(); it != eit; ++it)
559 {
560 const FunObjVar* func = it->first;
561
562 const ValVar* uniqueFunRetNode = it->second;
563
564 RetPESet retPEs;
565 if (uniqueFunRetNode->hasOutgoingEdges(SVFStmt::Ret))
566 {
567 for (SVFStmt::SVFStmtSetTy::const_iterator cit = uniqueFunRetNode->getOutgoingEdgesBegin(SVFStmt::Ret),
568 ecit = uniqueFunRetNode->getOutgoingEdgesEnd(SVFStmt::Ret);
569 cit != ecit; ++cit)
570 {
571 const RetPE* retPE = SVFUtil::cast<RetPE>(*cit);
572 if (isInterestedSVFVar(retPE->getLHSVar()))
573 retPEs.insert(retPE);
574 }
575 }
576
579 }
580
581 // initialize llvm phi nodes (phi of top level pointers)
583 for (SVFStmt::SVFStmtSetTy::iterator iter = phis.begin(), eiter =
584 phis.end(); iter != eiter; ++iter)
585 {
586 const PhiStmt* edge = SVFUtil::cast<PhiStmt>(*iter);
587 if(isInterestedSVFVar(edge->getRes()))
589 }
590 // initialize select statement
592 for (SVFStmt::SVFStmtSetTy::iterator iter = selects.begin(), eiter =
593 selects.end(); iter != eiter; ++iter)
594 {
595 const MultiOpndStmt* edge = SVFUtil::cast<MultiOpndStmt>(*iter);
596 if(isInterestedSVFVar(edge->getRes()))
598 }
599 // initialize llvm binary nodes (binary operators)
601 for (SVFStmt::SVFStmtSetTy::iterator iter = binaryops.begin(), eiter =
602 binaryops.end(); iter != eiter; ++iter)
603 {
604 const BinaryOPStmt* edge = SVFUtil::cast<BinaryOPStmt>(*iter);
605 if(isInterestedSVFVar(edge->getRes()))
607 }
608 // initialize llvm unary nodes (unary operators)
610 for (SVFStmt::SVFStmtSetTy::iterator iter = unaryops.begin(), eiter =
611 unaryops.end(); iter != eiter; ++iter)
612 {
613 const UnaryOPStmt* edge = SVFUtil::cast<UnaryOPStmt>(*iter);
614 if(isInterestedSVFVar(edge->getRes()))
616 }
617 // initialize llvm unary nodes (unary operators)
619 for (SVFStmt::SVFStmtSetTy::iterator iter = brs.begin(), eiter =
620 brs.end(); iter != eiter; ++iter)
621 {
622 const BranchStmt* edge = SVFUtil::cast<BranchStmt>(*iter);
623 if(isInterestedSVFVar(edge->getBranchInst()))
625 }
626 // initialize llvm cmp nodes (comparison)
628 for (SVFStmt::SVFStmtSetTy::iterator iter = cmps.begin(), eiter =
629 cmps.end(); iter != eiter; ++iter)
630 {
631 const CmpStmt* edge = SVFUtil::cast<CmpStmt>(*iter);
632 if(isInterestedSVFVar(edge->getRes()))
634 }
635}
NodeID getNullPtr() const
Definition IRGraph.h:259
NodeID getVarargNode(const FunObjVar *func) const
getVarargNode - Return the unique node representing the variadic argument of a variadic function.
Definition IRGraph.cpp:67
const ValVar * getLHSVar() const
CSToArgsListMap & getCallSiteArgsMap()
Get callsite argument list.
Definition SVFIR.h:388
CSToRetMap & getCallSiteRets()
Get callsite return.
Definition SVFIR.h:400
FunToRetMap & getFunRets()
Get function return list.
Definition SVFIR.h:416
const ValVar * getValVar(NodeID id) const
Definition SVFIR.h:137
CallPE * getCallPEForFormalParm(const SVFVar *param) const
Get the CallPE for a formal parameter (phi-like, nullptr if not found)
Definition SVFIR.h:359
FunToArgsListMap & getFunArgsMap()
Get function arguments list.
Definition SVFIR.h:371
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
void addStoreVFGNode(const StoreStmt *store)
Definition VFG.h:583
void addBranchVFGNode(const BranchStmt *edge)
Add a BranchVFGNode.
Definition VFG.h:690
void addLoadVFGNode(const LoadStmt *load)
Add a Load VFG node.
Definition VFG.h:575
void addCopyVFGNode(const CopyStmt *copy)
Add a Copy VFG node.
Definition VFG.h:561
void addGepVFGNode(const GepStmt *gep)
Add a Gep VFG node.
Definition VFG.h:568
bool isPhiCopyEdge(const SVFStmt *copy) const
Definition VFG.h:520
bool hasDef(const ValVar *valVar) const
Definition VFG.h:488
void addFormalParmVFGNode(const ValVar *fparm, const FunObjVar *fun, const CallPE *callPE)
Add a formal parameter VFG node.
Definition VFG.h:600
void addUnaryOPVFGNode(const UnaryOPStmt *edge)
Add a UnaryOperator VFG node.
Definition VFG.h:681
void addCmpVFGNode(const CmpStmt *edge)
Add a Compare VFG node.
Definition VFG.h:653
void addActualParmVFGNode(const ValVar *aparm, const CallICFGNode *cs)
Definition VFG.h:592
void addNullPtrVFGNode(const ValVar *svfVar)
Definition VFG.h:547
virtual SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get SVFStmt set.
Definition VFG.h:498
void addFormalRetVFGNode(const ValVar *uniqueFunRet, const FunObjVar *fun, RetPESet &retPEs)
Definition VFG.h:612
FormalRetVFGNode::RetPESet RetPESet
Definition VFG.h:76
void addBinaryOPVFGNode(const BinaryOPStmt *edge)
Add a BinaryOperator VFG node.
Definition VFG.h:667
void addAddrVFGNode(const AddrStmt *addr)
Add an Address VFG node.
Definition VFG.h:554
void addActualRetVFGNode(const ValVar *ret, const CallICFGNode *cs)
Add a callsite Receive VFG node.
Definition VFG.h:631
virtual bool isInterestedSVFVar(const SVFVar *node) const
Definition VFG.h:506
bool hasBlackHoleConstObjAddrAsDef(const ValVar *valVar) const
Whether a SVFVar has a blackhole or const object as its definition.
Definition VFG.h:327
void addIntraPHIVFGNode(const MultiOpndStmt *edge)
Add an llvm PHI VFG node.
Definition VFG.h:639

◆ checkIntraEdgeParents()

void SVF::VFG::checkIntraEdgeParents ( const VFGNode srcNode,
const VFGNode dstNode 
)
inlineprotected

sanitize Intra edges, verify that both nodes belong to the same function.

Definition at line 413 of file VFG.h.

414 {
415 const FunObjVar *srcfun = srcNode->getFun();
416 const FunObjVar *dstfun = dstNode->getFun();
417 if(srcfun != nullptr && dstfun != nullptr)
418 {
419 assert((srcfun == dstfun) && "src and dst nodes of an intra VFG edge are not in the same function?");
420 }
421 }

◆ connectAParamAndFParam()

virtual void SVF::VFG::connectAParamAndFParam ( const ValVar csArg,
const ValVar funArg,
const CallICFGNode cbn,
CallSiteID  csId,
VFGEdgeSetTy edges 
)
inlineprotectedvirtual

Connect VFG nodes between caller and callee for indirect call site.

Connect actual-param and formal param

Reimplemented in SVF::SVFGOPT.

Definition at line 448 of file VFG.h.

449 {
453 if (edge != nullptr)
454 edges.insert(edge);
455 }
NodeID getId() const
Get ID.
Definition SVFValue.h:163
VFGEdge * addInterEdgeFromAPToFP(ActualParmVFGNode *src, FormalParmVFGNode *dst, CallSiteID csId)
Add inter VF edge from actual to formal parameters.
Definition VFG.h:424
ActualParmVFGNode * getActualParmVFGNode(const SVFVar *aparm, const CallICFGNode *cs) const
Definition VFG.h:297
FormalParmVFGNode * getFormalParmVFGNode(const SVFVar *fparm) const
Definition VFG.h:309
u32_t NodeID
Definition GeneralType.h:56

◆ connectCallerAndCallee()

void VFG::connectCallerAndCallee ( const CallICFGNode callBlockNode,
const FunObjVar callee,
VFGEdgeSetTy edges 
)
virtual

Connect VFG nodes between caller and callee for indirect call site.

Connect actual params/return to formal params/return for top-level variables. Also connect indirect actual in/out and formal in/out.

Reimplemented in SVF::SVFG.

Definition at line 950 of file VFG.cpp.

951{
952 SVFIR * pag = SVFIR::getPAG();
953 CallSiteID csId = getCallSiteID(callBlockNode, callee);
954 const RetICFGNode* retBlockNode = callBlockNode->getRetICFGNode();
955 // connect actual and formal param
956 if (pag->hasCallSiteArgsMap(callBlockNode) && pag->hasFunArgsList(callee) &&
957 matchArgs(callBlockNode, callee))
958 {
959 const SVFIR::ValVarList& csArgList = pag->getCallSiteArgsList(callBlockNode);
961 SVFIR::ValVarList::const_iterator csArgIt = csArgList.begin(), csArgEit = csArgList.end();
962 SVFIR::ValVarList::const_iterator funArgIt = funArgList.begin(), funArgEit = funArgList.end();
963 for (; funArgIt != funArgEit && csArgIt != csArgEit; funArgIt++, csArgIt++)
964 {
965 const ValVar *cs_arg = *csArgIt;
966 const ValVar *fun_arg = *funArgIt;
968 connectAParamAndFParam(cs_arg, fun_arg, callBlockNode, csId, edges);
969 }
970 assert(funArgIt == funArgEit && "function has more arguments than call site");
971
972 if (callee->isVarArg())
973 {
977 {
978 for (; csArgIt != csArgEit; csArgIt++)
979 {
980 const ValVar *cs_arg = *csArgIt;
982 connectAParamAndFParam(cs_arg, varFunArgNode, callBlockNode, csId, edges);
983 }
984 }
985 }
986 }
987
988 // connect actual return and formal return
990 {
995 }
996}
const RetICFGNode * getRetICFGNode() const
Return callsite.
Definition ICFGNode.h:439
bool funHasRet(const FunObjVar *func) const
Definition SVFIR.h:427
bool hasFunArgsList(const FunObjVar *func) const
Function has arguments list.
Definition SVFIR.h:366
const ValVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
Definition SVFIR.h:405
const ValVarList & getFunArgsList(const FunObjVar *func) const
Get function arguments list.
Definition SVFIR.h:376
std::vector< const ValVar * > ValVarList
Definition SVFIR.h:58
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
Definition SVFIR.h:383
bool callsiteHasRet(const RetICFGNode *cs) const
Definition SVFIR.h:411
const ValVar * getFunRet(const FunObjVar *func) const
Get function return list.
Definition SVFIR.h:421
const ValVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
Definition SVFIR.h:393
virtual void connectAParamAndFParam(const ValVar *csArg, const ValVar *funArg, const CallICFGNode *cbn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
Definition VFG.h:448
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *func) const
Get callsite given a callsiteID.
Definition VFG.h:178
virtual void connectFRetAndARet(const ValVar *funReturn, const ValVar *csReturn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect formal-ret and actual ret.
Definition VFG.h:457
bool matchArgs(const CallICFGNode *cs, const FunObjVar *callee)
Definition SVFUtil.cpp:308
unsigned CallSiteID
Definition GeneralType.h:58

◆ connectDirectVFGEdges()

void VFG::connectDirectVFGEdges ( )
protected

Create edges between VFG nodes within a function.

Connect def-use chains for direct value-flow, (value-flow of top level pointers)

do not handle AddrSVFG node, as it is already the source of a definition

for all other cases, like copy/gep/load/ret, connect the RHS pointer to its def

for store, connect the RHS/LHS pointer to its def

connect formal ret to its definition node

connect formal ret to actual ret

Do not process FormalRetVFGNode, as they are connected by copy within callee We assume one procedure only has unique return

connect direct value-flow edges (parameter passing) for thread fork/join

add fork edge

add join edge

Definition at line 707 of file VFG.cpp.

708{
709
710 for(iterator it = begin(), eit = end(); it!=eit; ++it)
711 {
712 NodeID nodeId = it->first;
713 VFGNode* node = it->second;
714
715 if(StmtVFGNode* stmtNode = SVFUtil::dyn_cast<StmtVFGNode>(node))
716 {
718 if(SVFUtil::isa<AddrVFGNode>(stmtNode))
719 continue;
721 if (stmtNode->getSrcNode()->isConstDataOrAggDataButNotNullPtr() == false)
722 // for ptr vfg, we skip src node of integer type if it is at a int2ptr copystmt
723 if(isInterestedSVFVar(stmtNode->getSrcNode()))
724 addIntraDirectVFEdge(getDef(SVFUtil::cast<ValVar>(stmtNode->getSrcNode())), nodeId);
725 if (const GepStmt* gepStmt = SVFUtil::dyn_cast<GepStmt>(stmtNode->getSVFStmt()))
726 {
727 for (const auto &varType: gepStmt->getOffsetVarAndGepTypePairVec())
728 {
729 if(varType.first->isConstDataOrAggDataButNotNullPtr() || isInterestedSVFVar(varType.first) == false)
730 continue;
732 }
733 }
735 if(SVFUtil::isa<StoreVFGNode>(stmtNode) && (stmtNode->getDstNode()->isConstDataOrAggDataButNotNullPtr() == false))
736 {
737 addIntraDirectVFEdge(getDef(SVFUtil::cast<ValVar>(stmtNode->getDstNode())), nodeId);
738 }
739
740 }
741 else if(PHIVFGNode* phiNode = SVFUtil::dyn_cast<PHIVFGNode>(node))
742 {
743 for (PHIVFGNode::OPVers::const_iterator it = phiNode->opVerBegin(), eit = phiNode->opVerEnd(); it != eit; it++)
744 {
745 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
747 }
748 }
749 else if(BinaryOPVFGNode* binaryNode = SVFUtil::dyn_cast<BinaryOPVFGNode>(node))
750 {
751 for (BinaryOPVFGNode::OPVers::const_iterator it = binaryNode->opVerBegin(), eit = binaryNode->opVerEnd(); it != eit; it++)
752 {
753 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
755 }
756 }
757 else if(UnaryOPVFGNode* unaryNode = SVFUtil::dyn_cast<UnaryOPVFGNode>(node))
758 {
759 for (UnaryOPVFGNode::OPVers::const_iterator it = unaryNode->opVerBegin(), eit = unaryNode->opVerEnd(); it != eit; it++)
760 {
761 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
763 }
764 }
765 else if(CmpVFGNode* cmpNode = SVFUtil::dyn_cast<CmpVFGNode>(node))
766 {
767 for (CmpVFGNode::OPVers::const_iterator it = cmpNode->opVerBegin(), eit = cmpNode->opVerEnd(); it != eit; it++)
768 {
769 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
771 }
772 }
773 else if(BranchVFGNode* branchNode = SVFUtil::dyn_cast<BranchVFGNode>(node))
774 {
775 const ValVar* cond = branchNode->getBranchStmt()->getCondition();
776 if (cond->isConstDataOrAggDataButNotNullPtr() == false)
778 }
779 else if(ActualParmVFGNode* actualParm = SVFUtil::dyn_cast<ActualParmVFGNode>(node))
780 {
781 if (actualParm->getParam()->isConstDataOrAggDataButNotNullPtr() == false)
783 }
784 else if(FormalParmVFGNode* formalParm = SVFUtil::dyn_cast<FormalParmVFGNode>(node))
785 {
786 if(const CallPE* callPE = formalParm->getCallPE())
787 {
788 for(u32_t i = 0; i < callPE->getOpVarNum(); i++)
789 {
790 if(isInterestedSVFVar(callPE->getOpVar(i)))
791 {
792 const CallICFGNode* cs = callPE->getOpCallICFGNode(i);
793 ActualParmVFGNode* acutalParm = getActualParmVFGNode(callPE->getOpVar(i), cs);
795 }
796 }
797 }
798 }
799 else if(FormalRetVFGNode* calleeRet = SVFUtil::dyn_cast<FormalRetVFGNode>(node))
800 {
803
805 for(RetPESet::const_iterator it = calleeRet->retPEBegin(), eit = calleeRet->retPEEnd(); it!=eit; ++it)
806 {
807 ActualRetVFGNode* callsiteRev = getActualRetVFGNode((*it)->getLHSVar());
808 const CallICFGNode* callBlockNode = (*it)->getCallSite();
810 }
811 }
814 }
815
818 {
821 for (SVFStmt::SVFStmtSetTy::iterator iter = forks.begin(), eiter =
822 forks.end(); iter != eiter; ++iter)
823 {
824 TDForkPE* forkedge = SVFUtil::cast<TDForkPE>(*iter);
826 for(u32_t i = 0; i < forkedge->getOpVarNum(); i++)
827 {
828 if(isInterestedSVFVar(forkedge->getOpVar(i)))
829 {
830 const CallICFGNode* cs = forkedge->getOpCallICFGNode(i);
833 }
834 }
835 }
838 for (SVFStmt::SVFStmtSetTy::iterator iter = joins.begin(), eiter =
839 joins.end(); iter != eiter; ++iter)
840 {
841 TDJoinPE* joinedge = SVFUtil::cast<TDJoinPE>(*iter);
842 NodeID callsiteRev = getDef(joinedge->getLHSVar());
844 addRetEdge(calleeRet->getId(),callsiteRev, getCallSiteID(joinedge->getCallSite(), calleeRet->getFun()));
845 }
846 }
847}
iterator begin()
Iterators.
static const Option< bool > EnableThreadCallGraph
Definition Options.h:129
virtual bool isConstDataOrAggDataButNotNullPtr() const
Check if this variable represents constant data/metadata but not null pointer.
FormalRetVFGNode * getFormalRetVFGNode(const SVFVar *fret) const
Definition VFG.h:315
NodeID getDef(const ValVar *valVar) const
Definition VFG.h:482
VFGEdge * addInterEdgeFromFRToAR(FormalRetVFGNode *src, ActualRetVFGNode *dst, CallSiteID csId)
Add inter VF edge from callee return to callsite receive parameter.
Definition VFG.h:429
VFGNodeIDToNodeMapTy::iterator iterator
Definition VFG.h:80
VFGEdge * addIntraDirectVFEdge(NodeID srcId, NodeID dstId)
Definition VFG.cpp:640
ActualRetVFGNode * getActualRetVFGNode(const SVFVar *aret) const
Definition VFG.h:303

◆ connectFRetAndARet()

virtual void SVF::VFG::connectFRetAndARet ( const ValVar funReturn,
const ValVar csReturn,
CallSiteID  csId,
VFGEdgeSetTy edges 
)
inlineprotectedvirtual

Connect formal-ret and actual ret.

Reimplemented in SVF::SVFGOPT.

Definition at line 457 of file VFG.h.

458 {
461 VFGEdge* edge = addInterEdgeFromFRToAR(formalRet, actualRet,csId);
462 if (edge != nullptr)
463 edges.insert(edge);
464 }

◆ destroy()

void VFG::destroy ( )
protected

Clean up memory.

Memory has been cleaned up at GenericGraph

Definition at line 438 of file VFG.cpp.

439{
440 pag = nullptr;
441}

◆ dump()

void VFG::dump ( const std::string &  file,
bool  simple = false 
)

Dump graph into dot file.

Dump VFG

Definition at line 914 of file VFG.cpp.

915{
917}
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType &GT, bool simple=false)

◆ getActualParmVFGNode()

ActualParmVFGNode * SVF::VFG::getActualParmVFGNode ( const SVFVar aparm,
const CallICFGNode cs 
) const
inline

Definition at line 297 of file VFG.h.

298 {
299 SVFVarToActualParmMapTy::const_iterator it = SVFVarToActualParmMap.find(std::make_pair(aparm->getId(),cs));
300 assert(it!=SVFVarToActualParmMap.end() && "actual parameter VFG node can not be found??");
301 return it->second;
302 }

◆ getActualRetVFGNode()

ActualRetVFGNode * SVF::VFG::getActualRetVFGNode ( const SVFVar aret) const
inline

Definition at line 303 of file VFG.h.

304 {
305 SVFVarToActualRetMapTy::const_iterator it = SVFVarToActualRetMap.find(aret);
306 assert(it!=SVFVarToActualRetMap.end() && "actual return VFG node can not be found??");
307 return it->second;
308 }

◆ getBinaryOPVFGNode()

BinaryOPVFGNode * SVF::VFG::getBinaryOPVFGNode ( const SVFVar svfVar) const
inline

Definition at line 273 of file VFG.h.

274 {
275 SVFVarToBinaryOPVFGNodeMapTy::const_iterator it = SVFVarToBinaryOPVFGNodeMap.find(svfVar);
276 assert(it != SVFVarToBinaryOPVFGNodeMap.end() && "BinaryOPVFGNode can not be found??");
277 return it->second;
278 }

◆ getBranchVFGNode()

BranchVFGNode * SVF::VFG::getBranchVFGNode ( const SVFVar svfVar) const
inline

Definition at line 285 of file VFG.h.

286 {
287 SVFVarToBranchVFGNodeMapTy::const_iterator it = SVFVarToBranchVFGNodeMap.find(svfVar);
288 assert(it != SVFVarToBranchVFGNodeMap.end() && "BranchVFGNode can not be found??");
289 return it->second;
290 }

◆ getCallGraph()

CallGraph * SVF::VFG::getCallGraph ( ) const
inline

Return PTACallGraph.

Definition at line 139 of file VFG.h.

140 {
141 return callgraph;
142 }

◆ getCallSite()

const CallICFGNode * SVF::VFG::getCallSite ( CallSiteID  id) const
inline

Definition at line 182 of file VFG.h.

183 {
184 return callgraph->getCallSite(id);
185 }
const CallICFGNode * getCallSite(CallSiteID id) const
Definition CallGraph.h:408

◆ getCallSiteID()

CallSiteID SVF::VFG::getCallSiteID ( const CallICFGNode cs,
const FunObjVar func 
) const
inline

Get callsite given a callsiteID.

Definition at line 178 of file VFG.h.

179 {
180 return callgraph->getCallSiteID(cs, func);
181 }
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *callee) const
Get CallSiteID.
Definition CallGraph.h:389

◆ getCmpVFGNode()

CmpVFGNode * SVF::VFG::getCmpVFGNode ( const SVFVar svfVar) const
inline

Definition at line 291 of file VFG.h.

292 {
293 SVFVarToCmpVFGNodeMapTy::const_iterator it = SVFVarToCmpVFGNodeMap.find(svfVar);
294 assert(it != SVFVarToCmpVFGNodeMap.end() && "CmpVFGNode can not be found??");
295 return it->second;
296 }

◆ getDef()

NodeID SVF::VFG::getDef ( const ValVar valVar) const
inlineprotected

Definition at line 482 of file VFG.h.

483 {
484 ValVarToDefMapTy::const_iterator it = ValVarToDefMap.find(valVar);
485 assert(it!=ValVarToDefMap.end() && "ValVar does not have a definition??");
486 return it->second;
487 }
ValVarToDefMapTy ValVarToDefMap
map a pag node to its definition SVG node
Definition VFG.h:89

◆ getDefVFGNode()

const VFGNode * SVF::VFG::getDefVFGNode ( const ValVar valVar) const
inline

Given a valVar, return its definition site.

Definition at line 189 of file VFG.h.

190 {
191 return getVFGNode(getDef(valVar));
192 }

◆ getFormalParmVFGNode()

FormalParmVFGNode * SVF::VFG::getFormalParmVFGNode ( const SVFVar fparm) const
inline

Definition at line 309 of file VFG.h.

310 {
311 SVFVarToFormalParmMapTy::const_iterator it = SVFVarToFormalParmMap.find(fparm);
312 assert(it!=SVFVarToFormalParmMap.end() && "formal parameter VFG node can not be found??");
313 return it->second;
314 }

◆ getFormalRetVFGNode()

FormalRetVFGNode * SVF::VFG::getFormalRetVFGNode ( const SVFVar fret) const
inline

Definition at line 315 of file VFG.h.

316 {
317 SVFVarToFormalRetMapTy::const_iterator it = SVFVarToFormalRetMap.find(fret);
318 assert(it!=SVFVarToFormalRetMap.end() && "formal return VFG node can not be found??");
319 return it->second;
320 }

◆ getGlobalVFGNodes()

GlobalVFGNodeSet & SVF::VFG::getGlobalVFGNodes ( )
inline

Return global stores.

Definition at line 156 of file VFG.h.

157 {
158 return globalVFGNodes;
159 }

◆ getIntraPHIVFGNode()

IntraPHIVFGNode * SVF::VFG::getIntraPHIVFGNode ( const SVFVar svfVar) const
inline

Definition at line 267 of file VFG.h.

268 {
269 SVFVarToPHIVFGNodeMapTy::const_iterator it = SVFVarToIntraPHIVFGNodeMap.find(svfVar);
270 assert(it != SVFVarToIntraPHIVFGNodeMap.end() && "PHIVFGNode can not be found??");
271 return it->second;
272 }

◆ getIntraVFGEdge()

VFGEdge * VFG::getIntraVFGEdge ( const VFGNode src,
const VFGNode dst,
VFGEdge::VFGEdgeK  kind 
)

Get a SVFG edge according to src and dst.

Return the corresponding VFGEdge

Definition at line 905 of file VFG.cpp.

906{
907 return hasIntraVFGEdge(const_cast<VFGNode*>(src),const_cast<VFGNode*>(dst),kind);
908}

◆ getKind()

VFGK SVF::VFG::getKind ( ) const
inline

Get VFG kind.

Definition at line 121 of file VFG.h.

122 {
123 return kind;
124 }

◆ getLHSTopLevPtr()

const SVFVar * VFG::getLHSTopLevPtr ( const VFGNode node) const

Given a VFG node, return its left hand side top level pointer

Definition at line 1001 of file VFG.cpp.

1002{
1003
1004 if(const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(node))
1005 return addr->getDstNode();
1006 else if(const CopyVFGNode* copy = SVFUtil::dyn_cast<CopyVFGNode>(node))
1007 return copy->getDstNode();
1008 else if(const GepVFGNode* gep = SVFUtil::dyn_cast<GepVFGNode>(node))
1009 return gep->getDstNode();
1010 else if(const LoadVFGNode* load = SVFUtil::dyn_cast<LoadVFGNode>(node))
1011 return load->getDstNode();
1012 else if(const PHIVFGNode* phi = SVFUtil::dyn_cast<PHIVFGNode>(node))
1013 return phi->getRes();
1014 else if(const CmpVFGNode* cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
1015 return cmp->getRes();
1016 else if(const BinaryOPVFGNode* bop = SVFUtil::dyn_cast<BinaryOPVFGNode>(node))
1017 return bop->getRes();
1018 else if(const UnaryOPVFGNode* uop = SVFUtil::dyn_cast<UnaryOPVFGNode>(node))
1019 return uop->getRes();
1020 else if(const ActualParmVFGNode* ap = SVFUtil::dyn_cast<ActualParmVFGNode>(node))
1021 return ap->getParam();
1022 else if(const FormalParmVFGNode*fp = SVFUtil::dyn_cast<FormalParmVFGNode>(node))
1023 return fp->getParam();
1024 else if(const ActualRetVFGNode* ar = SVFUtil::dyn_cast<ActualRetVFGNode>(node))
1025 return ar->getRev();
1026 else if(const FormalRetVFGNode* fr = SVFUtil::dyn_cast<FormalRetVFGNode>(node))
1027 return fr->getRet();
1028 else if(const NullPtrVFGNode* nullVFG = SVFUtil::dyn_cast<NullPtrVFGNode>(node))
1029 return nullVFG->getSVFVar();
1030 else
1031 assert(false && "unexpected node kind!");
1032 return nullptr;
1033}

◆ getPAG()

SVFIR * SVF::VFG::getPAG ( ) const
inline

Return SVFIR.

Definition at line 133 of file VFG.h.

134 {
135 return pag;
136 }

◆ getStmtVFGNode()

StmtVFGNode * SVF::VFG::getStmtVFGNode ( const SVFStmt svfStmt) const
inline

Get an VFGNode.

Definition at line 261 of file VFG.h.

262 {
263 SVFStmtToStmtVFGNodeMapTy::const_iterator it = SVFStmtToStmtVFGNodeMap.find(svfStmt);
264 assert(it != SVFStmtToStmtVFGNodeMap.end() && "StmtVFGNode can not be found??");
265 return it->second;
266 }

◆ getSVFStmtSet()

virtual SVFStmt::SVFStmtSetTy & SVF::VFG::getSVFStmtSet ( SVFStmt::PEDGEK  kind)
inlineprotectedvirtual

Get SVFStmt set.

Definition at line 498 of file VFG.h.

499 {
500 if (isPtrOnlySVFG())
501 return pag->getPTASVFStmtSet(kind);
502 else
503 return pag->getSVFStmtSet(kind);
504 }
SVFStmt::SVFStmtSetTy & getPTASVFStmtSet(SVFStmt::PEDGEK kind)
Get PTA edges set according to its kind.
Definition SVFIR.h:301
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition SVFIR.h:296
bool isPtrOnlySVFG() const
Return true if this VFG only contains pointer related SVFGNodes for pointer analysis.
Definition VFG.h:127

◆ getUnaryOPVFGNode()

UnaryOPVFGNode * SVF::VFG::getUnaryOPVFGNode ( const SVFVar svfVar) const
inline

Definition at line 279 of file VFG.h.

280 {
281 SVFVarToUnaryOPVFGNodeMapTy::const_iterator it = SVFVarToUnaryOPVFGNodeMap.find(svfVar);
282 assert(it != SVFVarToUnaryOPVFGNodeMap.end() && "UnaryOPVFGNode can not be found??");
283 return it->second;
284 }

◆ getVFGNode()

VFGNode * SVF::VFG::getVFGNode ( NodeID  id) const
inline

Get a VFG node.

Definition at line 145 of file VFG.h.

146 {
147 return getGNode(id);
148 }
NodeType * getGNode(NodeID id) const
Get a node.

◆ getVFGNodeBegin()

VFGNodeSet::const_iterator SVF::VFG::getVFGNodeBegin ( const FunObjVar fun) const
inline

Definition at line 360 of file VFG.h.

361 {
362 FunToVFGNodesMapTy::const_iterator it = funToVFGNodesMap.find(fun);
363 assert(it != funToVFGNodesMap.end() && "this function does not have any VFGNode");
364 return it->second.begin();
365 }

◆ getVFGNodeEnd()

VFGNodeSet::const_iterator SVF::VFG::getVFGNodeEnd ( const FunObjVar fun) const
inline

Definition at line 366 of file VFG.h.

367 {
368 FunToVFGNodesMapTy::const_iterator it = funToVFGNodesMap.find(fun);
369 assert(it != funToVFGNodesMap.end() && "this function does not have any VFGNode");
370 return it->second.end();
371 }

◆ getVFGNodes()

VFGNodeSet & SVF::VFG::getVFGNodes ( const FunObjVar fun)
inline

Return all the VFGNodes of a function

Definition at line 348 of file VFG.h.

349 {
350 return funToVFGNodesMap[fun];
351 }

◆ hasActualParmVFGNode()

bool SVF::VFG::hasActualParmVFGNode ( const SVFVar aparm,
const CallICFGNode cs 
) const
inline

Definition at line 241 of file VFG.h.

242 {
243 return SVFVarToActualParmMap.find(std::make_pair(aparm->getId(),cs)) != SVFVarToActualParmMap.end();
244 }

◆ hasActualRetVFGNode()

bool SVF::VFG::hasActualRetVFGNode ( const SVFVar aret) const
inline

Definition at line 245 of file VFG.h.

246 {
247 return SVFVarToActualRetMap.find(aret) != SVFVarToActualRetMap.end();
248 }

◆ hasBinaryOPVFGNode()

bool SVF::VFG::hasBinaryOPVFGNode ( const SVFVar svfVar) const
inline

Definition at line 225 of file VFG.h.

226 {
228 }

◆ hasBlackHoleConstObjAddrAsDef()

bool SVF::VFG::hasBlackHoleConstObjAddrAsDef ( const ValVar valVar) const
inline

Whether a SVFVar has a blackhole or const object as its definition.

Definition at line 327 of file VFG.h.

328 {
329 if (hasDef(valVar))
330 {
331 const VFGNode* defNode = getVFGNode(getDef(valVar));
332 if (const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(defNode))
333 {
334 if (SVFIR::getPAG()->isBlkObjOrConstantObj(addr->getSVFStmt()->getSrcID()))
335 return true;
336 }
337 else if(const CopyVFGNode* copy = SVFUtil::dyn_cast<CopyVFGNode>(defNode))
338 {
339 if (SVFIR::getPAG()->isNullPtr(copy->getSVFStmt()->getSrcID()))
340 return true;
341 }
342 }
343 return false;
344 }

◆ hasBranchVFGNode()

bool SVF::VFG::hasBranchVFGNode ( const SVFVar svfVar) const
inline

Definition at line 233 of file VFG.h.

234 {
236 }

◆ hasCmpVFGNode()

bool SVF::VFG::hasCmpVFGNode ( const SVFVar svfVar) const
inline

Definition at line 237 of file VFG.h.

238 {
240 }

◆ hasDef()

bool SVF::VFG::hasDef ( const ValVar valVar) const
inlineprotected

Definition at line 488 of file VFG.h.

489 {
490 return (ValVarToDefMap.find(valVar) != ValVarToDefMap.end());
491 }

◆ hasFormalParmVFGNode()

bool SVF::VFG::hasFormalParmVFGNode ( const SVFVar fparm) const
inline

Definition at line 249 of file VFG.h.

250 {
252 }

◆ hasFormalRetVFGNode()

bool SVF::VFG::hasFormalRetVFGNode ( const SVFVar fret) const
inline

Definition at line 253 of file VFG.h.

254 {
255 return SVFVarToFormalRetMap.find(fret) != SVFVarToFormalRetMap.end();
256 }

◆ hasInterVFGEdge()

VFGEdge * VFG::hasInterVFGEdge ( VFGNode src,
VFGNode dst,
VFGEdge::VFGEdgeK  kind,
CallSiteID  csId 
)

Whether we has an inter VFG edge

Definition at line 887 of file VFG.cpp.

888{
892 if (outEdge && inEdge)
893 {
894 assert(outEdge == inEdge && "edges not match");
895 return outEdge;
896 }
897 else
898 return nullptr;
899}
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const
static GEdgeFlag makeEdgeFlagWithInvokeID(GEdgeKind k, CallSiteID cs)
Compute the unique edgeFlag value from edge kind and CallSiteID.
Definition VFGEdge.h:120

◆ hasIntraPHIVFGNode()

bool SVF::VFG::hasIntraPHIVFGNode ( const SVFVar svfVar) const
inline

Definition at line 221 of file VFG.h.

222 {
224 }

◆ hasIntraVFGEdge()

VFGEdge * VFG::hasIntraVFGEdge ( VFGNode src,
VFGNode dst,
VFGEdge::VFGEdgeK  kind 
)

Whether we has a SVFG edge.

Whether we has an intra VFG edge

Definition at line 852 of file VFG.cpp.

853{
854 VFGEdge edge(src,dst,kind);
857 if (outEdge && inEdge)
858 {
859 assert(outEdge == inEdge && "edges not match");
860 return outEdge;
861 }
862 else
863 return nullptr;
864}

◆ hasLHSTopLevPtr()

bool SVF::VFG::hasLHSTopLevPtr ( const VFGNode node) const
inline

Definition at line 195 of file VFG.h.

196 {
197 return node && SVFUtil::isa<AddrVFGNode,
198 CopyVFGNode,
199 GepVFGNode,
200 LoadVFGNode,
201 PHIVFGNode,
202 CmpVFGNode,
203 BinaryOPVFGNode,
204 UnaryOPVFGNode,
205 ActualParmVFGNode,
206 FormalParmVFGNode,
207 ActualRetVFGNode,
208 FormalRetVFGNode,
209 NullPtrVFGNode>(node);
210 }
LLVM_NODISCARD bool isa(const Y &Val)
Definition Casting.h:241

◆ hasStmtVFGNode()

bool SVF::VFG::hasStmtVFGNode ( const SVFStmt svfStmt) const
inline

Existence checks for VFGNodes.

Definition at line 217 of file VFG.h.

218 {
219 return SVFStmtToStmtVFGNodeMap.find(svfStmt) != SVFStmtToStmtVFGNodeMap.end();
220 }

◆ hasThreadVFGEdge()

VFGEdge * VFG::hasThreadVFGEdge ( VFGNode src,
VFGNode dst,
VFGEdge::VFGEdgeK  kind 
)

Whether we has an thread VFG edge

Definition at line 870 of file VFG.cpp.

871{
872 VFGEdge edge(src,dst,kind);
875 if (outEdge && inEdge)
876 {
877 assert(outEdge == inEdge && "edges not match");
878 return outEdge;
879 }
880 else
881 return nullptr;
882}

◆ hasUnaryOPVFGNode()

bool SVF::VFG::hasUnaryOPVFGNode ( const SVFVar svfVar) const
inline

Definition at line 229 of file VFG.h.

230 {
232 }

◆ hasVFGNode()

bool SVF::VFG::hasVFGNode ( NodeID  id) const
inline

Whether has the VFGNode.

Definition at line 151 of file VFG.h.

152 {
153 return hasGNode(id);
154 }
bool hasGNode(NodeID id) const
Has a node.

◆ hasVFGNodes()

bool SVF::VFG::hasVFGNodes ( const FunObjVar fun) const
inline

Definition at line 352 of file VFG.h.

353 {
354 return funToVFGNodesMap.find(fun) != funToVFGNodesMap.end();
355 }

◆ isFunEntryVFGNode()

const FunObjVar * VFG::isFunEntryVFGNode ( const VFGNode node) const

Whether a node is function entry VFGNode.

Whether this is an function entry VFGNode (formal parameter, formal In)

Definition at line 1038 of file VFG.cpp.

1039{
1040 if(const FormalParmVFGNode* fp = SVFUtil::dyn_cast<FormalParmVFGNode>(node))
1041 {
1042 return fp->getFun();
1043 }
1044 else if(const InterPHIVFGNode* phi = SVFUtil::dyn_cast<InterPHIVFGNode>(node))
1045 {
1046 if(phi->isFormalParmPHI())
1047 return phi->getFun();
1048 }
1049 return nullptr;
1050}

◆ isInterestedSVFVar()

virtual bool SVF::VFG::isInterestedSVFVar ( const SVFVar node) const
inlineprotectedvirtual

Definition at line 506 of file VFG.h.

507 {
508 if (isPtrOnlySVFG())
509 return node->isPointer();
510 else
511 return true;
512 }

◆ isPhiCopyEdge()

bool SVF::VFG::isPhiCopyEdge ( const SVFStmt copy) const
inlineprotected

Definition at line 520 of file VFG.h.

521 {
522 return pag->isPhiNode(copy->getDstNode());
523 }

◆ isPtrOnlySVFG()

bool SVF::VFG::isPtrOnlySVFG ( ) const
inline

Return true if this VFG only contains pointer related SVFGNodes for pointer analysis.

Definition at line 127 of file VFG.h.

128 {
129 return (kind == PTRONLYSVFG) || (kind == PTRONLYSVFG_OPT);
130 }

◆ removeVFGEdge()

void SVF::VFG::removeVFGEdge ( VFGEdge edge)
inline

Remove a SVFG edge.

Definition at line 381 of file VFG.h.

382 {
383 edge->getDstNode()->removeIncomingEdge(edge);
384 edge->getSrcNode()->removeOutgoingEdge(edge);
385 delete edge;
386 }

◆ removeVFGNode()

void SVF::VFG::removeVFGNode ( VFGNode node)
inline

Remove a VFGNode.

Definition at line 388 of file VFG.h.

389 {
390 removeGNode(node);
391 }
void removeGNode(NodeType *node)
Delete a node.

◆ setDef()

void SVF::VFG::setDef ( const ValVar valVar,
const VFGNode node 
)
inlineprotected

Given a ValVar, set/get its def VFG node (definition of top level pointers)

Definition at line 469 of file VFG.h.

470 {
471 ValVarToDefMapTy::iterator it = ValVarToDefMap.find(valVar);
472 if(it == ValVarToDefMap.end())
473 {
474 ValVarToDefMap[valVar] = node->getId();
475 assert(hasVFGNode(node->getId()) && "not in the map!!");
476 }
477 else
478 {
479 assert((it->second == node->getId()) && "a ValVar can only have unique definition ");
480 }
481 }
bool hasVFGNode(NodeID id) const
Whether has the VFGNode.
Definition VFG.h:151

◆ updateCallGraph()

void VFG::updateCallGraph ( PointerAnalysis pta)

Update VFG based on pointer analysis results.

Definition at line 928 of file VFG.cpp.

929{
930 VFGEdgeSetTy vfEdgesAtIndCallSite;
931 PointerAnalysis::CallEdgeMap::const_iterator iter = pta->getIndCallMap().begin();
932 PointerAnalysis::CallEdgeMap::const_iterator eiter = pta->getIndCallMap().end();
933 for (; iter != eiter; iter++)
934 {
935 const CallICFGNode* newcs = iter->first;
936 assert(newcs->isIndirectCall() && "this is not an indirect call?");
938 for (PointerAnalysis::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
939 {
940 const FunObjVar* func = *func_iter;
941 connectCallerAndCallee(newcs, func, vfEdgesAtIndCallSite);
942 }
943 }
944}
Set< const FunObjVar * > FunctionSet
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
VFGEdge::VFGEdgeSetTy VFGEdgeSetTy
Definition VFG.h:77
virtual void connectCallerAndCallee(const CallICFGNode *cs, const FunObjVar *callee, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
Definition VFG.cpp:950

◆ VFGNodes()

bool SVF::VFG::VFGNodes ( const FunObjVar fun) const
inline

Definition at line 356 of file VFG.h.

357 {
358 return funToVFGNodesMap.find(fun) != funToVFGNodesMap.end();
359 }

◆ view()

void VFG::view ( )

Dump graph into dot file.

View VFG from the debugger.

Definition at line 922 of file VFG.cpp.

923{
924 SVF::ViewGraph(this, "Value Flow Graph");
925}
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)

Member Data Documentation

◆ callgraph

CallGraph* SVF::VFG::callgraph
protected

Definition at line 103 of file VFG.h.

◆ funToVFGNodesMap

FunToVFGNodesMapTy SVF::VFG::funToVFGNodesMap
protected

map a function to its VFGNodes;

Definition at line 100 of file VFG.h.

◆ globalVFGNodes

GlobalVFGNodeSet SVF::VFG::globalVFGNodes
protected

set of global store VFG nodes

Definition at line 102 of file VFG.h.

◆ kind

VFGK SVF::VFG::kind
protected

Definition at line 105 of file VFG.h.

◆ pag

SVFIR* SVF::VFG::pag
protected

Definition at line 104 of file VFG.h.

◆ SVFStmtToStmtVFGNodeMap

SVFStmtToStmtVFGNodeMapTy SVF::VFG::SVFStmtToStmtVFGNodeMap
protected

map a SVFStmt to its StmtVFGNode

Definition at line 99 of file VFG.h.

◆ SVFVarToActualParmMap

SVFVarToActualParmMapTy SVF::VFG::SVFVarToActualParmMap
protected

map a SVFVar to an actual parameter

Definition at line 90 of file VFG.h.

◆ SVFVarToActualRetMap

SVFVarToActualRetMapTy SVF::VFG::SVFVarToActualRetMap
protected

map a SVFVar to an actual return

Definition at line 91 of file VFG.h.

◆ SVFVarToBinaryOPVFGNodeMap

SVFVarToBinaryOPVFGNodeMapTy SVF::VFG::SVFVarToBinaryOPVFGNodeMap
protected

map a SVFVar to its BinaryOPVFGNode

Definition at line 95 of file VFG.h.

◆ SVFVarToBranchVFGNodeMap

SVFVarToBranchVFGNodeMapTy SVF::VFG::SVFVarToBranchVFGNodeMap
protected

map a SVFVar to its BranchVFGNode

Definition at line 97 of file VFG.h.

◆ SVFVarToCmpVFGNodeMap

SVFVarToCmpVFGNodeMapTy SVF::VFG::SVFVarToCmpVFGNodeMap
protected

map a SVFVar to its CmpVFGNode

Definition at line 98 of file VFG.h.

◆ SVFVarToFormalParmMap

SVFVarToFormalParmMapTy SVF::VFG::SVFVarToFormalParmMap
protected

map a SVFVar to a formal parameter

Definition at line 92 of file VFG.h.

◆ SVFVarToFormalRetMap

SVFVarToFormalRetMapTy SVF::VFG::SVFVarToFormalRetMap
protected

map a SVFVar to a formal return

Definition at line 93 of file VFG.h.

◆ SVFVarToIntraPHIVFGNodeMap

SVFVarToPHIVFGNodeMapTy SVF::VFG::SVFVarToIntraPHIVFGNodeMap
protected

map a SVFVar to its PHIVFGNode

Definition at line 94 of file VFG.h.

◆ SVFVarToUnaryOPVFGNodeMap

SVFVarToUnaryOPVFGNodeMapTy SVF::VFG::SVFVarToUnaryOPVFGNodeMap
protected

map a SVFVar to its UnaryOPVFGNode

Definition at line 96 of file VFG.h.

◆ totalVFGNode

NodeID SVF::VFG::totalVFGNode
protected

Definition at line 88 of file VFG.h.

◆ ValVarToDefMap

ValVarToDefMapTy SVF::VFG::ValVarToDefMap
protected

map a pag node to its definition SVG node

Definition at line 89 of file VFG.h.


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