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 PAGNode *, NodeIDPAGNodeToDefMapTy
 
typedef Map< std::pair< NodeID, const CallICFGNode * >, ActualParmVFGNode * > PAGNodeToActualParmMapTy
 
typedef Map< const PAGNode *, ActualRetVFGNode * > PAGNodeToActualRetMapTy
 
typedef Map< const PAGNode *, FormalParmVFGNode * > PAGNodeToFormalParmMapTy
 
typedef Map< const PAGNode *, FormalRetVFGNode * > PAGNodeToFormalRetMapTy
 
typedef Map< const PAGEdge *, StmtVFGNode * > PAGEdgeToStmtVFGNodeMapTy
 
typedef Map< const PAGNode *, IntraPHIVFGNode * > PAGNodeToPHIVFGNodeMapTy
 
typedef Map< const PAGNode *, BinaryOPVFGNode * > PAGNodeToBinaryOPVFGNodeMapTy
 
typedef Map< const PAGNode *, UnaryOPVFGNode * > PAGNodeToUnaryOPVFGNodeMapTy
 
typedef Map< const PAGNode *, BranchVFGNode * > PAGNodeToBranchVFGNodeMapTy
 
typedef Map< const PAGNode *, CmpVFGNode * > PAGNodeToCmpVFGNodeMapTy
 
typedef Map< const SVFFunction *, 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 PAGNode * > PAGNodeSet
 
- 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 (PTACallGraph *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.
 
PTACallGraphgetCallGraph () 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 SVFFunction *callee, VFGEdgeSetTy &edges)
 Connect VFG nodes between caller and callee for indirect call site.
 
CallSiteID getCallSiteID (const CallICFGNode *cs, const SVFFunction *func) const
 Get callsite given a callsiteID.
 
const CallICFGNodegetCallSite (CallSiteID id) const
 
const VFGNodegetDefVFGNode (const PAGNode *pagNode) const
 Given a pagNode, return its definition site.
 
const PAGNodegetLHSTopLevPtr (const VFGNode *node) const
 
StmtVFGNodegetStmtVFGNode (const PAGEdge *pagEdge) const
 Get an VFGNode.
 
IntraPHIVFGNodegetIntraPHIVFGNode (const PAGNode *pagNode) const
 
BinaryOPVFGNodegetBinaryOPVFGNode (const PAGNode *pagNode) const
 
UnaryOPVFGNodegetUnaryOPVFGNode (const PAGNode *pagNode) const
 
BranchVFGNodegetBranchVFGNode (const PAGNode *pagNode) const
 
CmpVFGNodegetCmpVFGNode (const PAGNode *pagNode) const
 
ActualParmVFGNodegetActualParmVFGNode (const PAGNode *aparm, const CallICFGNode *cs) const
 
ActualRetVFGNodegetActualRetVFGNode (const PAGNode *aret) const
 
FormalParmVFGNodegetFormalParmVFGNode (const PAGNode *fparm) const
 
FormalRetVFGNodegetFormalRetVFGNode (const PAGNode *fret) const
 
const SVFFunctionisFunEntryVFGNode (const VFGNode *node) const
 Whether a node is function entry VFGNode.
 
bool hasBlackHoleConstObjAddrAsDef (const PAGNode *pagNode) const
 Whether a PAGNode 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 SVFFunction *fun)
 
bool hasVFGNodes (const SVFFunction *fun) const
 
bool VFGNodes (const SVFFunction *fun) const
 
VFGNodeSet::const_iterator getVFGNodeBegin (const SVFFunction *fun) const
 
VFGNodeSet::const_iterator getVFGNodeEnd (const SVFFunction *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 PAGNode *csArg, const PAGNode *funArg, const CallICFGNode *cbn, CallSiteID csId, VFGEdgeSetTy &edges)
 Connect VFG nodes between caller and callee for indirect call site.
 
virtual void connectFRetAndARet (const PAGNode *funReturn, const PAGNode *csReturn, CallSiteID csId, VFGEdgeSetTy &edges)
 Connect formal-ret and actual ret.
 
void setDef (const PAGNode *pagNode, const VFGNode *node)
 Given a PAGNode, set/get its def VFG node (definition of top level pointers)
 
NodeID getDef (const PAGNode *pagNode) const
 
bool hasDef (const PAGNode *pagNode) const
 
void addVFGNodes ()
 Create VFG nodes.
 
virtual SVFStmt::SVFStmtSetTygetPAGEdgeSet (SVFStmt::PEDGEK kind)
 Get PAGEdge set.
 
virtual bool isInterestedPAGNode (const SVFVar *node) const
 
void connectDirectVFGEdges ()
 Create edges between VFG nodes within a function.
 
void addVFGInterEdges (const CallICFGNode *cs, const SVFFunction *callee)
 Create edges between VFG nodes across functions.
 
bool isPhiCopyEdge (const PAGEdge *copy) const
 
virtual void addVFGNode (VFGNode *vfgNode, ICFGNode *icfgNode)
 Add a VFG node.
 
void addStmtVFGNode (StmtVFGNode *node, const PAGEdge *pagEdge)
 Add a VFG node for program statement.
 
void addNullPtrVFGNode (const PAGNode *pagNode)
 
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 PAGNode *aparm, const CallICFGNode *cs)
 
void addFormalParmVFGNode (const PAGNode *fparm, const SVFFunction *fun, CallPESet &callPEs)
 Add a formal parameter VFG node.
 
void addFormalRetVFGNode (const PAGNode *uniqueFunRet, const SVFFunction *fun, RetPESet &retPEs)
 
void addActualRetVFGNode (const PAGNode *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
 
PAGNodeToDefMapTy PAGNodeToDefMap
 map a pag node to its definition SVG node
 
PAGNodeToActualParmMapTy PAGNodeToActualParmMap
 map a PAGNode to an actual parameter
 
PAGNodeToActualRetMapTy PAGNodeToActualRetMap
 map a PAGNode to an actual return
 
PAGNodeToFormalParmMapTy PAGNodeToFormalParmMap
 map a PAGNode to a formal parameter
 
PAGNodeToFormalRetMapTy PAGNodeToFormalRetMap
 map a PAGNode to a formal return
 
PAGNodeToPHIVFGNodeMapTy PAGNodeToIntraPHIVFGNodeMap
 map a PAGNode to its PHIVFGNode
 
PAGNodeToBinaryOPVFGNodeMapTy PAGNodeToBinaryOPVFGNodeMap
 map a PAGNode to its BinaryOPVFGNode
 
PAGNodeToUnaryOPVFGNodeMapTy PAGNodeToUnaryOPVFGNodeMap
 map a PAGNode to its UnaryOPVFGNode
 
PAGNodeToBranchVFGNodeMapTy PAGNodeToBranchVFGNodeMap
 map a PAGNode to its BranchVFGNode
 
PAGNodeToCmpVFGNodeMapTy PAGNodeToCmpVFGNodeMap
 map a PAGNode to its CmpVFGNode
 
PAGEdgeToStmtVFGNodeMapTy PAGEdgeToStmtVFGNodeMap
 map a PAGEdge to its StmtVFGNode
 
FunToVFGNodesMapTy funToVFGNodesMap
 map a function to its VFGNodes;
 
GlobalVFGNodeSet globalVFGNodes
 set of global store VFG nodes
 
PTACallGraphcallgraph
 
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.

◆ PAGEdgeToStmtVFGNodeMapTy

Definition at line 67 of file VFG.h.

◆ PAGNodeSet

Definition at line 84 of file VFG.h.

◆ PAGNodeToActualParmMapTy

Definition at line 63 of file VFG.h.

◆ PAGNodeToActualRetMapTy

Definition at line 64 of file VFG.h.

◆ PAGNodeToBinaryOPVFGNodeMapTy

Definition at line 69 of file VFG.h.

◆ PAGNodeToBranchVFGNodeMapTy

Definition at line 71 of file VFG.h.

◆ PAGNodeToCmpVFGNodeMapTy

Definition at line 72 of file VFG.h.

◆ PAGNodeToDefMapTy

Definition at line 62 of file VFG.h.

◆ PAGNodeToFormalParmMapTy

Definition at line 65 of file VFG.h.

◆ PAGNodeToFormalRetMapTy

Definition at line 66 of file VFG.h.

◆ PAGNodeToPHIVFGNodeMapTy

Definition at line 68 of file VFG.h.

◆ PAGNodeToUnaryOPVFGNodeMapTy

Definition at line 70 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.

◆ 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 ( PTACallGraph cg,
VFGK  k = FULLSVFG 
)

Constructor.

Constructor

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

Definition at line 441 of file VFG.cpp.

442{
443
444 DBOUT(DGENERAL, outs() << pasMsg("\tCreate VFG Top Level Node\n"));
445 addVFGNodes();
446
447 DBOUT(DGENERAL, outs() << pasMsg("\tCreate SVFG Direct Edge\n"));
449}
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:484
#define DGENERAL
Definition SVFType.h:490
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:116
PTACallGraph * callgraph
Definition VFG.h:103
SVFIR * pag
Definition VFG.h:104
void addVFGNodes()
Create VFG nodes.
Definition VFG.cpp:463
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:742
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
Definition SVFUtil.cpp:100
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~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:454

Member Function Documentation

◆ addActualParmVFGNode()

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

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

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

Definition at line 530 of file VFG.h.

531 {
532 ActualParmVFGNode* sNode = new ActualParmVFGNode(totalVFGNode++,aparm,cs);
533 addVFGNode(sNode, const_cast<CallICFGNode*>(cs));
534 PAGNodeToActualParmMap[std::make_pair(aparm->getId(),cs)] = sNode;
536 }
PAGNodeToActualParmMapTy PAGNodeToActualParmMap
map a PAGNode to an actual parameter
Definition VFG.h:90
virtual void addVFGNode(VFGNode *vfgNode, ICFGNode *icfgNode)
Add a VFG node.
Definition VFG.h:464

◆ addActualRetVFGNode()

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

Add a callsite Receive VFG node.

Definition at line 571 of file VFG.h.

572 {
573 ActualRetVFGNode* sNode = new ActualRetVFGNode(totalVFGNode++,ret,cs);
574 addVFGNode(sNode, const_cast<RetICFGNode*>(cs->getRetICFGNode()));
575 setDef(ret,sNode);
577 }
void setDef(const PAGNode *pagNode, const VFGNode *node)
Given a PAGNode, set/get its def VFG node (definition of top level pointers)
Definition VFG.h:407
PAGNodeToActualRetMapTy PAGNodeToActualRetMap
map a PAGNode 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 492 of file VFG.h.

493 {
494 AddrVFGNode* sNode = new AddrVFGNode(totalVFGNode++,addr);
496 setDef(addr->getLHSVar(),sNode);
497 }
void addStmtVFGNode(StmtVFGNode *node, const PAGEdge *pagEdge)
Add a VFG node for program statement.
Definition VFG.h:477

◆ addBinaryOPVFGNode()

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

Add a BinaryOperator VFG node.

Definition at line 607 of file VFG.h.

608 {
609 BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, edge->getRes());
610 u32_t pos = 0;
611 for(auto var : edge->getOpndVars())
612 {
613 sNode->setOpVer(pos, var);
614 pos++;
615 }
616 addVFGNode(sNode,edge->getICFGNode());
617 setDef(edge->getRes(),sNode);
619 }
unsigned u32_t
Definition CommandLine.h:18
PAGNodeToBinaryOPVFGNodeMapTy PAGNodeToBinaryOPVFGNodeMap
map a PAGNode to its BinaryOPVFGNode
Definition VFG.h:95

◆ addBranchVFGNode()

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

Add a BranchVFGNode.

Definition at line 630 of file VFG.h.

631 {
632 BranchVFGNode* sNode = new BranchVFGNode(totalVFGNode++, edge);
633 addVFGNode(sNode,edge->getICFGNode());
634 setDef(edge->getBranchInst(),sNode);
635 PAGNodeToBranchVFGNodeMap[edge->getBranchInst()] = sNode;
636 }
PAGNodeToBranchVFGNodeMapTy PAGNodeToBranchVFGNodeMap
map a PAGNode 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 701 of file VFG.cpp.

702{
706 if (edge != nullptr)
707 {
708 assert(edge->isCallDirectVFGEdge() && "this should be a direct value flow edge!");
709 return nullptr;
710 }
711 else
712 {
714 return (addVFGEdge(callEdge) ? callEdge : nullptr);
715 }
716}
bool addVFGEdge(VFGEdge *edge)
Add VFG edge.
Definition VFG.h:339
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:910

◆ addCmpVFGNode()

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

Add a Compare VFG node.

Definition at line 593 of file VFG.h.

594 {
595 CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, edge->getRes());
596 u32_t pos = 0;
597 for(auto var : edge->getOpndVars())
598 {
599 sNode->setOpVer(pos, var);
600 pos++;
601 }
602 addVFGNode(sNode,edge->getICFGNode());
603 setDef(edge->getRes(),sNode);
604 PAGNodeToCmpVFGNodeMap[edge->getRes()] = sNode;
605 }
PAGNodeToCmpVFGNodeMapTy PAGNodeToCmpVFGNodeMap
map a PAGNode to its CmpVFGNode
Definition VFG.h:98

◆ addCopyVFGNode()

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

Add a Copy VFG node.

Definition at line 499 of file VFG.h.

500 {
501 CopyVFGNode* sNode = new CopyVFGNode(totalVFGNode++,copy);
503 setDef(copy->getLHSVar(),sNode);
504 }
copy
Definition cJSON.cpp:414

◆ addFormalParmVFGNode()

void SVF::VFG::addFormalParmVFGNode ( const PAGNode fparm,
const SVFFunction fun,
CallPESet callPEs 
)
inlineprotected

Add a formal parameter VFG node.

Definition at line 538 of file VFG.h.

539 {
540 FormalParmVFGNode* sNode = new FormalParmVFGNode(totalVFGNode++,fparm,fun);
542 for(CallPESet::const_iterator it = callPEs.begin(), eit=callPEs.end();
543 it!=eit; ++it)
544 sNode->addCallPE(*it);
545
548 }
FunEntryICFGNode * getFunEntryICFGNode(const SVFFunction *fun)
Add a function entry node.
Definition ICFG.cpp:234
ICFG * getICFG() const
Definition SVFIR.h:172
PAGNodeToFormalParmMapTy PAGNodeToFormalParmMap
map a PAGNode to a formal parameter
Definition VFG.h:92

◆ addFormalRetVFGNode()

void SVF::VFG::addFormalRetVFGNode ( const PAGNode uniqueFunRet,
const SVFFunction 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 <PAGNodeID,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 552 of file VFG.h.

553 {
554 FormalRetVFGNode *sNode = new FormalRetVFGNode(totalVFGNode++, uniqueFunRet, fun);
556 for (RetPESet::const_iterator it = retPEs.begin(), eit = retPEs.end(); it != eit; ++it)
557 sNode->addRetPE(*it);
558
564 {
565 std::string warn = fun->getName();
566 SVFUtil::writeWrnMsg(warn + " does not have any ret instruction!");
568 }
569 }
FunExitICFGNode * getFunExitICFGNode(const SVFFunction *fun)
Add a function exit node.
Definition ICFG.cpp:241
bool isPhiNode(const SVFVar *node) const
Whether this SVFVar is a result operand a of phi node.
Definition SVFIR.h:260
PAGNodeToFormalRetMapTy PAGNodeToFormalRetMap
map a PAGNode to a formal return
Definition VFG.h:93
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition SVFUtil.cpp:67

◆ addGepVFGNode()

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

Add a Gep VFG node.

Definition at line 506 of file VFG.h.

507 {
508 GepVFGNode* sNode = new GepVFGNode(totalVFGNode++,gep);
510 setDef(gep->getLHSVar(),sNode);
511 }

◆ 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 362 of file VFG.h.

363 {
364 return addCallEdge(src->getId(),dst->getId(),csId);
365 }
VFGEdge * addCallEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
Definition VFG.cpp:701

◆ 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 373 of file VFG.h.

374 {
375 return addCallEdge(src,dst,csId);
376 }

◆ 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 367 of file VFG.h.

368 {
369 return addRetEdge(src->getId(),dst->getId(),csId);
370 }
VFGEdge * addRetEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
Definition VFG.cpp:721

◆ 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 378 of file VFG.h.

379 {
380 return addRetEdge(src,dst,csId);
381 }

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

676{
681 if (edge != nullptr)
682 {
683 assert(edge->isDirectVFGEdge() && "this should be a direct value flow edge!");
684 return nullptr;
685 }
686 else
687 {
688 if(srcNode!=dstNode)
689 {
692 }
693 else
694 return nullptr;
695 }
696}
@ 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:351
VFGEdge * hasIntraVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
Whether we has a SVFG edge.
Definition VFG.cpp:875

◆ addIntraPHIVFGNode()

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

Add an llvm PHI VFG node.

Definition at line 579 of file VFG.h.

580 {
581 IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,edge->getRes());
582 u32_t pos = 0;
583 for(auto var : edge->getOpndVars())
584 {
585 sNode->setOpVerAndBB(pos, var, edge->getICFGNode());
586 pos++;
587 }
588 addVFGNode(sNode,edge->getICFGNode());
589 setDef(edge->getRes(),sNode);
591 }
PAGNodeToPHIVFGNodeMapTy PAGNodeToIntraPHIVFGNodeMap
map a PAGNode to its PHIVFGNode
Definition VFG.h:94

◆ addLoadVFGNode()

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

Add a Load VFG node.

Definition at line 513 of file VFG.h.

514 {
515 LoadVFGNode* sNode = new LoadVFGNode(totalVFGNode++,load);
516 addStmtVFGNode(sNode, load);
517 setDef(load->getLHSVar(),sNode);
518 }

◆ addNullPtrVFGNode()

void SVF::VFG::addNullPtrVFGNode ( const PAGNode pagNode)
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 485 of file VFG.h.

486 {
487 NullPtrVFGNode* sNode = new NullPtrVFGNode(totalVFGNode++,pagNode);
490 }
GlobalICFGNode * getGlobalICFGNode() const
Definition ICFG.h:236

◆ addRetEdge()

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

Add interprocedural return edges for top level pointers

Definition at line 721 of file VFG.cpp.

722{
726 if (edge != nullptr)
727 {
728 assert(edge->isRetDirectVFGEdge() && "this should be a direct value flow edge!");
729 return nullptr;
730 }
731 else
732 {
734 return (addVFGEdge(retEdge) ? retEdge : nullptr);
735 }
736}

◆ addStmtVFGNode()

void SVF::VFG::addStmtVFGNode ( StmtVFGNode node,
const PAGEdge pagEdge 
)
inlineprotected

Add a VFG node for program statement.

Definition at line 477 of file VFG.h.

478 {
479 assert(PAGEdgeToStmtVFGNodeMap.find(pagEdge)==PAGEdgeToStmtVFGNodeMap.end() && "should not insert twice!");
480 PAGEdgeToStmtVFGNodeMap[pagEdge] = node;
481 addVFGNode(node, pagEdge->getICFGNode());
482 }
PAGEdgeToStmtVFGNodeMapTy PAGEdgeToStmtVFGNodeMap
map a PAGEdge 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 521 of file VFG.h.

522 {
523 StoreVFGNode* sNode = new StoreVFGNode(totalVFGNode++,store);
524 addStmtVFGNode(sNode, store);
525 }

◆ addUnaryOPVFGNode()

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

Add a UnaryOperator VFG node.

Definition at line 621 of file VFG.h.

622 {
623 UnaryOPVFGNode* sNode = new UnaryOPVFGNode(totalVFGNode++, edge->getRes());
624 sNode->setOpVer(0, edge->getOpVar());
625 addVFGNode(sNode,edge->getICFGNode());
626 setDef(edge->getRes(),sNode);
628 }
PAGNodeToUnaryOPVFGNodeMapTy PAGNodeToUnaryOPVFGNodeMap
map a PAGNode to its UnaryOPVFGNode
Definition VFG.h:96

◆ addVFGEdge()

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

Add VFG edge.

Definition at line 339 of file VFG.h.

340 {
341 bool added1 = edge->getDstNode()->addIncomingEdge(edge);
342 bool added2 = edge->getSrcNode()->addOutgoingEdge(edge);
343 bool both_added = added1 & added2;
344 assert(both_added && "VFGEdge not added??");
345 return both_added;
346 }

◆ addVFGInterEdges()

void SVF::VFG::addVFGInterEdges ( const CallICFGNode cs,
const SVFFunction 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 464 of file VFG.h.

465 {
466 addGNode(vfgNode->getId(), vfgNode);
467 vfgNode->setICFGNode(icfgNode);
468 icfgNode->addVFGNode(vfgNode);
469
470 if(const SVFFunction* fun = icfgNode->getFun())
471 funToVFGNodesMap[fun].insert(vfgNode);
472 else
473 globalVFGNodes.insert(vfgNode);
474 }
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 463 of file VFG.cpp.

464{
465
466 // initialize dummy definition null pointers in order to uniform the construction
467 // to be noted for black hole pointer it has already has address edge connected,
468 // and its definition will be set when processing addr SVFIR edge.
470
471 // initialize address nodes
473 for (SVFStmt::SVFStmtSetTy::iterator iter = addrs.begin(), eiter =
474 addrs.end(); iter != eiter; ++iter)
475 {
476 addAddrVFGNode(SVFUtil::cast<AddrStmt>(*iter));
477 }
478
479 // initialize copy nodes
481 for (SVFStmt::SVFStmtSetTy::iterator iter = copys.begin(), eiter =
482 copys.end(); iter != eiter; ++iter)
483 {
484 const CopyStmt* edge = SVFUtil::cast<CopyStmt>(*iter);
485 assert(!isPhiCopyEdge(edge) && "Copy edges can not be a PhiNode (or from PhiNode)");
487 }
488
489 // initialize gep nodes
491 for (SVFStmt::SVFStmtSetTy::iterator iter = ngeps.begin(), eiter =
492 ngeps.end(); iter != eiter; ++iter)
493 {
494 addGepVFGNode(SVFUtil::cast<GepStmt>(*iter));
495 }
496
497 // initialize load nodes
499 for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
500 loads.end(); iter != eiter; ++iter)
501 {
502 addLoadVFGNode(SVFUtil::cast<LoadStmt>(*iter));
503 }
504
505 // initialize store nodes
507 for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
508 stores.end(); iter != eiter; ++iter)
509 {
510 addStoreVFGNode(SVFUtil::cast<StoreStmt>(*iter));
511 }
512
514 for (SVFStmt::SVFStmtSetTy::iterator iter = forks.begin(), eiter =
515 forks.end(); iter != eiter; ++iter)
516 {
517 TDForkPE* forkedge = SVFUtil::cast<TDForkPE>(*iter);
518 addActualParmVFGNode(forkedge->getRHSVar(),forkedge->getCallSite());
519 }
520
521 // initialize actual parameter nodes
522 for(SVFIR::CSToArgsListMap::iterator it = pag->getCallSiteArgsMap().begin(), eit = pag->getCallSiteArgsMap().end(); it !=eit; ++it)
523 {
524
525 for(SVFIR::SVFVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
526 {
527 const PAGNode* pagNode = *pit;
530 }
531 }
532
533 // initialize actual return nodes (callsite return)
534 for(SVFIR::CSToRetMap::iterator it = pag->getCallSiteRets().begin(), eit = pag->getCallSiteRets().end(); it !=eit; ++it)
535 {
536
540 if(isInterestedPAGNode(it->second) == false || hasDef(it->second))
541 continue;
542
543 addActualRetVFGNode(it->second,it->first->getCallICFGNode());
544 }
545
546 // initialize formal parameter nodes
547 for(SVFIR::FunToArgsListMap::iterator it = pag->getFunArgsMap().begin(), eit = pag->getFunArgsMap().end(); it !=eit; ++it)
548 {
549 const SVFFunction* func = it->first;
550
551 for(SVFIR::SVFVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
552 {
553 const PAGNode* param = *pit;
554 if (isInterestedPAGNode(param) == false || hasBlackHoleConstObjAddrAsDef(param))
555 continue;
556
557 CallPESet callPEs;
559 {
560 for (SVFStmt::SVFStmtSetTy::const_iterator cit = param->getIncomingEdgesBegin(SVFStmt::Call), ecit =
562 {
563 CallPE* callPE = SVFUtil::cast<CallPE>(*cit);
564 if (isInterestedPAGNode(callPE->getRHSVar()))
565 callPEs.insert(callPE);
566 }
567 }
568 addFormalParmVFGNode(param,func,callPEs);
569 }
570
571 if (func->isVarArg())
572 {
573 const PAGNode* varParam = pag->getGNode(pag->getVarargNode(func));
575 continue;
576
577 CallPESet callPEs;
578 if (varParam->hasIncomingEdges(SVFStmt::Call))
579 {
580 for(SVFStmt::SVFStmtSetTy::const_iterator cit = varParam->getIncomingEdgesBegin(SVFStmt::Call),
581 ecit = varParam->getIncomingEdgesEnd(SVFStmt::Call); cit!=ecit; ++cit)
582 {
583 CallPE* callPE = SVFUtil::cast<CallPE>(*cit);
584 if(isInterestedPAGNode(callPE->getRHSVar()))
585 callPEs.insert(callPE);
586 }
587 }
588 addFormalParmVFGNode(varParam,func,callPEs);
589 }
590 }
591
592 // initialize formal return nodes (callee return)
593 for (SVFIR::FunToRetMap::iterator it = pag->getFunRets().begin(), eit = pag->getFunRets().end(); it != eit; ++it)
594 {
595 const SVFFunction* func = it->first;
596
597 const PAGNode* uniqueFunRetNode = it->second;
598
599 RetPESet retPEs;
600 if (uniqueFunRetNode->hasOutgoingEdges(SVFStmt::Ret))
601 {
602 for (SVFStmt::SVFStmtSetTy::const_iterator cit = uniqueFunRetNode->getOutgoingEdgesBegin(SVFStmt::Ret),
603 ecit = uniqueFunRetNode->getOutgoingEdgesEnd(SVFStmt::Ret);
604 cit != ecit; ++cit)
605 {
606 const RetPE* retPE = SVFUtil::cast<RetPE>(*cit);
607 if (isInterestedPAGNode(retPE->getLHSVar()))
608 retPEs.insert(retPE);
609 }
610 }
611
614 }
615
616 // initialize llvm phi nodes (phi of top level pointers)
618 for (SVFStmt::SVFStmtSetTy::iterator iter = phis.begin(), eiter =
619 phis.end(); iter != eiter; ++iter)
620 {
621 const PhiStmt* edge = SVFUtil::cast<PhiStmt>(*iter);
622 if(isInterestedPAGNode(edge->getRes()))
624 }
625 // initialize select statement
627 for (SVFStmt::SVFStmtSetTy::iterator iter = selects.begin(), eiter =
628 selects.end(); iter != eiter; ++iter)
629 {
630 const MultiOpndStmt* edge = SVFUtil::cast<MultiOpndStmt>(*iter);
631 if(isInterestedPAGNode(edge->getRes()))
633 }
634 // initialize llvm binary nodes (binary operators)
636 for (SVFStmt::SVFStmtSetTy::iterator iter = binaryops.begin(), eiter =
637 binaryops.end(); iter != eiter; ++iter)
638 {
639 const BinaryOPStmt* edge = SVFUtil::cast<BinaryOPStmt>(*iter);
640 if(isInterestedPAGNode(edge->getRes()))
642 }
643 // initialize llvm unary nodes (unary operators)
645 for (SVFStmt::SVFStmtSetTy::iterator iter = unaryops.begin(), eiter =
646 unaryops.end(); iter != eiter; ++iter)
647 {
648 const UnaryOPStmt* edge = SVFUtil::cast<UnaryOPStmt>(*iter);
649 if(isInterestedPAGNode(edge->getRes()))
651 }
652 // initialize llvm unary nodes (unary operators)
654 for (SVFStmt::SVFStmtSetTy::iterator iter = brs.begin(), eiter =
655 brs.end(); iter != eiter; ++iter)
656 {
657 const BranchStmt* edge = SVFUtil::cast<BranchStmt>(*iter);
658 if(isInterestedPAGNode(edge->getBranchInst()))
660 }
661 // initialize llvm cmp nodes (comparison)
663 for (SVFStmt::SVFStmtSetTy::iterator iter = cmps.begin(), eiter =
664 cmps.end(); iter != eiter; ++iter)
665 {
666 const CmpStmt* edge = SVFUtil::cast<CmpStmt>(*iter);
667 if(isInterestedPAGNode(edge->getRes()))
669 }
670}
SVFVar * getLHSVar() const
NodeType * getGNode(NodeID id) const
Get a node.
NodeID getNullPtr() const
Definition IRGraph.h:173
NodeID getVarargNode(const SVFFunction *func) const
getVarargNode - Return the unique node representing the variadic argument of a variadic function.
Definition IRGraph.h:157
bool isVarArg() const
Definition SVFValue.cpp:181
CSToArgsListMap & getCallSiteArgsMap()
Get callsite argument list.
Definition SVFIR.h:288
CSToRetMap & getCallSiteRets()
Get callsite return.
Definition SVFIR.h:300
FunToRetMap & getFunRets()
Get function return list.
Definition SVFIR.h:316
FunToArgsListMap & getFunArgsMap()
Get function arguments list.
Definition SVFIR.h:271
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
bool hasIncomingEdges(SVFStmt::PEDGEK kind) const
Has incoming SVFIR statements (edges)
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesBegin(SVFStmt::PEDGEK kind) const
Get incoming SVFStmt iterator.
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesEnd(SVFStmt::PEDGEK kind) const
Get incoming SVFStmt iterator.
void addStoreVFGNode(const StoreStmt *store)
Definition VFG.h:521
void addBranchVFGNode(const BranchStmt *edge)
Add a BranchVFGNode.
Definition VFG.h:630
virtual SVFStmt::SVFStmtSetTy & getPAGEdgeSet(SVFStmt::PEDGEK kind)
Get PAGEdge set.
Definition VFG.h:436
void addLoadVFGNode(const LoadStmt *load)
Add a Load VFG node.
Definition VFG.h:513
void addCopyVFGNode(const CopyStmt *copy)
Add a Copy VFG node.
Definition VFG.h:499
void addGepVFGNode(const GepStmt *gep)
Add a Gep VFG node.
Definition VFG.h:506
void addNullPtrVFGNode(const PAGNode *pagNode)
Definition VFG.h:485
void addActualRetVFGNode(const PAGNode *ret, const CallICFGNode *cs)
Add a callsite Receive VFG node.
Definition VFG.h:571
void addUnaryOPVFGNode(const UnaryOPStmt *edge)
Add a UnaryOperator VFG node.
Definition VFG.h:621
void addActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs)
Definition VFG.h:530
void addCmpVFGNode(const CmpStmt *edge)
Add a Compare VFG node.
Definition VFG.h:593
virtual bool isInterestedPAGNode(const SVFVar *node) const
Definition VFG.h:444
bool hasBlackHoleConstObjAddrAsDef(const PAGNode *pagNode) const
Whether a PAGNode has a blackhole or const object as its definition.
Definition VFG.h:265
bool isPhiCopyEdge(const PAGEdge *copy) const
Definition VFG.h:458
void addFormalRetVFGNode(const PAGNode *uniqueFunRet, const SVFFunction *fun, RetPESet &retPEs)
Definition VFG.h:552
bool hasDef(const PAGNode *pagNode) const
Definition VFG.h:426
FormalRetVFGNode::RetPESet RetPESet
Definition VFG.h:76
void addBinaryOPVFGNode(const BinaryOPStmt *edge)
Add a BinaryOperator VFG node.
Definition VFG.h:607
void addAddrVFGNode(const AddrStmt *addr)
Add an Address VFG node.
Definition VFG.h:492
FormalParmVFGNode::CallPESet CallPESet
Definition VFG.h:75
void addIntraPHIVFGNode(const MultiOpndStmt *edge)
Add an llvm PHI VFG node.
Definition VFG.h:579
void addFormalParmVFGNode(const PAGNode *fparm, const SVFFunction *fun, CallPESet &callPEs)
Add a formal parameter VFG node.
Definition VFG.h:538

◆ 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 351 of file VFG.h.

352 {
353 const SVFFunction *srcfun = srcNode->getFun();
354 const SVFFunction *dstfun = dstNode->getFun();
355 if(srcfun != nullptr && dstfun != nullptr)
356 {
357 assert((srcfun == dstfun) && "src and dst nodes of an intra VFG edge are not in the same function?");
358 }
359 }

◆ connectAParamAndFParam()

virtual void SVF::VFG::connectAParamAndFParam ( const PAGNode csArg,
const PAGNode 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 386 of file VFG.h.

387 {
391 if (edge != nullptr)
392 edges.insert(edge);
393 }
NodeID getId() const
Get ID.
VFGEdge * addInterEdgeFromAPToFP(ActualParmVFGNode *src, FormalParmVFGNode *dst, CallSiteID csId)
Add inter VF edge from actual to formal parameters.
Definition VFG.h:362
FormalParmVFGNode * getFormalParmVFGNode(const PAGNode *fparm) const
Definition VFG.h:247
ActualParmVFGNode * getActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs) const
Definition VFG.h:235
u32_t NodeID
Definition GeneralType.h:55

◆ connectCallerAndCallee()

void VFG::connectCallerAndCallee ( const CallICFGNode callBlockNode,
const SVFFunction 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 973 of file VFG.cpp.

974{
975 SVFIR * pag = SVFIR::getPAG();
976 CallSiteID csId = getCallSiteID(callBlockNode, callee);
977 const RetICFGNode* retBlockNode = callBlockNode->getRetICFGNode();
978 // connect actual and formal param
979 if (pag->hasCallSiteArgsMap(callBlockNode) && pag->hasFunArgsList(callee) &&
980 matchArgs(callBlockNode, callee))
981 {
982 const SVFIR::SVFVarList& csArgList = pag->getCallSiteArgsList(callBlockNode);
984 SVFIR::SVFVarList::const_iterator csArgIt = csArgList.begin(), csArgEit = csArgList.end();
985 SVFIR::SVFVarList::const_iterator funArgIt = funArgList.begin(), funArgEit = funArgList.end();
986 for (; funArgIt != funArgEit && csArgIt != csArgEit; funArgIt++, csArgIt++)
987 {
988 const PAGNode *cs_arg = *csArgIt;
989 const PAGNode *fun_arg = *funArgIt;
991 connectAParamAndFParam(cs_arg, fun_arg, callBlockNode, csId, edges);
992 }
993 assert(funArgIt == funArgEit && "function has more arguments than call site");
994
995 if (callee->isVarArg())
996 {
1000 {
1001 for (; csArgIt != csArgEit; csArgIt++)
1002 {
1003 const PAGNode *cs_arg = *csArgIt;
1005 connectAParamAndFParam(cs_arg, varFunArgNode, callBlockNode, csId, edges);
1006 }
1007 }
1008 }
1009 }
1010
1011 // connect actual return and formal return
1013 {
1018 }
1019}
const RetICFGNode * getRetICFGNode() const
Return callsite.
Definition ICFGNode.h:457
std::vector< const SVFVar * > SVFVarList
Definition SVFIR.h:60
const SVFVarList & getFunArgsList(const SVFFunction *func) const
Get function arguments list.
Definition SVFIR.h:276
const SVFVar * getFunRet(const SVFFunction *func) const
Get function return list.
Definition SVFIR.h:321
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
Definition SVFIR.h:283
bool callsiteHasRet(const RetICFGNode *cs) const
Definition SVFIR.h:311
bool hasFunArgsList(const SVFFunction *func) const
Function has arguments list.
Definition SVFIR.h:266
const SVFVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
Definition SVFIR.h:293
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
Definition SVFIR.h:305
bool funHasRet(const SVFFunction *func) const
Definition SVFIR.h:327
virtual void connectAParamAndFParam(const PAGNode *csArg, const PAGNode *funArg, const CallICFGNode *cbn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
Definition VFG.h:386
CallSiteID getCallSiteID(const CallICFGNode *cs, const SVFFunction *func) const
Get callsite given a callsiteID.
Definition VFG.h:178
virtual void connectFRetAndARet(const PAGNode *funReturn, const PAGNode *csReturn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect formal-ret and actual ret.
Definition VFG.h:395
bool matchArgs(const CallICFGNode *cs, const SVFFunction *callee)
Definition SVFUtil.cpp:321
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 742 of file VFG.cpp.

743{
744
745 for(iterator it = begin(), eit = end(); it!=eit; ++it)
746 {
747 NodeID nodeId = it->first;
748 VFGNode* node = it->second;
749
750 if(StmtVFGNode* stmtNode = SVFUtil::dyn_cast<StmtVFGNode>(node))
751 {
753 if(SVFUtil::isa<AddrVFGNode>(stmtNode))
754 continue;
756 if (stmtNode->getPAGSrcNode()->isConstDataOrAggDataButNotNullPtr() == false)
757 // for ptr vfg, we skip src node of integer type if it is at a int2ptr copystmt
758 if(isInterestedPAGNode(stmtNode->getPAGSrcNode()))
759 addIntraDirectVFEdge(getDef(stmtNode->getPAGSrcNode()), nodeId);
760 if (const GepStmt* gepStmt = SVFUtil::dyn_cast<GepStmt>(stmtNode->getPAGEdge()))
761 {
762 for (const auto &varType: gepStmt->getOffsetVarAndGepTypePairVec())
763 {
764 if(varType.first->isConstDataOrAggDataButNotNullPtr() || isInterestedPAGNode(varType.first) == false)
765 continue;
767 }
768 }
770 if(SVFUtil::isa<StoreVFGNode>(stmtNode) && (stmtNode->getPAGDstNode()->isConstDataOrAggDataButNotNullPtr() == false))
771 {
772 addIntraDirectVFEdge(getDef(stmtNode->getPAGDstNode()), nodeId);
773 }
774
775 }
776 else if(PHIVFGNode* phiNode = SVFUtil::dyn_cast<PHIVFGNode>(node))
777 {
778 for (PHIVFGNode::OPVers::const_iterator it = phiNode->opVerBegin(), eit = phiNode->opVerEnd(); it != eit; it++)
779 {
780 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
782 }
783 }
784 else if(BinaryOPVFGNode* binaryNode = SVFUtil::dyn_cast<BinaryOPVFGNode>(node))
785 {
786 for (BinaryOPVFGNode::OPVers::const_iterator it = binaryNode->opVerBegin(), eit = binaryNode->opVerEnd(); it != eit; it++)
787 {
788 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
790 }
791 }
792 else if(UnaryOPVFGNode* unaryNode = SVFUtil::dyn_cast<UnaryOPVFGNode>(node))
793 {
794 for (UnaryOPVFGNode::OPVers::const_iterator it = unaryNode->opVerBegin(), eit = unaryNode->opVerEnd(); it != eit; it++)
795 {
796 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
798 }
799 }
800 else if(CmpVFGNode* cmpNode = SVFUtil::dyn_cast<CmpVFGNode>(node))
801 {
802 for (CmpVFGNode::OPVers::const_iterator it = cmpNode->opVerBegin(), eit = cmpNode->opVerEnd(); it != eit; it++)
803 {
804 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
806 }
807 }
808 else if(BranchVFGNode* branchNode = SVFUtil::dyn_cast<BranchVFGNode>(node))
809 {
810 const SVFVar* cond = branchNode->getBranchStmt()->getCondition();
811 if (cond->isConstDataOrAggDataButNotNullPtr() == false)
813 }
814 else if(ActualParmVFGNode* actualParm = SVFUtil::dyn_cast<ActualParmVFGNode>(node))
815 {
816 if (actualParm->getParam()->isConstDataOrAggDataButNotNullPtr() == false)
818 }
819 else if(FormalParmVFGNode* formalParm = SVFUtil::dyn_cast<FormalParmVFGNode>(node))
820 {
821 for(CallPESet::const_iterator it = formalParm->callPEBegin(), eit = formalParm->callPEEnd();
822 it!=eit; ++it)
823 {
824 const CallICFGNode* cs = (*it)->getCallSite();
825 ActualParmVFGNode* acutalParm = getActualParmVFGNode((*it)->getRHSVar(),cs);
827 }
828 }
829 else if(FormalRetVFGNode* calleeRet = SVFUtil::dyn_cast<FormalRetVFGNode>(node))
830 {
833
835 for(RetPESet::const_iterator it = calleeRet->retPEBegin(), eit = calleeRet->retPEEnd(); it!=eit; ++it)
836 {
837 ActualRetVFGNode* callsiteRev = getActualRetVFGNode((*it)->getLHSVar());
838 const CallICFGNode* callBlockNode = (*it)->getCallSite();
840 }
841 }
844 }
845
848 {
851 for (SVFStmt::SVFStmtSetTy::iterator iter = forks.begin(), eiter =
852 forks.end(); iter != eiter; ++iter)
853 {
854 TDForkPE* forkedge = SVFUtil::cast<TDForkPE>(*iter);
855 ActualParmVFGNode* acutalParm = getActualParmVFGNode(forkedge->getRHSVar(),forkedge->getCallSite());
858 }
861 for (SVFStmt::SVFStmtSetTy::iterator iter = joins.begin(), eiter =
862 joins.end(); iter != eiter; ++iter)
863 {
864 TDJoinPE* joinedge = SVFUtil::cast<TDJoinPE>(*iter);
865 NodeID callsiteRev = getDef(joinedge->getLHSVar());
867 addRetEdge(calleeRet->getId(),callsiteRev, getCallSiteID(joinedge->getCallSite(), calleeRet->getFun()));
868 }
869 }
870}
iterator begin()
Iterators.
static const Option< bool > EnableThreadCallGraph
Definition Options.h:132
bool isConstDataOrAggDataButNotNullPtr() const
VFGEdge * addInterEdgeFromFRToAR(FormalRetVFGNode *src, ActualRetVFGNode *dst, CallSiteID csId)
Add inter VF edge from callee return to callsite receive parameter.
Definition VFG.h:367
VFGNodeIDToNodeMapTy::iterator iterator
Definition VFG.h:80
ActualRetVFGNode * getActualRetVFGNode(const PAGNode *aret) const
Definition VFG.h:241
FormalRetVFGNode * getFormalRetVFGNode(const PAGNode *fret) const
Definition VFG.h:253
VFGEdge * addIntraDirectVFEdge(NodeID srcId, NodeID dstId)
Definition VFG.cpp:675
NodeID getDef(const PAGNode *pagNode) const
Definition VFG.h:420

◆ connectFRetAndARet()

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

Connect formal-ret and actual ret.

Reimplemented in SVF::SVFGOPT.

Definition at line 395 of file VFG.h.

396 {
399 VFGEdge* edge = addInterEdgeFromFRToAR(formalRet, actualRet,csId);
400 if (edge != nullptr)
401 edges.insert(edge);
402 }

◆ destroy()

void VFG::destroy ( )
protected

Clean up memory.

Memory has been cleaned up at GenericGraph

Definition at line 454 of file VFG.cpp.

455{
456 pag = nullptr;
457}

◆ dump()

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

Dump graph into dot file.

Dump VFG

Definition at line 937 of file VFG.cpp.

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

◆ getActualParmVFGNode()

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

Definition at line 235 of file VFG.h.

236 {
237 PAGNodeToActualParmMapTy::const_iterator it = PAGNodeToActualParmMap.find(std::make_pair(aparm->getId(),cs));
238 assert(it!=PAGNodeToActualParmMap.end() && "actual parameter VFG node can not be found??");
239 return it->second;
240 }

◆ getActualRetVFGNode()

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

Definition at line 241 of file VFG.h.

242 {
243 PAGNodeToActualRetMapTy::const_iterator it = PAGNodeToActualRetMap.find(aret);
244 assert(it!=PAGNodeToActualRetMap.end() && "actual return VFG node can not be found??");
245 return it->second;
246 }

◆ getBinaryOPVFGNode()

BinaryOPVFGNode * SVF::VFG::getBinaryOPVFGNode ( const PAGNode pagNode) const
inline

Definition at line 211 of file VFG.h.

212 {
213 PAGNodeToBinaryOPVFGNodeMapTy::const_iterator it = PAGNodeToBinaryOPVFGNodeMap.find(pagNode);
214 assert(it != PAGNodeToBinaryOPVFGNodeMap.end() && "BinaryOPVFGNode can not be found??");
215 return it->second;
216 }

◆ getBranchVFGNode()

BranchVFGNode * SVF::VFG::getBranchVFGNode ( const PAGNode pagNode) const
inline

Definition at line 223 of file VFG.h.

224 {
225 PAGNodeToBranchVFGNodeMapTy::const_iterator it = PAGNodeToBranchVFGNodeMap.find(pagNode);
226 assert(it != PAGNodeToBranchVFGNodeMap.end() && "BranchVFGNode can not be found??");
227 return it->second;
228 }

◆ getCallGraph()

PTACallGraph * 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

◆ getCallSiteID()

CallSiteID SVF::VFG::getCallSiteID ( const CallICFGNode cs,
const SVFFunction 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 SVFFunction *callee) const
Get CallSiteID.

◆ getCmpVFGNode()

CmpVFGNode * SVF::VFG::getCmpVFGNode ( const PAGNode pagNode) const
inline

Definition at line 229 of file VFG.h.

230 {
231 PAGNodeToCmpVFGNodeMapTy::const_iterator it = PAGNodeToCmpVFGNodeMap.find(pagNode);
232 assert(it != PAGNodeToCmpVFGNodeMap.end() && "CmpVFGNode can not be found??");
233 return it->second;
234 }

◆ getDef()

NodeID SVF::VFG::getDef ( const PAGNode pagNode) const
inlineprotected

Definition at line 420 of file VFG.h.

421 {
422 PAGNodeToDefMapTy::const_iterator it = PAGNodeToDefMap.find(pagNode);
423 assert(it!=PAGNodeToDefMap.end() && "SVFVar does not have a definition??");
424 return it->second;
425 }
PAGNodeToDefMapTy PAGNodeToDefMap
map a pag node to its definition SVG node
Definition VFG.h:89

◆ getDefVFGNode()

const VFGNode * SVF::VFG::getDefVFGNode ( const PAGNode pagNode) const
inline

Given a pagNode, return its definition site.

Definition at line 189 of file VFG.h.

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

◆ getFormalParmVFGNode()

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

Definition at line 247 of file VFG.h.

248 {
249 PAGNodeToFormalParmMapTy::const_iterator it = PAGNodeToFormalParmMap.find(fparm);
250 assert(it!=PAGNodeToFormalParmMap.end() && "formal parameter VFG node can not be found??");
251 return it->second;
252 }

◆ getFormalRetVFGNode()

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

Definition at line 253 of file VFG.h.

254 {
255 PAGNodeToFormalRetMapTy::const_iterator it = PAGNodeToFormalRetMap.find(fret);
256 assert(it!=PAGNodeToFormalRetMap.end() && "formal return VFG node can not be found??");
257 return it->second;
258 }

◆ 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 PAGNode pagNode) const
inline

Definition at line 205 of file VFG.h.

206 {
207 PAGNodeToPHIVFGNodeMapTy::const_iterator it = PAGNodeToIntraPHIVFGNodeMap.find(pagNode);
208 assert(it != PAGNodeToIntraPHIVFGNodeMap.end() && "PHIVFGNode can not be found??");
209 return it->second;
210 }

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

929{
930 return hasIntraVFGEdge(const_cast<VFGNode*>(src),const_cast<VFGNode*>(dst),kind);
931}

◆ 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 PAGNode * VFG::getLHSTopLevPtr ( const VFGNode node) const

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

Definition at line 1024 of file VFG.cpp.

1025{
1026
1027 if(const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(node))
1028 return addr->getPAGDstNode();
1029 else if(const CopyVFGNode* copy = SVFUtil::dyn_cast<CopyVFGNode>(node))
1030 return copy->getPAGDstNode();
1031 else if(const GepVFGNode* gep = SVFUtil::dyn_cast<GepVFGNode>(node))
1032 return gep->getPAGDstNode();
1033 else if(const LoadVFGNode* load = SVFUtil::dyn_cast<LoadVFGNode>(node))
1034 return load->getPAGDstNode();
1035 else if(const PHIVFGNode* phi = SVFUtil::dyn_cast<PHIVFGNode>(node))
1036 return phi->getRes();
1037 else if(const CmpVFGNode* cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
1038 return cmp->getRes();
1039 else if(const BinaryOPVFGNode* bop = SVFUtil::dyn_cast<BinaryOPVFGNode>(node))
1040 return bop->getRes();
1041 else if(const UnaryOPVFGNode* uop = SVFUtil::dyn_cast<UnaryOPVFGNode>(node))
1042 return uop->getRes();
1043 else if(const ActualParmVFGNode* ap = SVFUtil::dyn_cast<ActualParmVFGNode>(node))
1044 return ap->getParam();
1045 else if(const FormalParmVFGNode*fp = SVFUtil::dyn_cast<FormalParmVFGNode>(node))
1046 return fp->getParam();
1047 else if(const ActualRetVFGNode* ar = SVFUtil::dyn_cast<ActualRetVFGNode>(node))
1048 return ar->getRev();
1049 else if(const FormalRetVFGNode* fr = SVFUtil::dyn_cast<FormalRetVFGNode>(node))
1050 return fr->getRet();
1051 else if(const NullPtrVFGNode* nullVFG = SVFUtil::dyn_cast<NullPtrVFGNode>(node))
1052 return nullVFG->getPAGNode();
1053 else
1054 assert(false && "unexpected node kind!");
1055 return nullptr;
1056}

◆ getPAG()

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

Return SVFIR.

Definition at line 133 of file VFG.h.

134 {
135 return pag;
136 }

◆ getPAGEdgeSet()

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

Get PAGEdge set.

Definition at line 436 of file VFG.h.

437 {
438 if (isPtrOnlySVFG())
439 return pag->getPTASVFStmtSet(kind);
440 else
441 return pag->getSVFStmtSet(kind);
442 }
SVFStmt::SVFStmtSetTy & getPTASVFStmtSet(SVFStmt::PEDGEK kind)
Get PTA edges set according to its kind.
Definition SVFIR.h:207
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition SVFIR.h:202
bool isPtrOnlySVFG() const
Return true if this VFG only contains pointer related SVFGNodes for pointer analysis.
Definition VFG.h:127

◆ getStmtVFGNode()

StmtVFGNode * SVF::VFG::getStmtVFGNode ( const PAGEdge pagEdge) const
inline

Get an VFGNode.

Definition at line 199 of file VFG.h.

200 {
201 PAGEdgeToStmtVFGNodeMapTy::const_iterator it = PAGEdgeToStmtVFGNodeMap.find(pagEdge);
202 assert(it != PAGEdgeToStmtVFGNodeMap.end() && "StmtVFGNode can not be found??");
203 return it->second;
204 }

◆ getUnaryOPVFGNode()

UnaryOPVFGNode * SVF::VFG::getUnaryOPVFGNode ( const PAGNode pagNode) const
inline

Definition at line 217 of file VFG.h.

218 {
219 PAGNodeToUnaryOPVFGNodeMapTy::const_iterator it = PAGNodeToUnaryOPVFGNodeMap.find(pagNode);
220 assert(it != PAGNodeToUnaryOPVFGNodeMap.end() && "UnaryOPVFGNode can not be found??");
221 return it->second;
222 }

◆ 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 }

◆ getVFGNodeBegin()

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

Definition at line 298 of file VFG.h.

299 {
300 FunToVFGNodesMapTy::const_iterator it = funToVFGNodesMap.find(fun);
301 assert(it != funToVFGNodesMap.end() && "this function does not have any VFGNode");
302 return it->second.begin();
303 }

◆ getVFGNodeEnd()

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

Definition at line 304 of file VFG.h.

305 {
306 FunToVFGNodesMapTy::const_iterator it = funToVFGNodesMap.find(fun);
307 assert(it != funToVFGNodesMap.end() && "this function does not have any VFGNode");
308 return it->second.end();
309 }

◆ getVFGNodes()

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

Return all the VFGNodes of a function

Definition at line 286 of file VFG.h.

287 {
288 return funToVFGNodesMap[fun];
289 }

◆ hasBlackHoleConstObjAddrAsDef()

bool SVF::VFG::hasBlackHoleConstObjAddrAsDef ( const PAGNode pagNode) const
inline

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

Definition at line 265 of file VFG.h.

266 {
267 if (hasDef(pagNode))
268 {
269 const VFGNode* defNode = getVFGNode(getDef(pagNode));
270 if (const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(defNode))
271 {
272 if (SVFIR::getPAG()->isBlkObjOrConstantObj(addr->getPAGEdge()->getSrcID()))
273 return true;
274 }
275 else if(const CopyVFGNode* copy = SVFUtil::dyn_cast<CopyVFGNode>(defNode))
276 {
277 if (SVFIR::getPAG()->isNullPtr(copy->getPAGEdge()->getSrcID()))
278 return true;
279 }
280 }
281 return false;
282 }

◆ hasDef()

bool SVF::VFG::hasDef ( const PAGNode pagNode) const
inlineprotected

Definition at line 426 of file VFG.h.

427 {
428 return (PAGNodeToDefMap.find(pagNode) != PAGNodeToDefMap.end());
429 }

◆ hasInterVFGEdge()

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

Whether we has an inter VFG edge

Definition at line 910 of file VFG.cpp.

911{
915 if (outEdge && inEdge)
916 {
917 assert(outEdge == inEdge && "edges not match");
918 return outEdge;
919 }
920 else
921 return nullptr;
922}
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

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

876{
877 VFGEdge edge(src,dst,kind);
880 if (outEdge && inEdge)
881 {
882 assert(outEdge == inEdge && "edges not match");
883 return outEdge;
884 }
885 else
886 return nullptr;
887}

◆ hasThreadVFGEdge()

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

Whether we has an thread VFG edge

Definition at line 893 of file VFG.cpp.

894{
895 VFGEdge edge(src,dst,kind);
898 if (outEdge && inEdge)
899 {
900 assert(outEdge == inEdge && "edges not match");
901 return outEdge;
902 }
903 else
904 return nullptr;
905}

◆ 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 SVFFunction fun) const
inline

Definition at line 290 of file VFG.h.

291 {
292 return funToVFGNodesMap.find(fun) != funToVFGNodesMap.end();
293 }

◆ isFunEntryVFGNode()

const SVFFunction * 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 1061 of file VFG.cpp.

1062{
1063 if(const FormalParmVFGNode* fp = SVFUtil::dyn_cast<FormalParmVFGNode>(node))
1064 {
1065 return fp->getFun();
1066 }
1067 else if(const InterPHIVFGNode* phi = SVFUtil::dyn_cast<InterPHIVFGNode>(node))
1068 {
1069 if(phi->isFormalParmPHI())
1070 return phi->getFun();
1071 }
1072 return nullptr;
1073}

◆ isInterestedPAGNode()

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

Definition at line 444 of file VFG.h.

445 {
446 if (isPtrOnlySVFG())
447 return node->isPointer();
448 else
449 return true;
450 }

◆ isPhiCopyEdge()

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

Definition at line 458 of file VFG.h.

459 {
460 return pag->isPhiNode(copy->getDstNode());
461 }

◆ 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 319 of file VFG.h.

320 {
321 edge->getDstNode()->removeIncomingEdge(edge);
322 edge->getSrcNode()->removeOutgoingEdge(edge);
323 delete edge;
324 }

◆ removeVFGNode()

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

Remove a VFGNode.

Definition at line 326 of file VFG.h.

327 {
328 removeGNode(node);
329 }
void removeGNode(NodeType *node)
Delete a node.

◆ setDef()

void SVF::VFG::setDef ( const PAGNode pagNode,
const VFGNode node 
)
inlineprotected

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

Definition at line 407 of file VFG.h.

408 {
409 PAGNodeToDefMapTy::iterator it = PAGNodeToDefMap.find(pagNode);
410 if(it == PAGNodeToDefMap.end())
411 {
412 PAGNodeToDefMap[pagNode] = node->getId();
413 assert(hasVFGNode(node->getId()) && "not in the map!!");
414 }
415 else
416 {
417 assert((it->second == node->getId()) && "a SVFVar can only have unique definition ");
418 }
419 }
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 951 of file VFG.cpp.

952{
953 VFGEdgeSetTy vfEdgesAtIndCallSite;
954 PointerAnalysis::CallEdgeMap::const_iterator iter = pta->getIndCallMap().begin();
955 PointerAnalysis::CallEdgeMap::const_iterator eiter = pta->getIndCallMap().end();
956 for (; iter != eiter; iter++)
957 {
958 const CallICFGNode* newcs = iter->first;
959 assert(newcs->isIndirectCall() && "this is not an indirect call?");
961 for (PointerAnalysis::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
962 {
963 const SVFFunction* func = *func_iter;
964 connectCallerAndCallee(newcs, func, vfEdgesAtIndCallSite);
965 }
966 }
967}
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
Set< const SVFFunction * > FunctionSet
VFGEdge::VFGEdgeSetTy VFGEdgeSetTy
Definition VFG.h:77
virtual void connectCallerAndCallee(const CallICFGNode *cs, const SVFFunction *callee, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
Definition VFG.cpp:973

◆ VFGNodes()

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

Definition at line 294 of file VFG.h.

295 {
296 return funToVFGNodesMap.find(fun) != funToVFGNodesMap.end();
297 }

◆ view()

void VFG::view ( )

Dump graph into dot file.

View VFG from the debugger.

Definition at line 945 of file VFG.cpp.

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

Member Data Documentation

◆ callgraph

PTACallGraph* 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.

◆ PAGEdgeToStmtVFGNodeMap

PAGEdgeToStmtVFGNodeMapTy SVF::VFG::PAGEdgeToStmtVFGNodeMap
protected

map a PAGEdge to its StmtVFGNode

Definition at line 99 of file VFG.h.

◆ PAGNodeToActualParmMap

PAGNodeToActualParmMapTy SVF::VFG::PAGNodeToActualParmMap
protected

map a PAGNode to an actual parameter

Definition at line 90 of file VFG.h.

◆ PAGNodeToActualRetMap

PAGNodeToActualRetMapTy SVF::VFG::PAGNodeToActualRetMap
protected

map a PAGNode to an actual return

Definition at line 91 of file VFG.h.

◆ PAGNodeToBinaryOPVFGNodeMap

PAGNodeToBinaryOPVFGNodeMapTy SVF::VFG::PAGNodeToBinaryOPVFGNodeMap
protected

map a PAGNode to its BinaryOPVFGNode

Definition at line 95 of file VFG.h.

◆ PAGNodeToBranchVFGNodeMap

PAGNodeToBranchVFGNodeMapTy SVF::VFG::PAGNodeToBranchVFGNodeMap
protected

map a PAGNode to its BranchVFGNode

Definition at line 97 of file VFG.h.

◆ PAGNodeToCmpVFGNodeMap

PAGNodeToCmpVFGNodeMapTy SVF::VFG::PAGNodeToCmpVFGNodeMap
protected

map a PAGNode to its CmpVFGNode

Definition at line 98 of file VFG.h.

◆ PAGNodeToDefMap

PAGNodeToDefMapTy SVF::VFG::PAGNodeToDefMap
protected

map a pag node to its definition SVG node

Definition at line 89 of file VFG.h.

◆ PAGNodeToFormalParmMap

PAGNodeToFormalParmMapTy SVF::VFG::PAGNodeToFormalParmMap
protected

map a PAGNode to a formal parameter

Definition at line 92 of file VFG.h.

◆ PAGNodeToFormalRetMap

PAGNodeToFormalRetMapTy SVF::VFG::PAGNodeToFormalRetMap
protected

map a PAGNode to a formal return

Definition at line 93 of file VFG.h.

◆ PAGNodeToIntraPHIVFGNodeMap

PAGNodeToPHIVFGNodeMapTy SVF::VFG::PAGNodeToIntraPHIVFGNodeMap
protected

map a PAGNode to its PHIVFGNode

Definition at line 94 of file VFG.h.

◆ PAGNodeToUnaryOPVFGNodeMap

PAGNodeToUnaryOPVFGNodeMapTy SVF::VFG::PAGNodeToUnaryOPVFGNodeMap
protected

map a PAGNode 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.


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