30#ifndef GENERICGRAPH_H_
31#define GENERICGRAPH_H_
41template <
typename,
typename>
class GenericGraphWriter;
42template <
typename,
typename>
class GenericGraphReader;
114 if (
lhs->edgeFlag !=
rhs->edgeFlag)
115 return lhs->edgeFlag <
rhs->edgeFlag;
116 else if (
lhs->getSrcID() !=
rhs->getSrcID())
117 return lhs->getSrcID() <
rhs->getSrcID();
119 return lhs->getDstID() <
rhs->getDstID();
125 return (
rhs->edgeFlag ==
this->edgeFlag &&
126 rhs->getSrcID() ==
this->getSrcID() &&
127 rhs->getDstID() ==
this->getDstID());
266 "the number of ICFGNodeKinds has changed, make sure "
267 "the range is correct");
274 "the number of InterICFGNodeKind has changed, make sure "
275 "the range is correct");
282 "The number of SVFVarKinds has changed, make sure the "
291 "The number of ValVarKinds has changed, make sure the "
299 "The number of ObjVarKinds has changed, make sure the "
307 "The number of BaseObjVarKinds has changed, make sure the "
315 "The number of VFGNodeKinds has changed, make sure the "
323 "The number of ArgumentVFGNodeKinds has changed, make "
324 "sure the range is correct");
331 "The number of StmtVFGNodeKinds has changed, make sure "
332 "the range is correct");
339 "The number of PHIVFGNodeKinds has changed, make sure "
340 "the range is correct");
347 "The number of MRSVFGNodeKinds has changed, make sure "
348 "the range is correct");
355 "The number of MSSAPHISVFGNodeKinds has changed, make "
356 "sure the range is correct");
365template<
class NodeTy,
class EdgeTy>
417 return (
InEdges.empty() ==
false);
563template<
class NodeTy,
class EdgeTy>
643 assert(node->hasIncomingEdge() ==
false
644 && node->hasOutgoingEdge() ==
false
645 &&
"node which have edges can't be deleted");
693 decltype(std::declval<FuncTy>()(*std::declval<ItTy>()))>
696 mapped_iter<ItTy, FuncTy>, ItTy,
697 typename std::iterator_traits<ItTy>::iterator_category,
698 typename std::remove_reference<FuncReturnTy>::type>
720template <
class ItTy,
class FuncTy>
736 return E->getDstNode();
749 return map_iter(
N->OutEdgeBegin(), &edge_dest);
753 return map_iter(
N->OutEdgeEnd(), &edge_dest);
757 return map_iter(
N->directOutEdgeBegin(), &edge_dest);
761 return map_iter(
N->directOutEdgeEnd(), &edge_dest);
768template<
class NodeTy,
class EdgeTy>
776 return E->getSrcNode();
789 return map_iter(
N->InEdgeBegin(), &edge_dest);
793 return map_iter(
N->InEdgeEnd(), &edge_dest);
816 typedef std::pair<SVF::NodeID, NodeType*>
PairTy;
virtual bool operator==(const GenericEdge< NodeType > *rhs) const
GEdgeKind getEdgeKindWithoutMask() const
NodeType * getSrcNode() const
virtual ~GenericEdge()
Destructor.
GenericEdge(NodeTy *s, NodeTy *d, GEdgeFlag k)
Constructor.
NodeType * getDstNode() const
static constexpr u64_t EdgeKindMask
GEdgeFlag edgeFlag
edge kind
NodeTy * dst
destination node
GEdgeKind getEdgeKind() const
NodeID getSrcID() const
get methods of the components
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
NodeTy NodeType
Node type.
void addGNode(NodeID id, NodeType *node)
Add a Node.
iterator begin()
Iterators.
void removeGNode(NodeType *node)
Delete a node.
u32_t getTotalEdgeNum() const
u32_t edgeNum
total num of node
const_iterator end() const
const_iterator begin() const
u32_t nodeNum
total num of edge
virtual ~GenericGraph()
Destructor.
IDToNodeMapTy IDToNodeMap
node map
IDToNodeMapTy::const_iterator const_iterator
bool hasGNode(NodeID id) const
Has a node.
void incNodeNum()
Increase number of node/edge.
u32_t getTotalNodeNum() const
Get total number of node/edge.
GenericGraph()
Constructor.
IDToNodeMapTy::iterator iterator
Node Iterators.
NodeType * getGNode(NodeID id) const
Get a node.
void destroy()
Release memory.
OrderedMap< NodeID, NodeType * > IDToNodeMapTy
NodeID to GenericNode map.
const_iterator InEdgeEnd() const
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
GEdgeSetTy OutEdges
all outgoing edge of this node
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const
static bool classof(const SVFBaseNode *)
u32_t removeOutgoingEdge(EdgeType *edge)
virtual iterator directInEdgeEnd()
EdgeType * hasIncomingEdge(EdgeType *edge) const
Find incoming and outgoing edges.
GEdgeSetTy InEdges
all incoming edge of this node
GEdgeSetTy::iterator iterator
const GEdgeSetTy & getOutEdges() const
virtual ~GenericNode()
Destructor.
virtual iterator directInEdgeBegin()
const_iterator OutEdgeBegin() const
virtual iterator directOutEdgeEnd()
const GEdgeSetTy & getInEdges() const
const_iterator InEdgeBegin() const
virtual const_iterator directOutEdgeEnd() const
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
u32_t removeIncomingEdge(EdgeType *edge)
virtual iterator directOutEdgeBegin()
Iterators used for SCC detection, overwrite it in child class if necessary.
iterator OutEdgeBegin()
iterators
virtual const_iterator directInEdgeEnd() const
static bool classof(const GenericNode< NodeTy, EdgeTy > *)
virtual const_iterator directInEdgeBegin() const
GEdgeSetTy::const_iterator const_iterator
GenericNode(NodeID i, GNodeK k)
Constructor.
const_iterator OutEdgeEnd() const
virtual const_iterator directOutEdgeBegin() const
EdgeType * hasOutgoingEdge(EdgeType *edge) const
bool addOutgoingEdge(EdgeType *outEdge)
static bool isArgumentVFGNodeKinds(GNodeK n)
static bool isObjVarKinds(GNodeK n)
std::string sourceLoc
Source code information of this value.
static bool isVFGNodeKinds(GNodeK n)
const SVFType * type
SVF type.
virtual const SVFType * getType() const
static bool isMRSVFGNodeKinds(GNodeK n)
static bool isValVarKinds(GNodeK n)
static bool isPHIVFGNodeKinds(GNodeK n)
GNodeK getNodeKind() const
Get node kind.
NodeID getId() const
Get ID.
static bool isICFGNodeKinds(GNodeK n)
Helper functions to check node kinds.
static bool isMSSAPHISVFGNodeKinds(GNodeK n)
GNodeK nodeKind
Node kind.
virtual void setSourceLoc(const std::string &sourceCodeInfo)
static bool isStmtVFGNodeKinds(GNodeK n)
SVFBaseNode(NodeID i, GNodeK k, SVFType *ty=nullptr)
static bool isInterICFGNodeKind(GNodeK n)
static bool isSVFVarKind(GNodeK n)
const std::string valueOnlyToString() const
virtual const std::string getSourceLoc() const
static bool isBaseObjVarKinds(GNodeK n)
mapped_iter(ItTy U, FuncTy F)
FuncReturnTy operator*() const
llvm::IRBuilder IRBuilder
mapped_iter< ItTy, FuncTy > map_iter(ItTy I, FuncTy F)
Add the hash function for std::set (we also can overload operator< to implement this)
bool operator()(const GenericEdge< NodeType > *lhs, const GenericEdge< NodeType > *rhs) const
mapped_iter< typename SVF::GenericNode< NodeTy, EdgeTy >::iterator, decltype(&edge_dest)> ChildIteratorType
static NodeType * getEntryNode(Inverse< NodeType * > G)
static ChildIteratorType child_begin(const NodeType *N)
static ChildIteratorType child_end(const NodeType *N)
static NodeType * edge_dest(const EdgeType *E)
static unsigned getNodeID(const NodeType *N)
static unsigned getNodeID(NodeType *N)
static unsigned graphSize(GenericGraphTy *G)
static NodeType * getNode(GenericGraphTy *G, SVF::NodeID id)
mapped_iter< typename GenericGraphTy::iterator, decltype(&deref_val)> nodes_iterator
static NodeType * deref_val(PairTy P)
static NodeType * getEntryNode(GenericGraphTy *pag)
static nodes_iterator nodes_end(GenericGraphTy *G)
std::pair< SVF::NodeID, NodeType * > PairTy
static nodes_iterator nodes_begin(GenericGraphTy *G)
SVF::GenericGraph< NodeTy, EdgeTy > GenericGraphTy
static NodeType * getEntryNode(NodeType *pagN)
static ChildIteratorType direct_child_begin(const NodeType *N)
static ChildIteratorType child_end(const NodeType *N)
static ChildIteratorType direct_child_end(const NodeType *N)
static NodeType * edge_dest(const EdgeType *E)
mapped_iter< typename SVF::GenericNode< NodeTy, EdgeTy >::iterator, decltype(&edge_dest)> ChildIteratorType
static ChildIteratorType child_begin(const NodeType *N)