30#ifndef SVF_CONTROLDG_H
31#define SVF_CONTROLDG_H
64 rawstr <<
"CDGEdge " <<
" [";
94 typedef CDGEdge::CDGEdgeSetTy::iterator
iterator;
223 if ((*iter)->getDstID() == dst->
getId())
229 assert(
counter <= 1 &&
"there's more than one edge between two CDG nodes");
249 edge->getDstNode()->removeIncomingEdge(
edge);
250 edge->getSrcNode()->removeOutgoingEdge(
edge);
257 std::set<CDGEdge *>
temp;
328 Inverse<SVF::GenericNode<SVF::CDGNode, SVF::CDGEdge> *> >
353 return "Control Dependence Graph";
358 return getSimpleNodeLabel(node, graph);
384 rawstr <<
" {fun: " <<
bNode->getFun()->getName() <<
"}";
386 else if (
const SVF::FunEntryICFGNode *entry = SVF::SVFUtil::dyn_cast<SVF::FunEntryICFGNode>(icfgNode))
388 rawstr << entry->toString();
390 else if (
const SVF::FunExitICFGNode *exit = SVF::SVFUtil::dyn_cast<SVF::FunExitICFGNode>(icfgNode))
392 rawstr << exit->toString();
394 else if (
const SVF::CallICFGNode *call = SVF::SVFUtil::dyn_cast<SVF::CallICFGNode>(icfgNode))
396 rawstr << call->toString();
398 else if (
const SVF::RetICFGNode *ret = SVF::SVFUtil::dyn_cast<SVF::RetICFGNode>(icfgNode))
400 rawstr << ret->toString();
412 assert(
false &&
"what else kinds of nodes do we have??");
423 if (SVF::SVFUtil::isa<SVF::IntraICFGNode>(icfgNode))
427 else if (SVF::SVFUtil::isa<SVF::FunEntryICFGNode>(icfgNode))
431 else if (SVF::SVFUtil::isa<SVF::FunExitICFGNode>(icfgNode))
435 else if (SVF::SVFUtil::isa<SVF::CallICFGNode>(icfgNode))
439 else if (SVF::SVFUtil::isa<SVF::RetICFGNode>(icfgNode))
443 else if (SVF::SVFUtil::isa<SVF::GlobalICFGNode>(icfgNode))
448 assert(
false &&
"no such kind of node!!");
455 template<
class EdgeIter>
458 assert(*(
EI.getCurrent()) &&
"No edge found!!");
459 return "style=solid";
462 template<
class EdgeIter>
470 for (
const auto &cond:
edge->getBranchConditions())
472 rawstr << std::to_string(cond.second) <<
"|";
474 std::string lb =
rawstr.str();
Set< BranchCondition > brConditions
virtual const std::string toString() const
CDGEdge(CDGNode *s, CDGNode *d)
Constructor.
GenericNode< CDGNode, CDGEdge >::GEdgeSetTy CDGEdgeSetTy
std::pair< const SVFVar *, s32_t > BranchCondition
const Set< BranchCondition > & getBranchConditions() const
get/set branch condition
CDGEdgeSetTy SVFGEdgeSetTy
void insertBranchCondition(const SVFVar *pNode, s32_t branchID)
const ICFGNode * getICFGNode() const
static bool classof(const SVFBaseNode *node)
CDGNode(const ICFGNode *icfgNode)
Constructor.
CDGEdge::CDGEdgeSetTy::iterator iterator
static bool classof(const CDGNode *)
Methods for support type inquiry through isa, cast, and dyn_cast:
const ICFGNode * _icfgNode
virtual const std::string toString() const
CDGEdge::CDGEdgeSetTy::const_iterator const_iterator
static bool classof(const GenericICFGNodeTy *node)
Map< NodeID, CDGNode * > CDGNodeIDToNodeMapTy
std::vector< std::pair< const ICFGNode *, const ICFGNode * > > ICFGNodePairVector
void removeCDGNode(CDGNode *node)
Remove a CDGNode.
CDGNodeIDToNodeMapTy::iterator iterator
void addCDGNodesFromVector(ICFGNodeVector nodes)
Add CDG nodes from nodeid vector.
CDGNodeIDToNodeMapTy::const_iterator const_iterator
void view()
View graph from the debugger.
bool hasCDGEdge(CDGNode *src, CDGNode *dst)
Whether we has a CDG edge.
bool removeCDGNode(NodeID id)
Remove node from nodeID.
CDGEdge * getCDGEdge(const CDGNode *src, const CDGNode *dst)
Get a control dependence edge according to src and dst.
virtual ~CDG()
Destructor.
static CDG * getCDG()
Singleton design here to make sure we only have one instance during any analysis.
void addCDGEdgeFromSrcDst(const ICFGNode *src, const ICFGNode *dst, const SVFVar *pNode, s32_t branchID)
Add CDG edges from nodeid pair.
void dump(const std::string &filename)
Dump graph into dot file.
bool hasCDGNode(NodeID id) const
Whether has the CDGNode.
virtual void addCDGNode(CDGNode *node)
Add a CDG node.
bool addCDGEdge(CDGEdge *edge)
Add CDG edge.
CDGEdge::CDGEdgeSetTy CDGEdgeSetTy
CDGNode * getCDGNode(NodeID id) const
Get a CDG node.
std::vector< const ICFGNode * > ICFGNodeVector
void removeCDGEdge(CDGEdge *edge)
Remove a control dependence edge.
NodeID getSrcID() const
get methods of the components
void addGNode(NodeID id, NodeType *node)
Add a Node.
void removeGNode(NodeType *node)
Delete a node.
IDToNodeMapTy IDToNodeMap
node map
bool hasGNode(NodeID id) const
Has a node.
IDToNodeMapTy::iterator iterator
Node Iterators.
NodeType * getGNode(NodeID id) const
Get a node.
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
iterator OutEdgeBegin()
iterators
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
GNodeK getNodeKind() const
Get node kind.
NodeID getId() const
Get ID.
std::vector< const SVFStmt * > SVFStmtList
SVFStmtList & getPTASVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PTA PAGEdges.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
virtual const std::string toString() const
std::ostream & outs()
Overwrite llvm::outs()
std::vector< std::pair< NodeID, NodeID > > NodePairVector
GenericGraph< CDGNode, CDGEdge > GenericCDGTy
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)
llvm::IRBuilder IRBuilder
iter_range< typename GenericGraphTraits< GraphType >::nodes_iterator > nodes(const GraphType &G)
GenericEdge< CDGNode > GenericCDGEdgeTy
GenericNode< CDGNode, CDGEdge > GenericCDGNodeTy
std::string getNodeLabel(NodeType *node, SVF::CDG *graph)
static std::string getGraphName(SVF::CDG *)
Return name of the graph.
static std::string getSimpleNodeLabel(NodeType *node, SVF::CDG *)
Return the label of an ICFG node.
DOTGraphTraits(bool isSimple=false)
static std::string getEdgeSourceLabel(NodeType *, EdgeIter EI)
static std::string getNodeAttributes(NodeType *node, SVF::CDG *)
static std::string getEdgeAttributes(NodeType *, EdgeIter EI, SVF::CDG *)