30#ifndef INCLUDE_UTIL_VFG_H_
31#define INCLUDE_UTIL_VFG_H_
80 typedef VFGNodeIDToNodeMapTy::iterator
iterator;
165 void dump(
const std::string& file,
bool simple =
false);
364 return it->second.begin();
370 return it->second.end();
383 edge->getDstNode()->removeIncomingEdge(
edge);
384 edge->getSrcNode()->removeOutgoingEdge(
edge);
419 assert((
srcfun ==
dstfun) &&
"src and dst nodes of an intra VFG edge are not in the same function?");
479 assert((
it->second == node->
getId()) &&
"a ValVar can only have unique definition ");
529 vfgNode->setICFGNode(icfgNode);
604 for(CallPESet::const_iterator
it = callPEs.begin(),
eit=callPEs.end();
618 for (RetPESet::const_iterator
it = retPEs.begin(),
eit = retPEs.end();
it !=
eit; ++
it)
645 for(
auto var :
edge->getOpndVars())
659 for(
auto var :
edge->getOpndVars())
673 for(
auto var :
edge->getOpndVars())
const CallICFGNode * getCallSite(CallSiteID id) const
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *callee) const
Get CallSiteID.
const RetICFGNode * getRetICFGNode() const
Return callsite.
void addGNode(NodeID id, NodeType *node)
Add a Node.
void removeGNode(NodeType *node)
Delete a node.
bool hasGNode(NodeID id) const
Has a node.
NodeType * getGNode(NodeID id) const
Get a node.
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
void addVFGNode(const VFGNode *vfgNode)
FunExitICFGNode * getFunExitICFGNode(const FunObjVar *fun)
Add a function exit node.
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
GlobalICFGNode * getGlobalICFGNode() const
Set< const SVFStmt * > SVFStmtSet
const ValVar * getLHSVar() const
SVFStmt::SVFStmtSetTy & getPTASVFStmtSet(SVFStmt::PEDGEK kind)
Get PTA edges set according to its kind.
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
bool isPhiNode(const SVFVar *node) const
Whether this SVFVar is a result operand a of phi node.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
ICFGNode * getICFGNode() const
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
NodeID getId() const
Get ID.
virtual const std::string & getName() const
virtual bool isPointer() const
Check if this variable represents a pointer.
GenericNode< VFGNode, VFGEdge >::GEdgeSetTy VFGEdgeSetTy
VFGEdgeSetTy SVFGEdgeSetTy
Set< const RetPE * > RetPESet
Set< const CallPE * > CallPESet
Set< VFGNode * > VFGNodeSet
FormalRetVFGNode * getFormalRetVFGNode(const SVFVar *fret) const
CmpVFGNode * getCmpVFGNode(const SVFVar *svfVar) const
CallGraph * getCallGraph() const
Return PTACallGraph.
SVFVarToBranchVFGNodeMapTy SVFVarToBranchVFGNodeMap
map a SVFVar to its BranchVFGNode
Map< const SVFVar *, BinaryOPVFGNode * > SVFVarToBinaryOPVFGNodeMapTy
SVFVarToFormalRetMapTy SVFVarToFormalRetMap
map a SVFVar to a formal return
Set< const SVFVar * > SVFVarSet
Map< std::pair< NodeID, const CallICFGNode * >, ActualParmVFGNode * > SVFVarToActualParmMapTy
VFGEdge::VFGEdgeSetTy VFGEdgeSetTy
void updateCallGraph(PointerAnalysis *pta)
Update VFG based on pointer analysis results.
NodeID getDef(const ValVar *valVar) const
const CallICFGNode * getCallSite(CallSiteID id) const
VFGEdge * addInterEdgeFromAPToFP(ActualParmVFGNode *src, FormalParmVFGNode *dst, CallSiteID csId)
Add inter VF edge from actual to formal parameters.
Set< const VFGNode * > GlobalVFGNodeSet
void removeVFGNode(VFGNode *node)
Remove a VFGNode.
void addStoreVFGNode(const StoreStmt *store)
void setDef(const ValVar *valVar, const VFGNode *node)
Given a ValVar, set/get its def VFG node (definition of top level pointers)
BranchVFGNode * getBranchVFGNode(const SVFVar *svfVar) const
bool hasCmpVFGNode(const SVFVar *svfVar) const
VFGEdge * addInterEdgeFromFRToAR(FormalRetVFGNode *src, ActualRetVFGNode *dst, CallSiteID csId)
Add inter VF edge from callee return to callsite receive parameter.
void addBranchVFGNode(const BranchStmt *edge)
Add a BranchVFGNode.
ActualParmVFGNode * getActualParmVFGNode(const SVFVar *aparm, const CallICFGNode *cs) const
VFGEdge * addInterEdgeFromFRToAR(NodeID src, NodeID dst, CallSiteID csId)
Add inter VF edge from callee return to callsite receive parameter.
SVFStmtToStmtVFGNodeMapTy SVFStmtToStmtVFGNodeMap
map a SVFStmt to its StmtVFGNode
Map< const SVFStmt *, StmtVFGNode * > SVFStmtToStmtVFGNodeMapTy
const SVFVar * getLHSTopLevPtr(const VFGNode *node) const
VFGNodeIDToNodeMapTy::const_iterator const_iterator
VFGNodeIDToNodeMapTy::iterator iterator
Map< const SVFVar *, IntraPHIVFGNode * > SVFVarToPHIVFGNodeMapTy
bool isPtrOnlySVFG() const
Return true if this VFG only contains pointer related SVFGNodes for pointer analysis.
VFGEdge * addRetEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
virtual void connectAParamAndFParam(const ValVar *csArg, const ValVar *funArg, const CallICFGNode *cbn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
bool hasBranchVFGNode(const SVFVar *svfVar) const
VFGEdge::VFGEdgeSetTy::iterator VFGNodeIter
bool hasVFGNode(NodeID id) const
Whether has the VFGNode.
SVFVarToUnaryOPVFGNodeMapTy SVFVarToUnaryOPVFGNodeMap
map a SVFVar to its UnaryOPVFGNode
void addVFGNodes()
Create VFG nodes.
SVFVarToActualParmMapTy SVFVarToActualParmMap
map a SVFVar to an actual parameter
void addLoadVFGNode(const LoadStmt *load)
Add a Load VFG node.
Map< const FunObjVar *, VFGNodeSet > FunToVFGNodesMapTy
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *func) const
Get callsite given a callsiteID.
VFGEdge * addIntraDirectVFEdge(NodeID srcId, NodeID dstId)
Map< const SVFVar *, UnaryOPVFGNode * > SVFVarToUnaryOPVFGNodeMapTy
void addVFGInterEdges(const CallICFGNode *cs, const FunObjVar *callee)
Create edges between VFG nodes across functions.
bool hasVFGNodes(const FunObjVar *fun) const
Map< const SVFVar *, FormalParmVFGNode * > SVFVarToFormalParmMapTy
void checkIntraEdgeParents(const VFGNode *srcNode, const VFGNode *dstNode)
sanitize Intra edges, verify that both nodes belong to the same function.
void addStmtVFGNode(StmtVFGNode *node, const SVFStmt *svfStmt)
Add a VFG node for program statement.
SVFVarToBinaryOPVFGNodeMapTy SVFVarToBinaryOPVFGNodeMap
map a SVFVar to its BinaryOPVFGNode
void addCopyVFGNode(const CopyStmt *copy)
Add a Copy VFG node.
bool hasBinaryOPVFGNode(const SVFVar *svfVar) const
void addFormalParmVFGNode(const ValVar *fparm, const FunObjVar *fun, CallPESet &callPEs)
Add a formal parameter VFG node.
void addGepVFGNode(const GepStmt *gep)
Add a Gep VFG node.
bool isPhiCopyEdge(const SVFStmt *copy) const
bool hasDef(const ValVar *valVar) const
IntraPHIVFGNode * getIntraPHIVFGNode(const SVFVar *svfVar) const
Map< const SVFVar *, CmpVFGNode * > SVFVarToCmpVFGNodeMapTy
virtual void connectFRetAndARet(const ValVar *funReturn, const ValVar *csReturn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect formal-ret and actual ret.
void addUnaryOPVFGNode(const UnaryOPStmt *edge)
Add a UnaryOperator VFG node.
virtual ~VFG()
Destructor.
SVFIR * getPAG() const
Return SVFIR.
UnaryOPVFGNode * getUnaryOPVFGNode(const SVFVar *svfVar) const
void addCmpVFGNode(const CmpStmt *edge)
Add a Compare VFG node.
GlobalVFGNodeSet globalVFGNodes
set of global store VFG nodes
FormalParmVFGNode * getFormalParmVFGNode(const SVFVar *fparm) const
bool hasActualRetVFGNode(const SVFVar *aret) const
Map< const SVFVar *, ActualRetVFGNode * > SVFVarToActualRetMapTy
VFGNodeSet::const_iterator getVFGNodeEnd(const FunObjVar *fun) const
Map< const SVFVar *, FormalRetVFGNode * > SVFVarToFormalRetMapTy
bool addVFGEdge(VFGEdge *edge)
Add VFG edge.
bool hasLHSTopLevPtr(const VFGNode *node) const
VFGNodeSet & getVFGNodes(const FunObjVar *fun)
bool hasStmtVFGNode(const SVFStmt *svfStmt) const
Existence checks for VFGNodes.
SVFIR::SVFStmtSet SVFStmtSet
VFGNode * getVFGNode(NodeID id) const
Get a VFG node.
void addActualParmVFGNode(const ValVar *aparm, const CallICFGNode *cs)
ValVarToDefMapTy ValVarToDefMap
map a pag node to its definition SVG node
const FunObjVar * isFunEntryVFGNode(const VFGNode *node) const
Whether a node is function entry VFGNode.
bool hasUnaryOPVFGNode(const SVFVar *svfVar) const
bool hasFormalRetVFGNode(const SVFVar *fret) const
FunToVFGNodesMapTy funToVFGNodesMap
map a function to its VFGNodes;
VFGNodeSet::const_iterator getVFGNodeBegin(const FunObjVar *fun) const
Map< const ValVar *, NodeID > ValVarToDefMapTy
SVFVarToFormalParmMapTy SVFVarToFormalParmMap
map a SVFVar to a formal parameter
VFGEdge * addCallEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
GlobalVFGNodeSet & getGlobalVFGNodes()
Return global stores.
BinaryOPVFGNode * getBinaryOPVFGNode(const SVFVar *svfVar) const
SVFVarToActualRetMapTy SVFVarToActualRetMap
map a SVFVar to an actual return
SVFVarToPHIVFGNodeMapTy SVFVarToIntraPHIVFGNodeMap
map a SVFVar to its PHIVFGNode
void addNullPtrVFGNode(const ValVar *svfVar)
StmtVFGNode * getStmtVFGNode(const SVFStmt *svfStmt) const
Get an VFGNode.
virtual SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get SVFStmt set.
void addFormalRetVFGNode(const ValVar *uniqueFunRet, const FunObjVar *fun, RetPESet &retPEs)
FormalRetVFGNode::RetPESet RetPESet
VFGEdge * hasIntraVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
Whether we has a SVFG edge.
const VFGNode * getDefVFGNode(const ValVar *valVar) const
Given a valVar, return its definition site.
void addBinaryOPVFGNode(const BinaryOPStmt *edge)
Add a BinaryOperator VFG node.
Map< const SVFVar *, BranchVFGNode * > SVFVarToBranchVFGNodeMapTy
VFGEdge::SVFGEdgeSetTy SVFGEdgeSetTy
void addAddrVFGNode(const AddrStmt *addr)
Add an Address VFG node.
OrderedMap< NodeID, VFGNode * > VFGNodeIDToNodeMapTy
bool hasActualParmVFGNode(const SVFVar *aparm, const CallICFGNode *cs) const
void addActualRetVFGNode(const ValVar *ret, const CallICFGNode *cs)
Add a callsite Receive VFG node.
SVFVarToCmpVFGNodeMapTy SVFVarToCmpVFGNodeMap
map a SVFVar to its CmpVFGNode
VFGEdge * addInterEdgeFromAPToFP(NodeID src, NodeID dst, CallSiteID csId)
Add inter VF edge from actual to formal parameters.
bool hasFormalParmVFGNode(const SVFVar *fparm) const
VFGK getKind() const
Get VFG kind.
VFGEdge * hasInterVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind, CallSiteID csId)
virtual void addVFGNode(VFGNode *vfgNode, ICFGNode *icfgNode)
Add a VFG node.
virtual bool isInterestedSVFVar(const SVFVar *node) const
FormalParmVFGNode::CallPESet CallPESet
void connectDirectVFGEdges()
Create edges between VFG nodes within a function.
VFGEdge * getIntraVFGEdge(const VFGNode *src, const VFGNode *dst, VFGEdge::VFGEdgeK kind)
Get a SVFG edge according to src and dst.
ActualRetVFGNode * getActualRetVFGNode(const SVFVar *aret) const
void view()
Dump graph into dot file.
VFGEdge * hasThreadVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
void removeVFGEdge(VFGEdge *edge)
Remove a SVFG edge.
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
bool hasBlackHoleConstObjAddrAsDef(const ValVar *valVar) const
Whether a SVFVar has a blackhole or const object as its definition.
bool VFGNodes(const FunObjVar *fun) const
bool hasIntraPHIVFGNode(const SVFVar *svfVar) const
virtual void connectCallerAndCallee(const CallICFGNode *cs, const FunObjVar *callee, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
void destroy()
Clean up memory.
void addIntraPHIVFGNode(const MultiOpndStmt *edge)
Add an llvm PHI VFG node.
LLVM_NODISCARD bool isa(const Y &Val)
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
llvm::IRBuilder IRBuilder
GenericGraph< VFGNode, VFGEdge > GenericVFGTy