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 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 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 (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 PAGNode *pagNode) const
 Given a pagNode, return its definition site.
 
bool hasLHSTopLevPtr (const VFGNode *node) const
 
const PAGNodegetLHSTopLevPtr (const VFGNode *node) const
 
bool hasStmtVFGNode (const PAGEdge *pagEdge) const
 Existence checks for VFGNodes.
 
bool hasIntraPHIVFGNode (const PAGNode *pagNode) const
 
bool hasBinaryOPVFGNode (const PAGNode *pagNode) const
 
bool hasUnaryOPVFGNode (const PAGNode *pagNode) const
 
bool hasBranchVFGNode (const PAGNode *pagNode) const
 
bool hasCmpVFGNode (const PAGNode *pagNode) const
 
bool hasActualParmVFGNode (const PAGNode *aparm, const CallICFGNode *cs) const
 
bool hasActualRetVFGNode (const PAGNode *aret) const
 
bool hasFormalParmVFGNode (const PAGNode *fparm) const
 
bool hasFormalRetVFGNode (const PAGNode *fret) 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 FunObjVarisFunEntryVFGNode (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 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 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 FunObjVar *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 FunObjVar *fun, CallPESet &callPEs)
 Add a formal parameter VFG node.
 
void addFormalRetVFGNode (const PAGNode *uniqueFunRet, const FunObjVar *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
 
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.

◆ 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 ( CallGraph 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 425 of file VFG.cpp.

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

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

593 {
594 ActualParmVFGNode* sNode = new ActualParmVFGNode(totalVFGNode++,aparm,cs);
595 addVFGNode(sNode, const_cast<CallICFGNode*>(cs));
596 PAGNodeToActualParmMap[std::make_pair(aparm->getId(),cs)] = sNode;
598 }
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:526

◆ addActualRetVFGNode()

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

Add a callsite Receive VFG node.

Definition at line 633 of file VFG.h.

634 {
635 ActualRetVFGNode* sNode = new ActualRetVFGNode(totalVFGNode++,ret,cs);
636 addVFGNode(sNode, const_cast<RetICFGNode*>(cs->getRetICFGNode()));
637 setDef(ret,sNode);
639 }
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:469
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 554 of file VFG.h.

555 {
556 AddrVFGNode* sNode = new AddrVFGNode(totalVFGNode++,addr);
558 setDef(addr->getLHSVar(),sNode);
559 }
void addStmtVFGNode(StmtVFGNode *node, const PAGEdge *pagEdge)
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 669 of file VFG.h.

670 {
671 BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, edge->getRes());
672 u32_t pos = 0;
673 for(auto var : edge->getOpndVars())
674 {
675 sNode->setOpVer(pos, var);
676 pos++;
677 }
678 addVFGNode(sNode,edge->getICFGNode());
679 setDef(edge->getRes(),sNode);
681 }
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 692 of file VFG.h.

693 {
694 BranchVFGNode* sNode = new BranchVFGNode(totalVFGNode++, edge);
695 addVFGNode(sNode,edge->getICFGNode());
696 setDef(edge->getBranchInst(),sNode);
697 PAGNodeToBranchVFGNodeMap[edge->getBranchInst()] = sNode;
698 }
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 685 of file VFG.cpp.

686{
690 if (edge != nullptr)
691 {
692 assert(edge->isCallDirectVFGEdge() && "this should be a direct value flow edge!");
693 return nullptr;
694 }
695 else
696 {
698 return (addVFGEdge(callEdge) ? callEdge : nullptr);
699 }
700}
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:894

◆ addCmpVFGNode()

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

Add a Compare VFG node.

Definition at line 655 of file VFG.h.

656 {
657 CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, edge->getRes());
658 u32_t pos = 0;
659 for(auto var : edge->getOpndVars())
660 {
661 sNode->setOpVer(pos, var);
662 pos++;
663 }
664 addVFGNode(sNode,edge->getICFGNode());
665 setDef(edge->getRes(),sNode);
666 PAGNodeToCmpVFGNodeMap[edge->getRes()] = sNode;
667 }
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 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 PAGNode fparm,
const FunObjVar fun,
CallPESet callPEs 
)
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 for(CallPESet::const_iterator it = callPEs.begin(), eit=callPEs.end();
605 it!=eit; ++it)
606 sNode->addCallPE(*it);
607
610 }
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
Definition ICFG.cpp:242
ICFG * getICFG() const
Definition SVFIR.h:163
PAGNodeToFormalParmMapTy PAGNodeToFormalParmMap
map a PAGNode to a formal parameter
Definition VFG.h:92

◆ addFormalRetVFGNode()

void SVF::VFG::addFormalRetVFGNode ( const PAGNode 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 <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 614 of file VFG.h.

615 {
616 FormalRetVFGNode *sNode = new FormalRetVFGNode(totalVFGNode++, uniqueFunRet, fun);
618 for (RetPESet::const_iterator it = retPEs.begin(), eit = retPEs.end(); it != eit; ++it)
619 sNode->addRetPE(*it);
620
626 {
627 std::string warn = fun->getName();
628 SVFUtil::writeWrnMsg(warn + " does not have any ret instruction!");
630 }
631 }
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:287
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:68

◆ addGepVFGNode()

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

Add a Gep VFG node.

Definition at line 568 of file VFG.h.

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

◆ addInterEdgeFromAPToFP() [1/2]

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

Add inter VF edge from actual to formal parameters.

Definition at line 424 of file VFG.h.

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

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

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

660{
665 if (edge != nullptr)
666 {
667 assert(edge->isDirectVFGEdge() && "this should be a direct value flow edge!");
668 return nullptr;
669 }
670 else
671 {
672 if(srcNode!=dstNode)
673 {
676 }
677 else
678 return nullptr;
679 }
680}
@ 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:859

◆ addIntraPHIVFGNode()

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

Add an llvm PHI VFG node.

Definition at line 641 of file VFG.h.

642 {
643 IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,edge->getRes());
644 u32_t pos = 0;
645 for(auto var : edge->getOpndVars())
646 {
647 sNode->setOpVerAndBB(pos, var, edge->getICFGNode());
648 pos++;
649 }
650 addVFGNode(sNode,edge->getICFGNode());
651 setDef(edge->getRes(),sNode);
653 }
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 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 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 547 of file VFG.h.

548 {
549 NullPtrVFGNode* sNode = new NullPtrVFGNode(totalVFGNode++,pagNode);
552 }
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 705 of file VFG.cpp.

706{
710 if (edge != nullptr)
711 {
712 assert(edge->isRetDirectVFGEdge() && "this should be a direct value flow edge!");
713 return nullptr;
714 }
715 else
716 {
718 return (addVFGEdge(retEdge) ? retEdge : nullptr);
719 }
720}

◆ addStmtVFGNode()

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

Add a VFG node for program statement.

Definition at line 539 of file VFG.h.

540 {
541 assert(PAGEdgeToStmtVFGNodeMap.find(pagEdge)==PAGEdgeToStmtVFGNodeMap.end() && "should not insert twice!");
542 PAGEdgeToStmtVFGNodeMap[pagEdge] = node;
543 addVFGNode(node, pagEdge->getICFGNode());
544 }
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 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 683 of file VFG.h.

684 {
685 UnaryOPVFGNode* sNode = new UnaryOPVFGNode(totalVFGNode++, edge->getRes());
686 sNode->setOpVer(0, edge->getOpVar());
687 addVFGNode(sNode,edge->getICFGNode());
688 setDef(edge->getRes(),sNode);
690 }
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 401 of file VFG.h.

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

◆ addVFGInterEdges()

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

Create edges between VFG nodes across functions.

◆ addVFGNode()

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

Add a VFG node.

Definition at line 526 of file VFG.h.

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

◆ addVFGNodes()

void VFG::addVFGNodes ( )
protected

Create VFG nodes.

Create VFG nodes for top level pointers

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

Definition at line 447 of file VFG.cpp.

448{
449
450 // initialize dummy definition null pointers in order to uniform the construction
451 // to be noted for black hole pointer it has already has address edge connected,
452 // and its definition will be set when processing addr SVFIR edge.
454
455 // initialize address nodes
457 for (SVFStmt::SVFStmtSetTy::iterator iter = addrs.begin(), eiter =
458 addrs.end(); iter != eiter; ++iter)
459 {
460 addAddrVFGNode(SVFUtil::cast<AddrStmt>(*iter));
461 }
462
463 // initialize copy nodes
465 for (SVFStmt::SVFStmtSetTy::iterator iter = copys.begin(), eiter =
466 copys.end(); iter != eiter; ++iter)
467 {
468 const CopyStmt* edge = SVFUtil::cast<CopyStmt>(*iter);
469 assert(!isPhiCopyEdge(edge) && "Copy edges can not be a PhiNode (or from PhiNode)");
471 }
472
473 // initialize gep nodes
475 for (SVFStmt::SVFStmtSetTy::iterator iter = ngeps.begin(), eiter =
476 ngeps.end(); iter != eiter; ++iter)
477 {
478 addGepVFGNode(SVFUtil::cast<GepStmt>(*iter));
479 }
480
481 // initialize load nodes
483 for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
484 loads.end(); iter != eiter; ++iter)
485 {
486 addLoadVFGNode(SVFUtil::cast<LoadStmt>(*iter));
487 }
488
489 // initialize store nodes
491 for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
492 stores.end(); iter != eiter; ++iter)
493 {
494 addStoreVFGNode(SVFUtil::cast<StoreStmt>(*iter));
495 }
496
498 for (SVFStmt::SVFStmtSetTy::iterator iter = forks.begin(), eiter =
499 forks.end(); iter != eiter; ++iter)
500 {
501 TDForkPE* forkedge = SVFUtil::cast<TDForkPE>(*iter);
502 addActualParmVFGNode(forkedge->getRHSVar(),forkedge->getCallSite());
503 }
504
505 // initialize actual parameter nodes
506 for(SVFIR::CSToArgsListMap::iterator it = pag->getCallSiteArgsMap().begin(), eit = pag->getCallSiteArgsMap().end(); it !=eit; ++it)
507 {
508
509 for(SVFIR::SVFVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
510 {
511 const PAGNode* pagNode = *pit;
514 }
515 }
516
517 // initialize actual return nodes (callsite return)
518 for(SVFIR::CSToRetMap::iterator it = pag->getCallSiteRets().begin(), eit = pag->getCallSiteRets().end(); it !=eit; ++it)
519 {
520
524 if(isInterestedPAGNode(it->second) == false || hasDef(it->second))
525 continue;
526
527 addActualRetVFGNode(it->second,it->first->getCallICFGNode());
528 }
529
530 // initialize formal parameter nodes
531 for(SVFIR::FunToArgsListMap::iterator it = pag->getFunArgsMap().begin(), eit = pag->getFunArgsMap().end(); it !=eit; ++it)
532 {
533 const FunObjVar* func = it->first;
534
535 for(SVFIR::SVFVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
536 {
537 const PAGNode* param = *pit;
538 if (isInterestedPAGNode(param) == false || hasBlackHoleConstObjAddrAsDef(param))
539 continue;
540
541 CallPESet callPEs;
543 {
544 for (SVFStmt::SVFStmtSetTy::const_iterator cit = param->getIncomingEdgesBegin(SVFStmt::Call), ecit =
546 {
547 CallPE* callPE = SVFUtil::cast<CallPE>(*cit);
548 if (isInterestedPAGNode(callPE->getRHSVar()))
549 callPEs.insert(callPE);
550 }
551 }
552 addFormalParmVFGNode(param,func,callPEs);
553 }
554
555 if (func->isVarArg())
556 {
559 continue;
560
561 CallPESet callPEs;
562 if (varParam->hasIncomingEdges(SVFStmt::Call))
563 {
564 for(SVFStmt::SVFStmtSetTy::const_iterator cit = varParam->getIncomingEdgesBegin(SVFStmt::Call),
565 ecit = varParam->getIncomingEdgesEnd(SVFStmt::Call); cit!=ecit; ++cit)
566 {
567 CallPE* callPE = SVFUtil::cast<CallPE>(*cit);
568 if(isInterestedPAGNode(callPE->getRHSVar()))
569 callPEs.insert(callPE);
570 }
571 }
573 }
574 }
575
576 // initialize formal return nodes (callee return)
577 for (SVFIR::FunToRetMap::iterator it = pag->getFunRets().begin(), eit = pag->getFunRets().end(); it != eit; ++it)
578 {
579 const FunObjVar* func = it->first;
580
581 const PAGNode* uniqueFunRetNode = it->second;
582
583 RetPESet retPEs;
584 if (uniqueFunRetNode->hasOutgoingEdges(SVFStmt::Ret))
585 {
586 for (SVFStmt::SVFStmtSetTy::const_iterator cit = uniqueFunRetNode->getOutgoingEdgesBegin(SVFStmt::Ret),
587 ecit = uniqueFunRetNode->getOutgoingEdgesEnd(SVFStmt::Ret);
588 cit != ecit; ++cit)
589 {
590 const RetPE* retPE = SVFUtil::cast<RetPE>(*cit);
591 if (isInterestedPAGNode(retPE->getLHSVar()))
592 retPEs.insert(retPE);
593 }
594 }
595
598 }
599
600 // initialize llvm phi nodes (phi of top level pointers)
602 for (SVFStmt::SVFStmtSetTy::iterator iter = phis.begin(), eiter =
603 phis.end(); iter != eiter; ++iter)
604 {
605 const PhiStmt* edge = SVFUtil::cast<PhiStmt>(*iter);
606 if(isInterestedPAGNode(edge->getRes()))
608 }
609 // initialize select statement
611 for (SVFStmt::SVFStmtSetTy::iterator iter = selects.begin(), eiter =
612 selects.end(); iter != eiter; ++iter)
613 {
614 const MultiOpndStmt* edge = SVFUtil::cast<MultiOpndStmt>(*iter);
615 if(isInterestedPAGNode(edge->getRes()))
617 }
618 // initialize llvm binary nodes (binary operators)
620 for (SVFStmt::SVFStmtSetTy::iterator iter = binaryops.begin(), eiter =
621 binaryops.end(); iter != eiter; ++iter)
622 {
623 const BinaryOPStmt* edge = SVFUtil::cast<BinaryOPStmt>(*iter);
624 if(isInterestedPAGNode(edge->getRes()))
626 }
627 // initialize llvm unary nodes (unary operators)
629 for (SVFStmt::SVFStmtSetTy::iterator iter = unaryops.begin(), eiter =
630 unaryops.end(); iter != eiter; ++iter)
631 {
632 const UnaryOPStmt* edge = SVFUtil::cast<UnaryOPStmt>(*iter);
633 if(isInterestedPAGNode(edge->getRes()))
635 }
636 // initialize llvm unary nodes (unary operators)
638 for (SVFStmt::SVFStmtSetTy::iterator iter = brs.begin(), eiter =
639 brs.end(); iter != eiter; ++iter)
640 {
641 const BranchStmt* edge = SVFUtil::cast<BranchStmt>(*iter);
642 if(isInterestedPAGNode(edge->getBranchInst()))
644 }
645 // initialize llvm cmp nodes (comparison)
647 for (SVFStmt::SVFStmtSetTy::iterator iter = cmps.begin(), eiter =
648 cmps.end(); iter != eiter; ++iter)
649 {
650 const CmpStmt* edge = SVFUtil::cast<CmpStmt>(*iter);
651 if(isInterestedPAGNode(edge->getRes()))
653 }
654}
SVFVar * getLHSVar() const
NodeType * getGNode(NodeID id) const
Get a node.
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
CSToArgsListMap & getCallSiteArgsMap()
Get callsite argument list.
Definition SVFIR.h:315
CSToRetMap & getCallSiteRets()
Get callsite return.
Definition SVFIR.h:327
FunToRetMap & getFunRets()
Get function return list.
Definition SVFIR.h:343
FunToArgsListMap & getFunArgsMap()
Get function arguments list.
Definition SVFIR.h:298
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
bool hasIncomingEdges(SVFStmt::PEDGEK kind) const
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesBegin(SVFStmt::PEDGEK kind) const
Edge iterators.
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesEnd(SVFStmt::PEDGEK kind) const
void addStoreVFGNode(const StoreStmt *store)
Definition VFG.h:583
void addBranchVFGNode(const BranchStmt *edge)
Add a BranchVFGNode.
Definition VFG.h:692
virtual SVFStmt::SVFStmtSetTy & getPAGEdgeSet(SVFStmt::PEDGEK kind)
Get PAGEdge set.
Definition VFG.h:498
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
void addNullPtrVFGNode(const PAGNode *pagNode)
Definition VFG.h:547
void addActualRetVFGNode(const PAGNode *ret, const CallICFGNode *cs)
Add a callsite Receive VFG node.
Definition VFG.h:633
void addUnaryOPVFGNode(const UnaryOPStmt *edge)
Add a UnaryOperator VFG node.
Definition VFG.h:683
void addFormalParmVFGNode(const PAGNode *fparm, const FunObjVar *fun, CallPESet &callPEs)
Add a formal parameter VFG node.
Definition VFG.h:600
void addActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs)
Definition VFG.h:592
void addCmpVFGNode(const CmpStmt *edge)
Add a Compare VFG node.
Definition VFG.h:655
virtual bool isInterestedPAGNode(const SVFVar *node) const
Definition VFG.h:506
bool hasBlackHoleConstObjAddrAsDef(const PAGNode *pagNode) const
Whether a PAGNode has a blackhole or const object as its definition.
Definition VFG.h:327
bool isPhiCopyEdge(const PAGEdge *copy) const
Definition VFG.h:520
bool hasDef(const PAGNode *pagNode) const
Definition VFG.h:488
FormalRetVFGNode::RetPESet RetPESet
Definition VFG.h:76
void addBinaryOPVFGNode(const BinaryOPStmt *edge)
Add a BinaryOperator VFG node.
Definition VFG.h:669
void addAddrVFGNode(const AddrStmt *addr)
Add an Address VFG node.
Definition VFG.h:554
FormalParmVFGNode::CallPESet CallPESet
Definition VFG.h:75
void addFormalRetVFGNode(const PAGNode *uniqueFunRet, const FunObjVar *fun, RetPESet &retPEs)
Definition VFG.h:614
void addIntraPHIVFGNode(const MultiOpndStmt *edge)
Add an llvm PHI VFG node.
Definition VFG.h:641

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

449 {
453 if (edge != nullptr)
454 edges.insert(edge);
455 }
NodeID getId() const
Get ID.
Definition SVFValue.h:158
VFGEdge * addInterEdgeFromAPToFP(ActualParmVFGNode *src, FormalParmVFGNode *dst, CallSiteID csId)
Add inter VF edge from actual to formal parameters.
Definition VFG.h:424
FormalParmVFGNode * getFormalParmVFGNode(const PAGNode *fparm) const
Definition VFG.h:309
ActualParmVFGNode * getActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs) const
Definition VFG.h:297
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 957 of file VFG.cpp.

958{
959 SVFIR * pag = SVFIR::getPAG();
960 CallSiteID csId = getCallSiteID(callBlockNode, callee);
961 const RetICFGNode* retBlockNode = callBlockNode->getRetICFGNode();
962 // connect actual and formal param
963 if (pag->hasCallSiteArgsMap(callBlockNode) && pag->hasFunArgsList(callee) &&
964 matchArgs(callBlockNode, callee))
965 {
966 const SVFIR::SVFVarList& csArgList = pag->getCallSiteArgsList(callBlockNode);
968 SVFIR::SVFVarList::const_iterator csArgIt = csArgList.begin(), csArgEit = csArgList.end();
969 SVFIR::SVFVarList::const_iterator funArgIt = funArgList.begin(), funArgEit = funArgList.end();
970 for (; funArgIt != funArgEit && csArgIt != csArgEit; funArgIt++, csArgIt++)
971 {
972 const PAGNode *cs_arg = *csArgIt;
973 const PAGNode *fun_arg = *funArgIt;
975 connectAParamAndFParam(cs_arg, fun_arg, callBlockNode, csId, edges);
976 }
977 assert(funArgIt == funArgEit && "function has more arguments than call site");
978
979 if (callee->isVarArg())
980 {
984 {
985 for (; csArgIt != csArgEit; csArgIt++)
986 {
987 const PAGNode *cs_arg = *csArgIt;
989 connectAParamAndFParam(cs_arg, varFunArgNode, callBlockNode, csId, edges);
990 }
991 }
992 }
993 }
994
995 // connect actual return and formal return
997 {
1002 }
1003}
const RetICFGNode * getRetICFGNode() const
Return callsite.
Definition ICFGNode.h:451
bool funHasRet(const FunObjVar *func) const
Definition SVFIR.h:354
bool hasFunArgsList(const FunObjVar *func) const
Function has arguments list.
Definition SVFIR.h:293
std::vector< const SVFVar * > SVFVarList
Definition SVFIR.h:58
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
Definition SVFIR.h:310
bool callsiteHasRet(const RetICFGNode *cs) const
Definition SVFIR.h:338
const SVFVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
Definition SVFIR.h:320
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
Definition SVFIR.h:332
const SVFVarList & getFunArgsList(const FunObjVar *func) const
Get function arguments list.
Definition SVFIR.h:303
const SVFVar * getFunRet(const FunObjVar *func) const
Get function return list.
Definition SVFIR.h:348
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:448
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *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:457
bool matchArgs(const CallICFGNode *cs, const FunObjVar *callee)
Definition SVFUtil.cpp:308
unsigned CallSiteID
Definition GeneralType.h:58

◆ connectDirectVFGEdges()

void VFG::connectDirectVFGEdges ( )
protected

Create edges between VFG nodes within a function.

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

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

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

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

connect formal ret to its definition node

connect formal ret to actual ret

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

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

add fork edge

add join edge

Definition at line 726 of file VFG.cpp.

727{
728
729 for(iterator it = begin(), eit = end(); it!=eit; ++it)
730 {
731 NodeID nodeId = it->first;
732 VFGNode* node = it->second;
733
734 if(StmtVFGNode* stmtNode = SVFUtil::dyn_cast<StmtVFGNode>(node))
735 {
737 if(SVFUtil::isa<AddrVFGNode>(stmtNode))
738 continue;
740 if (stmtNode->getPAGSrcNode()->isConstDataOrAggDataButNotNullPtr() == false)
741 // for ptr vfg, we skip src node of integer type if it is at a int2ptr copystmt
742 if(isInterestedPAGNode(stmtNode->getPAGSrcNode()))
743 addIntraDirectVFEdge(getDef(stmtNode->getPAGSrcNode()), nodeId);
744 if (const GepStmt* gepStmt = SVFUtil::dyn_cast<GepStmt>(stmtNode->getPAGEdge()))
745 {
746 for (const auto &varType: gepStmt->getOffsetVarAndGepTypePairVec())
747 {
748 if(varType.first->isConstDataOrAggDataButNotNullPtr() || isInterestedPAGNode(varType.first) == false)
749 continue;
751 }
752 }
754 if(SVFUtil::isa<StoreVFGNode>(stmtNode) && (stmtNode->getPAGDstNode()->isConstDataOrAggDataButNotNullPtr() == false))
755 {
756 addIntraDirectVFEdge(getDef(stmtNode->getPAGDstNode()), nodeId);
757 }
758
759 }
760 else if(PHIVFGNode* phiNode = SVFUtil::dyn_cast<PHIVFGNode>(node))
761 {
762 for (PHIVFGNode::OPVers::const_iterator it = phiNode->opVerBegin(), eit = phiNode->opVerEnd(); it != eit; it++)
763 {
764 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
766 }
767 }
768 else if(BinaryOPVFGNode* binaryNode = SVFUtil::dyn_cast<BinaryOPVFGNode>(node))
769 {
770 for (BinaryOPVFGNode::OPVers::const_iterator it = binaryNode->opVerBegin(), eit = binaryNode->opVerEnd(); it != eit; it++)
771 {
772 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
774 }
775 }
776 else if(UnaryOPVFGNode* unaryNode = SVFUtil::dyn_cast<UnaryOPVFGNode>(node))
777 {
778 for (UnaryOPVFGNode::OPVers::const_iterator it = unaryNode->opVerBegin(), eit = unaryNode->opVerEnd(); it != eit; it++)
779 {
780 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
782 }
783 }
784 else if(CmpVFGNode* cmpNode = SVFUtil::dyn_cast<CmpVFGNode>(node))
785 {
786 for (CmpVFGNode::OPVers::const_iterator it = cmpNode->opVerBegin(), eit = cmpNode->opVerEnd(); it != eit; it++)
787 {
788 if (it->second->isConstDataOrAggDataButNotNullPtr() == false)
790 }
791 }
792 else if(BranchVFGNode* branchNode = SVFUtil::dyn_cast<BranchVFGNode>(node))
793 {
794 const SVFVar* cond = branchNode->getBranchStmt()->getCondition();
795 if (cond->isConstDataOrAggDataButNotNullPtr() == false)
797 }
798 else if(ActualParmVFGNode* actualParm = SVFUtil::dyn_cast<ActualParmVFGNode>(node))
799 {
800 if (actualParm->getParam()->isConstDataOrAggDataButNotNullPtr() == false)
802 }
803 else if(FormalParmVFGNode* formalParm = SVFUtil::dyn_cast<FormalParmVFGNode>(node))
804 {
805 for(CallPESet::const_iterator it = formalParm->callPEBegin(), eit = formalParm->callPEEnd();
806 it!=eit; ++it)
807 {
808 const CallICFGNode* cs = (*it)->getCallSite();
809 ActualParmVFGNode* acutalParm = getActualParmVFGNode((*it)->getRHSVar(),cs);
811 }
812 }
813 else if(FormalRetVFGNode* calleeRet = SVFUtil::dyn_cast<FormalRetVFGNode>(node))
814 {
817
819 for(RetPESet::const_iterator it = calleeRet->retPEBegin(), eit = calleeRet->retPEEnd(); it!=eit; ++it)
820 {
821 ActualRetVFGNode* callsiteRev = getActualRetVFGNode((*it)->getLHSVar());
822 const CallICFGNode* callBlockNode = (*it)->getCallSite();
824 }
825 }
828 }
829
832 {
835 for (SVFStmt::SVFStmtSetTy::iterator iter = forks.begin(), eiter =
836 forks.end(); iter != eiter; ++iter)
837 {
838 TDForkPE* forkedge = SVFUtil::cast<TDForkPE>(*iter);
839 ActualParmVFGNode* acutalParm = getActualParmVFGNode(forkedge->getRHSVar(),forkedge->getCallSite());
842 }
845 for (SVFStmt::SVFStmtSetTy::iterator iter = joins.begin(), eiter =
846 joins.end(); iter != eiter; ++iter)
847 {
848 TDJoinPE* joinedge = SVFUtil::cast<TDJoinPE>(*iter);
849 NodeID callsiteRev = getDef(joinedge->getLHSVar());
851 addRetEdge(calleeRet->getId(),callsiteRev, getCallSiteID(joinedge->getCallSite(), calleeRet->getFun()));
852 }
853 }
854}
iterator begin()
Iterators.
static const Option< bool > EnableThreadCallGraph
Definition Options.h:133
virtual bool isConstDataOrAggDataButNotNullPtr() const
Check if this variable represents constant data/metadata but not null pointer.
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
ActualRetVFGNode * getActualRetVFGNode(const PAGNode *aret) const
Definition VFG.h:303
FormalRetVFGNode * getFormalRetVFGNode(const PAGNode *fret) const
Definition VFG.h:315
VFGEdge * addIntraDirectVFEdge(NodeID srcId, NodeID dstId)
Definition VFG.cpp:659
NodeID getDef(const PAGNode *pagNode) const
Definition VFG.h:482

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

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

◆ destroy()

void VFG::destroy ( )
protected

Clean up memory.

Memory has been cleaned up at GenericGraph

Definition at line 438 of file VFG.cpp.

439{
440 pag = nullptr;
441}

◆ dump()

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

Dump graph into dot file.

Dump VFG

Definition at line 921 of file VFG.cpp.

922{
924}
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 297 of file VFG.h.

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

◆ getActualRetVFGNode()

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

Definition at line 303 of file VFG.h.

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

◆ getBinaryOPVFGNode()

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

Definition at line 273 of file VFG.h.

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

◆ getBranchVFGNode()

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

Definition at line 285 of file VFG.h.

286 {
287 PAGNodeToBranchVFGNodeMapTy::const_iterator it = PAGNodeToBranchVFGNodeMap.find(pagNode);
288 assert(it != PAGNodeToBranchVFGNodeMap.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:396

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

◆ getCmpVFGNode()

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

Definition at line 291 of file VFG.h.

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

◆ getDef()

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

Definition at line 482 of file VFG.h.

483 {
484 PAGNodeToDefMapTy::const_iterator it = PAGNodeToDefMap.find(pagNode);
485 assert(it!=PAGNodeToDefMap.end() && "SVFVar does not have a definition??");
486 return it->second;
487 }
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 309 of file VFG.h.

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

◆ getFormalRetVFGNode()

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

Definition at line 315 of file VFG.h.

316 {
317 PAGNodeToFormalRetMapTy::const_iterator it = PAGNodeToFormalRetMap.find(fret);
318 assert(it!=PAGNodeToFormalRetMap.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 PAGNode pagNode) const
inline

Definition at line 267 of file VFG.h.

268 {
269 PAGNodeToPHIVFGNodeMapTy::const_iterator it = PAGNodeToIntraPHIVFGNodeMap.find(pagNode);
270 assert(it != PAGNodeToIntraPHIVFGNodeMap.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 912 of file VFG.cpp.

913{
914 return hasIntraVFGEdge(const_cast<VFGNode*>(src),const_cast<VFGNode*>(dst),kind);
915}

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

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

◆ 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 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:234
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition SVFIR.h:229
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 261 of file VFG.h.

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

◆ getUnaryOPVFGNode()

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

Definition at line 279 of file VFG.h.

280 {
281 PAGNodeToUnaryOPVFGNodeMapTy::const_iterator it = PAGNodeToUnaryOPVFGNodeMap.find(pagNode);
282 assert(it != PAGNodeToUnaryOPVFGNodeMap.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 }

◆ 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 PAGNode aparm,
const CallICFGNode cs 
) const
inline

Definition at line 241 of file VFG.h.

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

◆ hasActualRetVFGNode()

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

Definition at line 245 of file VFG.h.

246 {
248 }

◆ hasBinaryOPVFGNode()

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

Definition at line 225 of file VFG.h.

226 {
228 }

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

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

◆ hasBranchVFGNode()

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

Definition at line 233 of file VFG.h.

234 {
236 }

◆ hasCmpVFGNode()

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

Definition at line 237 of file VFG.h.

238 {
240 }

◆ hasDef()

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

Definition at line 488 of file VFG.h.

489 {
490 return (PAGNodeToDefMap.find(pagNode) != PAGNodeToDefMap.end());
491 }

◆ hasFormalParmVFGNode()

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

Definition at line 249 of file VFG.h.

250 {
252 }

◆ hasFormalRetVFGNode()

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

Definition at line 253 of file VFG.h.

254 {
256 }

◆ hasInterVFGEdge()

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

Whether we has an inter VFG edge

Definition at line 894 of file VFG.cpp.

895{
899 if (outEdge && inEdge)
900 {
901 assert(outEdge == inEdge && "edges not match");
902 return outEdge;
903 }
904 else
905 return nullptr;
906}
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 PAGNode pagNode) 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 859 of file VFG.cpp.

860{
861 VFGEdge edge(src,dst,kind);
864 if (outEdge && inEdge)
865 {
866 assert(outEdge == inEdge && "edges not match");
867 return outEdge;
868 }
869 else
870 return nullptr;
871}

◆ 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 PAGEdge pagEdge) const
inline

Existence checks for VFGNodes.

Definition at line 217 of file VFG.h.

218 {
219 return PAGEdgeToStmtVFGNodeMap.find(pagEdge) != PAGEdgeToStmtVFGNodeMap.end();
220 }

◆ hasThreadVFGEdge()

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

Whether we has an thread VFG edge

Definition at line 877 of file VFG.cpp.

878{
879 VFGEdge edge(src,dst,kind);
882 if (outEdge && inEdge)
883 {
884 assert(outEdge == inEdge && "edges not match");
885 return outEdge;
886 }
887 else
888 return nullptr;
889}

◆ hasUnaryOPVFGNode()

bool SVF::VFG::hasUnaryOPVFGNode ( const PAGNode pagNode) 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 1045 of file VFG.cpp.

1046{
1047 if(const FormalParmVFGNode* fp = SVFUtil::dyn_cast<FormalParmVFGNode>(node))
1048 {
1049 return fp->getFun();
1050 }
1051 else if(const InterPHIVFGNode* phi = SVFUtil::dyn_cast<InterPHIVFGNode>(node))
1052 {
1053 if(phi->isFormalParmPHI())
1054 return phi->getFun();
1055 }
1056 return nullptr;
1057}

◆ isInterestedPAGNode()

virtual bool SVF::VFG::isInterestedPAGNode ( 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 PAGEdge 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 PAGNode pagNode,
const VFGNode node 
)
inlineprotected

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

Definition at line 469 of file VFG.h.

470 {
471 PAGNodeToDefMapTy::iterator it = PAGNodeToDefMap.find(pagNode);
472 if(it == PAGNodeToDefMap.end())
473 {
474 PAGNodeToDefMap[pagNode] = node->getId();
475 assert(hasVFGNode(node->getId()) && "not in the map!!");
476 }
477 else
478 {
479 assert((it->second == node->getId()) && "a SVFVar 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 935 of file VFG.cpp.

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

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

930{
931 SVF::ViewGraph(this, "Value Flow Graph");
932}
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.

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