37using namespace SVFUtil;
44 if (
f->begin() !=
f->end())
46 bb =
f->getEntryBlock();
55 if (
f->begin() !=
f->end())
181 rawstr <<
"CallCFGEdge " <<
" [ICFGNode";
190 rawstr <<
"RetCFGEdge " <<
" [ICFGNode";
199 return SVFUtil::cast<RetICFGNode>(
getDstNode())->getCallICFGNode();
219 for (
const auto &
loop:
it.second)
237 assert (entry &&
"fun entry not created in ICFGBuilder?");
244 assert (exit &&
"fun exit not created in ICFGBuilder?");
311 if ((*iter)->getDstID() == dst->
getId() && (*iter)->getEdgeKind() == kind)
317 assert(
counter <= 1 &&
"there's more than one edge between two ICFG nodes");
331 assert(
edge->isIntraCFGEdge() &&
"this should be an intra CFG edge!");
351 assert(
edge->isIntraCFGEdge() &&
"this should be an intra CFG edge!");
357 intraEdge->setBranchCondVal(branchCondVal);
371 assert(
edge->isCallCFGEdge() &&
"this should be a call CFG edge!");
389 assert(
edge->isRetCFGEdge() &&
"this should be a return CFG edge!");
421 PTACallGraph::CallEdgeMap::const_iterator
iter = callgraph->
getIndCallMap().begin();
454 if(
const RetPE *retPE = SVFUtil::dyn_cast<RetPE>(
stmt))
457 SVFUtil::cast<RetCFGEdge>(
retEdge)->addRetPE(retPE);
499 return getSimpleNodeLabel(node, graph);
521 if(SVFUtil::isa<IntraICFGNode>(node))
525 else if(SVFUtil::isa<FunEntryICFGNode>(node))
529 else if(SVFUtil::isa<FunExitICFGNode>(node))
533 else if(SVFUtil::isa<CallICFGNode>(node))
537 else if(SVFUtil::isa<RetICFGNode>(node))
541 else if(SVFUtil::isa<GlobalICFGNode>(node))
546 assert(
false &&
"no such kind of node!!");
553 template<
class EdgeIter>
558 if (SVFUtil::isa<CallCFGEdge>(
edge))
559 return "style=solid,color=red";
560 else if (SVFUtil::isa<RetCFGEdge>(
edge))
561 return "style=solid,color=blue";
563 return "style=solid";
567 template<
class EdgeIter>
580 rawstr << ret->getCallICFGNode();
virtual const std::string toString() const
const std::string toString() const override
const RetICFGNode * getRetICFGNode() const
Return callsite.
bool isIndirectCall() const
Return true if this is an indirect call.
FunEntryICFGNode(NodeID id)
Constructor to create empty FunEntryICFGNode (for SVFIRReader/deserialization)
const SVFFunction * getFun() const override
Return function.
const std::string toString() const override
const std::string toString() const override
FunExitICFGNode(NodeID id)
Constructor to create empty FunExitICFGNode (for SVFIRReader/deserialization)
const SVFFunction * getFun() const override
Return function.
NodeType * getSrcNode() const
NodeType * getDstNode() const
NodeID getSrcID() const
get methods of the components
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
iterator OutEdgeBegin()
iterators
const std::string toString() const override
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
virtual const std::string toString() const
virtual const SVFFunction * getFun() const
Return the function of this ICFGNode.
virtual const std::string toString() const
const SVFStmtList & getSVFStmts() const
void view()
View graph from the debugger.
FunEntryICFGNode * getFunEntryICFGNode(const SVFFunction *fun)
Add a function entry node.
ICFGEdge * hasThreadICFGEdge(ICFGNode *src, ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
FunEntryICFGNode * getFunEntryBlock(const SVFFunction *fun)
Get/Add a function entry node.
FunExitICFGNode * getFunExitBlock(const SVFFunction *fun)
Get/Add a function exit node.
bool addICFGEdge(ICFGEdge *edge)
Add ICFG edge, only used by addIntraEdge, addCallEdge, addRetEdge etc.
void removeICFGEdge(ICFGEdge *edge)
Remove a ICFG edge.
void updateCallGraph(PTACallGraph *callgraph)
update ICFG for indirect calls
ICFGEdge * getICFGEdge(const ICFGNode *src, const ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
Get a SVFG edge according to src and dst.
void checkIntraEdgeParents(const ICFGNode *srcNode, const ICFGNode *dstNode)
sanitize Intra edges, verify that both nodes belong to the same function.
ICFGEdge * addCallEdge(ICFGNode *srcNode, ICFGNode *dstNode)
ICFGNodeToSVFLoopVec icfgNodeToSVFLoopVec
map ICFG node to the SVF loops where it resides
ICFGEdge * hasInterICFGEdge(ICFGNode *src, ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
ICFGEdge * addRetEdge(ICFGNode *srcNode, ICFGNode *dstNode)
ICFGEdge * hasIntraICFGEdge(ICFGNode *src, ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
Whether we has a SVFG edge.
ICFGEdge * addConditionalIntraEdge(ICFGNode *srcNode, ICFGNode *dstNode, s64_t branchCondVal)
ICFGEdge * addIntraEdge(ICFGNode *srcNode, ICFGNode *dstNode)
Add intraprocedural and interprocedural control-flow edges.
~ICFG() override
Destructor.
FunExitICFGNode * getFunExitICFGNode(const SVFFunction *fun)
Add a function exit node.
s64_t getSuccessorCondValue() const
virtual const std::string toString() const
const SVFVar * getCondition() const
const std::string toString() const override
static const Option< bool > ShowHiddenNode
static const Option< bool > DumpICFG
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
Set< const SVFFunction * > FunctionSet
const CallICFGNode * getCallSite() const
Return call ICFGNode at the callsite.
virtual const std::string toString() const
const std::string toString() const override
NodeID getId() const
Get ID.
const std::string valueOnlyToString() const
virtual const std::string getSourceLoc() const
const ICFGNode * front() const
const SVFBasicBlock * getExitBB() const
const std::string & getName() const
virtual const std::string getSourceLoc() const
virtual const std::string toString() const
bool isExtCall(const SVFFunction *fun)
std::ostream & outs()
Overwrite llvm::outs()
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)
llvm::IRBuilder IRBuilder
std::string getNodeLabel(NodeType *node, ICFG *graph)
static std::string getGraphName(ICFG *)
Return name of the graph.
static bool isNodeHidden(ICFGNode *node, ICFG *)
static std::string getSimpleNodeLabel(NodeType *node, ICFG *)
Return the label of an ICFG node.
static std::string getEdgeSourceLabel(NodeType *, EdgeIter EI)
static std::string getEdgeAttributes(NodeType *, EdgeIter EI, ICFG *)
static std::string getNodeAttributes(NodeType *node, ICFG *)
DOTGraphTraits(bool isSimple=false)