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);
302 return it->second.begin();
308 return it->second.end();
321 edge->getDstNode()->removeIncomingEdge(
edge);
322 edge->getSrcNode()->removeOutgoingEdge(
edge);
357 assert((
srcfun ==
dstfun) &&
"src and dst nodes of an intra VFG edge are not in the same function?");
417 assert((
it->second == node->
getId()) &&
"a SVFVar can only have unique definition ");
467 vfgNode->setICFGNode(icfgNode);
542 for(CallPESet::const_iterator
it = callPEs.begin(),
eit=callPEs.end();
556 for (RetPESet::const_iterator
it = retPEs.begin(),
eit = retPEs.end();
it !=
eit; ++
it)
583 for(
auto var :
edge->getOpndVars())
597 for(
auto var :
edge->getOpndVars())
611 for(
auto var :
edge->getOpndVars())
SVFVar * getLHSVar() const
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 SVFFunction * getFun() const
Return the function of this ICFGNode.
void addVFGNode(const VFGNode *vfgNode)
FunEntryICFGNode * getFunEntryICFGNode(const SVFFunction *fun)
Add a function entry node.
GlobalICFGNode * getGlobalICFGNode() const
FunExitICFGNode * getFunExitICFGNode(const SVFFunction *fun)
Add a function exit node.
Set< const SVFStmt * > SVFStmtSet
const CallICFGNode * getCallSite(CallSiteID id) const
CallSiteID getCallSiteID(const CallICFGNode *cs, const SVFFunction *callee) const
Get CallSiteID.
NodeID getId() const
Get ID.
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
const std::string & getName() const
virtual bool isPointer() const
Whether it is a pointer.
GenericNode< VFGNode, VFGEdge >::GEdgeSetTy VFGEdgeSetTy
VFGEdgeSetTy SVFGEdgeSetTy
Set< const RetPE * > RetPESet
Set< const CallPE * > CallPESet
Set< VFGNode * > VFGNodeSet
UnaryOPVFGNode * getUnaryOPVFGNode(const PAGNode *pagNode) const
VFGEdge::VFGEdgeSetTy VFGEdgeSetTy
void updateCallGraph(PointerAnalysis *pta)
Update VFG based on pointer analysis results.
const CallICFGNode * getCallSite(CallSiteID id) const
PAGNodeToBinaryOPVFGNodeMapTy PAGNodeToBinaryOPVFGNodeMap
map a PAGNode to its BinaryOPVFGNode
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)
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.
PAGNodeToFormalRetMapTy PAGNodeToFormalRetMap
map a PAGNode to a formal return
virtual SVFStmt::SVFStmtSetTy & getPAGEdgeSet(SVFStmt::PEDGEK kind)
Get PAGEdge set.
VFGEdge * addInterEdgeFromFRToAR(NodeID src, NodeID dst, CallSiteID csId)
Add inter VF edge from callee return to callsite receive parameter.
void setDef(const PAGNode *pagNode, const VFGNode *node)
Given a PAGNode, set/get its def VFG node (definition of top level pointers)
const PAGNode * getLHSTopLevPtr(const VFGNode *node) const
FormalParmVFGNode * getFormalParmVFGNode(const PAGNode *fparm) const
VFGNodeIDToNodeMapTy::const_iterator const_iterator
VFGNodeIDToNodeMapTy::iterator iterator
ActualRetVFGNode * getActualRetVFGNode(const PAGNode *aret) const
bool isPtrOnlySVFG() const
Return true if this VFG only contains pointer related SVFGNodes for pointer analysis.
VFGEdge * addRetEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
PAGNodeToActualRetMapTy PAGNodeToActualRetMap
map a PAGNode to an actual return
VFGNodeSet::const_iterator getVFGNodeEnd(const SVFFunction *fun) const
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.
FormalRetVFGNode * getFormalRetVFGNode(const PAGNode *fret) const
VFGEdge::VFGEdgeSetTy::iterator VFGNodeIter
bool hasVFGNode(NodeID id) const
Whether has the VFGNode.
void addVFGNodes()
Create VFG nodes.
void addLoadVFGNode(const LoadStmt *load)
Add a Load VFG node.
VFGEdge * addIntraDirectVFEdge(NodeID srcId, NodeID dstId)
void checkIntraEdgeParents(const VFGNode *srcNode, const VFGNode *dstNode)
sanitize Intra edges, verify that both nodes belong to the same function.
bool VFGNodes(const SVFFunction *fun) const
PAGEdgeToStmtVFGNodeMapTy PAGEdgeToStmtVFGNodeMap
map a PAGEdge to its StmtVFGNode
void addCopyVFGNode(const CopyStmt *copy)
Add a Copy VFG node.
void addGepVFGNode(const GepStmt *gep)
Add a Gep VFG node.
VFGNodeSet::const_iterator getVFGNodeBegin(const SVFFunction *fun) const
Map< const PAGNode *, FormalRetVFGNode * > PAGNodeToFormalRetMapTy
IntraPHIVFGNode * getIntraPHIVFGNode(const PAGNode *pagNode) const
PAGNodeToPHIVFGNodeMapTy PAGNodeToIntraPHIVFGNodeMap
map a PAGNode to its PHIVFGNode
void addNullPtrVFGNode(const PAGNode *pagNode)
CallSiteID getCallSiteID(const CallICFGNode *cs, const SVFFunction *func) const
Get callsite given a callsiteID.
CmpVFGNode * getCmpVFGNode(const PAGNode *pagNode) const
void addActualRetVFGNode(const PAGNode *ret, const CallICFGNode *cs)
Add a callsite Receive VFG node.
void addUnaryOPVFGNode(const UnaryOPStmt *edge)
Add a UnaryOperator VFG node.
virtual ~VFG()
Destructor.
SVFIR * getPAG() const
Return SVFIR.
void addActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs)
void addCmpVFGNode(const CmpStmt *edge)
Add a Compare VFG node.
GlobalVFGNodeSet globalVFGNodes
set of global store VFG nodes
Map< std::pair< NodeID, const CallICFGNode * >, ActualParmVFGNode * > PAGNodeToActualParmMapTy
void addStmtVFGNode(StmtVFGNode *node, const PAGEdge *pagEdge)
Add a VFG node for program statement.
Map< const PAGNode *, FormalParmVFGNode * > PAGNodeToFormalParmMapTy
Map< const PAGNode *, BranchVFGNode * > PAGNodeToBranchVFGNodeMapTy
NodeID getDef(const PAGNode *pagNode) const
bool hasVFGNodes(const SVFFunction *fun) const
Map< const PAGNode *, BinaryOPVFGNode * > PAGNodeToBinaryOPVFGNodeMapTy
const VFGNode * getDefVFGNode(const PAGNode *pagNode) const
Given a pagNode, return its definition site.
bool addVFGEdge(VFGEdge *edge)
Add VFG edge.
virtual bool isInterestedPAGNode(const SVFVar *node) const
BinaryOPVFGNode * getBinaryOPVFGNode(const PAGNode *pagNode) const
bool hasBlackHoleConstObjAddrAsDef(const PAGNode *pagNode) const
Whether a PAGNode has a blackhole or const object as its definition.
const SVFFunction * isFunEntryVFGNode(const VFGNode *node) const
Whether a node is function entry VFGNode.
PAGNodeToActualParmMapTy PAGNodeToActualParmMap
map a PAGNode to an actual parameter
ActualParmVFGNode * getActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs) const
bool isPhiCopyEdge(const PAGEdge *copy) const
SVFIR::SVFStmtSet SVFStmtSet
VFGNode * getVFGNode(NodeID id) const
Get a VFG node.
VFGNodeSet & getVFGNodes(const SVFFunction *fun)
BranchVFGNode * getBranchVFGNode(const PAGNode *pagNode) const
Map< const PAGNode *, ActualRetVFGNode * > PAGNodeToActualRetMapTy
PAGNodeToCmpVFGNodeMapTy PAGNodeToCmpVFGNodeMap
map a PAGNode to its CmpVFGNode
FunToVFGNodesMapTy funToVFGNodesMap
map a function to its VFGNodes;
Map< const PAGNode *, CmpVFGNode * > PAGNodeToCmpVFGNodeMapTy
StmtVFGNode * getStmtVFGNode(const PAGEdge *pagEdge) const
Get an VFGNode.
VFGEdge * addCallEdge(NodeID srcId, NodeID dstId, CallSiteID csId)
virtual void connectCallerAndCallee(const CallICFGNode *cs, const SVFFunction *callee, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
GlobalVFGNodeSet & getGlobalVFGNodes()
Return global stores.
void addFormalRetVFGNode(const PAGNode *uniqueFunRet, const SVFFunction *fun, RetPESet &retPEs)
Set< const PAGNode * > PAGNodeSet
Map< const PAGEdge *, StmtVFGNode * > PAGEdgeToStmtVFGNodeMapTy
virtual void connectFRetAndARet(const PAGNode *funReturn, const PAGNode *csReturn, CallSiteID csId, VFGEdgeSetTy &edges)
Connect formal-ret and actual ret.
PTACallGraph * getCallGraph() const
Return PTACallGraph.
bool hasDef(const PAGNode *pagNode) const
Map< const PAGNode *, NodeID > PAGNodeToDefMapTy
FormalRetVFGNode::RetPESet RetPESet
VFGEdge * hasIntraVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
Whether we has a SVFG edge.
PAGNodeToUnaryOPVFGNodeMapTy PAGNodeToUnaryOPVFGNodeMap
map a PAGNode to its UnaryOPVFGNode
void addBinaryOPVFGNode(const BinaryOPStmt *edge)
Add a BinaryOperator VFG node.
PAGNodeToDefMapTy PAGNodeToDefMap
map a pag node to its definition SVG node
VFGEdge::SVFGEdgeSetTy SVFGEdgeSetTy
void addAddrVFGNode(const AddrStmt *addr)
Add an Address VFG node.
OrderedMap< NodeID, VFGNode * > VFGNodeIDToNodeMapTy
VFGEdge * addInterEdgeFromAPToFP(NodeID src, NodeID dst, CallSiteID csId)
Add inter VF edge from actual to formal parameters.
Map< const PAGNode *, UnaryOPVFGNode * > PAGNodeToUnaryOPVFGNodeMapTy
PAGNodeToFormalParmMapTy PAGNodeToFormalParmMap
map a PAGNode to a formal parameter
Map< const SVFFunction *, VFGNodeSet > FunToVFGNodesMapTy
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.
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.
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.
Map< const PAGNode *, IntraPHIVFGNode * > PAGNodeToPHIVFGNodeMapTy
void destroy()
Clean up memory.
PAGNodeToBranchVFGNodeMapTy PAGNodeToBranchVFGNodeMap
map a PAGNode to its BranchVFGNode
void addIntraPHIVFGNode(const MultiOpndStmt *edge)
Add an llvm PHI VFG node.
void addFormalParmVFGNode(const PAGNode *fparm, const SVFFunction *fun, CallPESet &callPEs)
Add a formal parameter VFG node.
void addVFGInterEdges(const CallICFGNode *cs, const SVFFunction *callee)
Create edges between VFG nodes across functions.
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
llvm::IRBuilder IRBuilder
GenericGraph< VFGNode, VFGEdge > GenericVFGTy