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 426 of file VFG.cpp.

427{
428
429 DBOUT(DGENERAL, outs() << pasMsg("\tCreate VFG Top Level Node\n"));
430 addVFGNodes();
431
432 DBOUT(DGENERAL, outs() << pasMsg("\tCreate SVFG Direct Edge\n"));
434}
#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:448
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:708
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:105
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:439

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 667 of file VFG.cpp.

668{
672 if (edge != nullptr)
673 {
674 assert(edge->isCallDirectVFGEdge() && "this should be a direct value flow edge!");
675 return nullptr;
676 }
677 else
678 {
680 return (addVFGEdge(callEdge) ? callEdge : nullptr);
681 }
682}
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:888

◆ 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:72

◆ 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:667

◆ 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:687

◆ 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 641 of file VFG.cpp.

642{
647 if (edge != nullptr)
648 {
649 assert(edge->isDirectVFGEdge() && "this should be a direct value flow edge!");
650 return nullptr;
651 }
652 else
653 {
654 if(srcNode!=dstNode)
655 {
658 }
659 else
660 return nullptr;
661 }
662}
@ 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:853

◆ 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 687 of file VFG.cpp.

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

◆ 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 448 of file VFG.cpp.

449{
450
451 // initialize dummy definition null pointers in order to uniform the construction
452 // to be noted for black hole pointer it has already has address edge connected,
453 // and its definition will be set when processing addr SVFIR edge.
455
456 // initialize address nodes
458 for (SVFStmt::SVFStmtSetTy::iterator iter = addrs.begin(), eiter =
459 addrs.end(); iter != eiter; ++iter)
460 {
461 addAddrVFGNode(SVFUtil::cast<AddrStmt>(*iter));
462 }
463
464 // initialize copy nodes
466 for (SVFStmt::SVFStmtSetTy::iterator iter = copys.begin(), eiter =
467 copys.end(); iter != eiter; ++iter)
468 {
469 const CopyStmt* edge = SVFUtil::cast<CopyStmt>(*iter);
470 assert(!isPhiCopyEdge(edge) && "Copy edges can not be a PhiNode (or from PhiNode)");
472 }
473
474 // initialize gep nodes
476 for (SVFStmt::SVFStmtSetTy::iterator iter = ngeps.begin(), eiter =
477 ngeps.end(); iter != eiter; ++iter)
478 {
479 addGepVFGNode(SVFUtil::cast<GepStmt>(*iter));
480 }
481
482 // initialize load nodes
484 for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
485 loads.end(); iter != eiter; ++iter)
486 {
487 addLoadVFGNode(SVFUtil::cast<LoadStmt>(*iter));
488 }
489
490 // initialize store nodes
492 for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
493 stores.end(); iter != eiter; ++iter)
494 {
495 addStoreVFGNode(SVFUtil::cast<StoreStmt>(*iter));
496 }
497
499 for (SVFStmt::SVFStmtSetTy::iterator iter = forks.begin(), eiter =
500 forks.end(); iter != eiter; ++iter)
501 {
502 TDForkPE* forkedge = SVFUtil::cast<TDForkPE>(*iter);
503 for(u32_t i = 0; i < forkedge->getOpVarNum(); i++)
504 addActualParmVFGNode(forkedge->getOpVar(i), forkedge->getOpCallICFGNode(i));
505 }
506
507 // initialize actual parameter nodes
508 for(SVFIR::CSToArgsListMap::iterator it = pag->getCallSiteArgsMap().begin(), eit = pag->getCallSiteArgsMap().end(); it !=eit; ++it)
509 {
510
511 for(SVFIR::ValVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
512 {
513 const ValVar* svfVar = *pit;
516 }
517 }
518
519 // initialize actual return nodes (callsite return)
520 for(SVFIR::CSToRetMap::iterator it = pag->getCallSiteRets().begin(), eit = pag->getCallSiteRets().end(); it !=eit; ++it)
521 {
522
526 if(isInterestedSVFVar(it->second) == false || hasDef(it->second))
527 continue;
528
529 addActualRetVFGNode(it->second,it->first->getCallICFGNode());
530 }
531
532 // initialize formal parameter nodes
533 for(SVFIR::FunToArgsListMap::iterator it = pag->getFunArgsMap().begin(), eit = pag->getFunArgsMap().end(); it !=eit; ++it)
534 {
535 const FunObjVar* func = it->first;
536
537 for(SVFIR::ValVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
538 {
539 const ValVar* param = *pit;
540 if (isInterestedSVFVar(param) == false || hasBlackHoleConstObjAddrAsDef(param))
541 continue;
542
543 const CallPE* callPE = pag->getCallPEForFormalParm(param);
544 addFormalParmVFGNode(param,func,callPE);
545 }
546
547 if (func->isVarArg())
548 {
551 continue;
552
555 }
556 }
557
558 // initialize formal return nodes (callee return)
559 for (SVFIR::FunToRetMap::iterator it = pag->getFunRets().begin(), eit = pag->getFunRets().end(); it != eit; ++it)
560 {
561 const FunObjVar* func = it->first;
562
563 const ValVar* uniqueFunRetNode = it->second;
564
565 RetPESet retPEs;
566 if (uniqueFunRetNode->hasOutgoingEdges(SVFStmt::Ret))
567 {
568 for (SVFStmt::SVFStmtSetTy::const_iterator cit = uniqueFunRetNode->getOutgoingEdgesBegin(SVFStmt::Ret),
569 ecit = uniqueFunRetNode->getOutgoingEdgesEnd(SVFStmt::Ret);
570 cit != ecit; ++cit)
571 {
572 const RetPE* retPE = SVFUtil::cast<RetPE>(*cit);
573 if (isInterestedSVFVar(retPE->getLHSVar()))
574 retPEs.insert(retPE);
575 }
576 }
577
580 }
581
582 // initialize llvm phi nodes (phi of top level pointers)
584 for (SVFStmt::SVFStmtSetTy::iterator iter = phis.begin(), eiter =
585 phis.end(); iter != eiter; ++iter)
586 {
587 const PhiStmt* edge = SVFUtil::cast<PhiStmt>(*iter);
588 if(isInterestedSVFVar(edge->getRes()))
590 }
591 // initialize select statement
593 for (SVFStmt::SVFStmtSetTy::iterator iter = selects.begin(), eiter =
594 selects.end(); iter != eiter; ++iter)
595 {
596 const MultiOpndStmt* edge = SVFUtil::cast<MultiOpndStmt>(*iter);
597 if(isInterestedSVFVar(edge->getRes()))
599 }
600 // initialize llvm binary nodes (binary operators)
602 for (SVFStmt::SVFStmtSetTy::iterator iter = binaryops.begin(), eiter =
603 binaryops.end(); iter != eiter; ++iter)
604 {
605 const BinaryOPStmt* edge = SVFUtil::cast<BinaryOPStmt>(*iter);
606 if(isInterestedSVFVar(edge->getRes()))
608 }
609 // initialize llvm unary nodes (unary operators)
611 for (SVFStmt::SVFStmtSetTy::iterator iter = unaryops.begin(), eiter =
612 unaryops.end(); iter != eiter; ++iter)
613 {
614 const UnaryOPStmt* edge = SVFUtil::cast<UnaryOPStmt>(*iter);
615 if(isInterestedSVFVar(edge->getRes()))
617 }
618 // initialize llvm unary nodes (unary operators)
620 for (SVFStmt::SVFStmtSetTy::iterator iter = brs.begin(), eiter =
621 brs.end(); iter != eiter; ++iter)
622 {
623 const BranchStmt* edge = SVFUtil::cast<BranchStmt>(*iter);
624 if(isInterestedSVFVar(edge->getBranchInst()))
626 }
627 // initialize llvm cmp nodes (comparison)
629 for (SVFStmt::SVFStmtSetTy::iterator iter = cmps.begin(), eiter =
630 cmps.end(); iter != eiter; ++iter)
631 {
632 const CmpStmt* edge = SVFUtil::cast<CmpStmt>(*iter);
633 if(isInterestedSVFVar(edge->getRes()))
635 }
636}
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:161
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 951 of file VFG.cpp.

952{
953 SVFIR * pag = SVFIR::getPAG();
954 CallSiteID csId = getCallSiteID(callBlockNode, callee);
955 const RetICFGNode* retBlockNode = callBlockNode->getRetICFGNode();
956 // connect actual and formal param
957 if (pag->hasCallSiteArgsMap(callBlockNode) && pag->hasFunArgsList(callee) &&
958 matchArgs(callBlockNode, callee))
959 {
960 const SVFIR::ValVarList& csArgList = pag->getCallSiteArgsList(callBlockNode);
962 SVFIR::ValVarList::const_iterator csArgIt = csArgList.begin(), csArgEit = csArgList.end();
963 SVFIR::ValVarList::const_iterator funArgIt = funArgList.begin(), funArgEit = funArgList.end();
964 for (; funArgIt != funArgEit && csArgIt != csArgEit; funArgIt++, csArgIt++)
965 {
966 const ValVar *cs_arg = *csArgIt;
967 const ValVar *fun_arg = *funArgIt;
969 connectAParamAndFParam(cs_arg, fun_arg, callBlockNode, csId, edges);
970 }
971 assert(funArgIt == funArgEit && "function has more arguments than call site");
972
973 if (callee->isVarArg())
974 {
978 {
979 for (; csArgIt != csArgEit; csArgIt++)
980 {
981 const ValVar *cs_arg = *csArgIt;
983 connectAParamAndFParam(cs_arg, varFunArgNode, callBlockNode, csId, edges);
984 }
985 }
986 }
987 }
988
989 // connect actual return and formal return
991 {
996 }
997}
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:312
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 708 of file VFG.cpp.

709{
710
711 for(iterator it = begin(), eit = end(); it!=eit; ++it)
712 {
713 NodeID nodeId = it->first;
714 VFGNode* node = it->second;
715
716 if(StmtVFGNode* stmtNode = SVFUtil::dyn_cast<StmtVFGNode>(node))
717 {
719 if(SVFUtil::isa<AddrVFGNode>(stmtNode))
720 continue;
722 if (stmtNode->getSrcNode()->isConstDataOrAggDataButNotNullPtr() == false)
723 // for ptr vfg, we skip src node of integer type if it is at a int2ptr copystmt
724 if(isInterestedSVFVar(stmtNode->getSrcNode()))
725 addIntraDirectVFEdge(getDef(SVFUtil::cast<ValVar>(stmtNode->getSrcNode())), nodeId);
726 if (const GepStmt* gepStmt = SVFUtil::dyn_cast<GepStmt>(stmtNode->getSVFStmt()))
727 {
728 for (const auto &varType: gepStmt->getOffsetVarAndGepTypePairVec())
729 {
730 if(varType.first->isConstDataOrAggDataButNotNullPtr() || isInterestedSVFVar(varType.first) == false)
731 continue;
733 }
734 }
736 if(SVFUtil::isa<StoreVFGNode>(stmtNode) && (stmtNode->getDstNode()->isConstDataOrAggDataButNotNullPtr() == false))
737 {
738 addIntraDirectVFEdge(getDef(SVFUtil::cast<ValVar>(stmtNode->getDstNode())), nodeId);
739 }
740
741 }
742 else if(PHIVFGNode* phiNode = SVFUtil::dyn_cast<PHIVFGNode>(node))
743 {
744 for (PHIVFGNode::OPVers::const_iterator it = phiNode->opVerBegin(), eit = phiNode->opVerEnd(); it != eit; it++)
745 {
746 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
748 }
749 }
750 else if(BinaryOPVFGNode* binaryNode = SVFUtil::dyn_cast<BinaryOPVFGNode>(node))
751 {
752 for (BinaryOPVFGNode::OPVers::const_iterator it = binaryNode->opVerBegin(), eit = binaryNode->opVerEnd(); it != eit; it++)
753 {
754 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
756 }
757 }
758 else if(UnaryOPVFGNode* unaryNode = SVFUtil::dyn_cast<UnaryOPVFGNode>(node))
759 {
760 for (UnaryOPVFGNode::OPVers::const_iterator it = unaryNode->opVerBegin(), eit = unaryNode->opVerEnd(); it != eit; it++)
761 {
762 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
764 }
765 }
766 else if(CmpVFGNode* cmpNode = SVFUtil::dyn_cast<CmpVFGNode>(node))
767 {
768 for (CmpVFGNode::OPVers::const_iterator it = cmpNode->opVerBegin(), eit = cmpNode->opVerEnd(); it != eit; it++)
769 {
770 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
772 }
773 }
774 else if(BranchVFGNode* branchNode = SVFUtil::dyn_cast<BranchVFGNode>(node))
775 {
776 const ValVar* cond = branchNode->getBranchStmt()->getCondition();
777 if (cond->isConstDataOrAggDataButNotNullPtr() == false)
779 }
780 else if(ActualParmVFGNode* actualParm = SVFUtil::dyn_cast<ActualParmVFGNode>(node))
781 {
782 if (actualParm->getParam()->isConstDataOrAggDataButNotNullPtr() == false)
784 }
785 else if(FormalParmVFGNode* formalParm = SVFUtil::dyn_cast<FormalParmVFGNode>(node))
786 {
787 if(const CallPE* callPE = formalParm->getCallPE())
788 {
789 for(u32_t i = 0; i < callPE->getOpVarNum(); i++)
790 {
791 if(isInterestedSVFVar(callPE->getOpVar(i)))
792 {
793 const CallICFGNode* cs = callPE->getOpCallICFGNode(i);
794 ActualParmVFGNode* acutalParm = getActualParmVFGNode(callPE->getOpVar(i), cs);
796 }
797 }
798 }
799 }
800 else if(FormalRetVFGNode* calleeRet = SVFUtil::dyn_cast<FormalRetVFGNode>(node))
801 {
804
806 for(RetPESet::const_iterator it = calleeRet->retPEBegin(), eit = calleeRet->retPEEnd(); it!=eit; ++it)
807 {
808 ActualRetVFGNode* callsiteRev = getActualRetVFGNode((*it)->getLHSVar());
809 const CallICFGNode* callBlockNode = (*it)->getCallSite();
811 }
812 }
815 }
816
819 {
822 for (SVFStmt::SVFStmtSetTy::iterator iter = forks.begin(), eiter =
823 forks.end(); iter != eiter; ++iter)
824 {
825 TDForkPE* forkedge = SVFUtil::cast<TDForkPE>(*iter);
827 for(u32_t i = 0; i < forkedge->getOpVarNum(); i++)
828 {
829 if(isInterestedSVFVar(forkedge->getOpVar(i)))
830 {
831 const CallICFGNode* cs = forkedge->getOpCallICFGNode(i);
834 }
835 }
836 }
839 for (SVFStmt::SVFStmtSetTy::iterator iter = joins.begin(), eiter =
840 joins.end(); iter != eiter; ++iter)
841 {
842 TDJoinPE* joinedge = SVFUtil::cast<TDJoinPE>(*iter);
843 NodeID callsiteRev = getDef(joinedge->getLHSVar());
845 addRetEdge(calleeRet->getId(),callsiteRev, getCallSiteID(joinedge->getCallSite(), calleeRet->getFun()));
846 }
847 }
848}
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:641
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 439 of file VFG.cpp.

440{
441 pag = nullptr;
442}

◆ dump()

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

Dump graph into dot file.

Dump VFG

Definition at line 915 of file VFG.cpp.

916{
918}
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 906 of file VFG.cpp.

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

◆ 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 1002 of file VFG.cpp.

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

◆ 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 888 of file VFG.cpp.

889{
893 if (outEdge && inEdge)
894 {
895 assert(outEdge == inEdge && "edges not match");
896 return outEdge;
897 }
898 else
899 return nullptr;
900}
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 853 of file VFG.cpp.

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

◆ 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 871 of file VFG.cpp.

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

◆ 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 1039 of file VFG.cpp.

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

◆ 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 929 of file VFG.cpp.

930{
931 VFGEdgeSetTy vfEdgesAtIndCallSite;
932 CallGraph::CallEdgeMap::const_iterator iter = pta->getIndCallMap().begin();
933 CallGraph::CallEdgeMap::const_iterator eiter = pta->getIndCallMap().end();
934 for (; iter != eiter; iter++)
935 {
936 const CallICFGNode* newcs = iter->first;
937 assert(newcs->isIndirectCall() && "this is not an indirect call?");
939 for (PointerAnalysis::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
940 {
941 const FunObjVar* func = *func_iter;
942 connectCallerAndCallee(newcs, func, vfEdgesAtIndCallSite);
943 }
944 }
945}
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:951

◆ 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 923 of file VFG.cpp.

924{
925 SVF::ViewGraph(this, "Value Flow Graph");
926}
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: