30#ifndef SVF_CONTROLDG_H
31#define SVF_CONTROLDG_H
69 std::stringstream rawstr(str);
70 rawstr <<
"CDGEdge " <<
" [";
113 std::stringstream rawstr(str);
212 if (outEdge && inEdge)
214 assert(outEdge == inEdge &&
"edges not match");
226 for (CDGEdge::CDGEdgeSetTy::iterator iter = src->
OutEdgeBegin();
229 if ((*iter)->getDstID() == dst->
getId())
235 assert(counter <= 1 &&
"there's more than one edge between two CDG nodes");
246 void dump(
const std::string &filename)
263 std::set<CDGEdge *> temp;
291 assert(added1 && added2 &&
"edge not added??");
292 return added1 && added2;
334 Inverse<SVF::GenericNode<SVF::CDGNode, SVF::CDGEdge> *> >
359 return "Control Dependence Graph";
371 std::stringstream rawstr(str);
372 rawstr <<
"NodeID: " << node->
getId() <<
"\n";
376 rawstr <<
"IntraBlockNode ID: " << bNode->getId() <<
" \t";
380 rawstr << (bNode)->toString() <<
" \t";
390 rawstr <<
" {fun: " << bNode->getFun()->getName() <<
"}";
394 rawstr << entry->toString();
398 rawstr << exit->toString();
402 rawstr << call->toString();
406 rawstr << ret->toString();
418 assert(
false &&
"what else kinds of nodes do we have??");
426 std::stringstream rawstr(str);
429 rawstr <<
"shape=record";
433 rawstr <<
",color=black";
437 rawstr <<
",color=yellow";
441 rawstr <<
",color=green";
445 rawstr <<
",color=red";
449 rawstr <<
",color=blue";
453 rawstr <<
",color=purple";
456 assert(
false &&
"no such kind of node!!");
461 template<
class EdgeIter>
464 assert(*(EI.getCurrent()) &&
"No edge found!!");
465 return "style=solid";
468 template<
class EdgeIter>
472 assert(edge &&
"No edge found!!");
475 std::stringstream rawstr(str);
478 rawstr << std::to_string(cond.second) <<
"|";
480 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
CDGNode(const ICFGNode *icfgNode)
Constructor.
static bool classof(const SVFValue *node)
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.
NodeType * getSrcNode() const
NodeType * getDstNode() const
void addGNode(NodeID id, NodeType *node)
void removeGNode(NodeType *node)
IDToNodeMapTy IDToNodeMap
bool hasGNode(NodeID id) const
IDToNodeMapTy::iterator iterator
NodeType * getGNode(NodeID id) const
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const
u32_t removeOutgoingEdge(EdgeType *edge)
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
u32_t removeIncomingEdge(EdgeType *edge)
iterator OutEdgeBegin()
iterators
bool addOutgoingEdge(EdgeType *outEdge)
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
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
NodeID getId() const
Get ID.
GNodeK getNodeKind() const
Get node kind.
LLVM_NODISCARD bool isa(const Y &Val)
std::ostream & outs()
Overwrite llvm::outs().
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
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)
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
iter_range< typename GenericGraphTraits< GraphType >::nodes_iterator > nodes(const GraphType &G)
GenericEdge< CDGNode > GenericCDGEdgeTy
GenericNode< CDGNode, CDGEdge > GenericCDGNodeTy
GenericNode< ICFGNode, ICFGEdge > GenericICFGNodeTy
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 *)