Static Value-Flow Analysis
GenericGraph.h
Go to the documentation of this file.
1 //===- CenericGraph.h -- Generic graph ---------------------------------------//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-2017> <Yulei Sui>
6 //
7 
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
17 
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //===----------------------------------------------------------------------===//
22 
23 /*
24  * GenericGraph.h
25  *
26  * Created on: Mar 19, 2014
27  * Author: Yulei Sui
28  */
29 
30 #ifndef GENERICGRAPH_H_
31 #define GENERICGRAPH_H_
32 
33 #include "SVFIR/SVFType.h"
34 #include "Util/iterator.h"
35 #include "Graphs/GraphTraits.h"
36 
37 namespace SVF
38 {
41 template <typename, typename> class GenericGraphWriter;
42 template <typename, typename> class GenericGraphReader;
44 
48 template<class NodeTy>
50 {
51  friend class SVFIRWriter;
52  friend class SVFIRReader;
53 
54 public:
56  typedef NodeTy NodeType;
61  typedef u64_t GEdgeFlag;
62  typedef s64_t GEdgeKind;
63 private:
64  NodeTy* src;
65  NodeTy* dst;
67 
68 public:
70  GenericEdge(NodeTy* s, NodeTy* d, GEdgeFlag k) : src(s), dst(d), edgeFlag(k)
71  {
72  }
73 
75  virtual ~GenericEdge()
76  {
77  }
78 
80 
81  inline NodeID getSrcID() const
82  {
83  return src->getId();
84  }
85  inline NodeID getDstID() const
86  {
87  return dst->getId();
88  }
89  inline GEdgeKind getEdgeKind() const
90  {
91  return (EdgeKindMask & edgeFlag);
92  }
94  {
95  return edgeFlag;
96  }
98  {
99  return src;
100  }
102  {
103  return dst;
104  }
106 
108  // and duplicated elements in the set are not inserted (binary tree comparison)
110  typedef struct equalGEdge
111  {
112  bool operator()(const GenericEdge<NodeType>* lhs, const GenericEdge<NodeType>* rhs) const
113  {
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();
118  else
119  return lhs->getDstID() < rhs->getDstID();
120  }
122 
123  virtual inline bool operator==(const GenericEdge<NodeType>* rhs) const
124  {
125  return (rhs->edgeFlag == this->edgeFlag &&
126  rhs->getSrcID() == this->getSrcID() &&
127  rhs->getDstID() == this->getDstID());
128  }
130 
131 protected:
132  static constexpr unsigned char EdgeKindMaskBits = 8;
133  static constexpr u64_t EdgeKindMask = (~0ULL) >> (64 - EdgeKindMaskBits);
134 };
135 
136 
138 {
139 
140 public:
141 
142  enum GNodeK
143  {
144  // ┌── ICFGNodeKinds: Combines inter-procedural and intra-procedural control flow graph nodes
145  // │ ├── Represents a node within a single procedure
147  // │ └── Represents a global-level block
149  // │ └─ InterICFGNodeKinds: Types of inter-procedural control flow graph nodes
150  // │ ├── Entry point of a function
152  // │ ├── Exit point of a function
154  // │ ├── Call site in the function
156  // │ └── Return site in the function
158  // └────────
159 
160  // ┌── SVFVarKinds: Combines ValVarKinds and ObjVarKinds for variable nodes
161  // │ ┌── ValVarKinds: Types of value variable nodes
162  // │ │ ├── Represents a standard value variable
164  // │ │ ├── Represents a GEP value variable
166  // │ │ ├── Represents a return value node
168  // │ │ ├── Represents a variadic argument node
170  // │ │ └── Dummy node for uninitialized values
172  // │ └── ObjVarKinds: Types of object variable nodes
173  // │ ├── Represents an object variable
175  // │ ├── GepObjNode: Represents a GEP object variable
177  // │ ├── FIObjNode: Represents a flow-insensitive object node
179  // │ └── DummyObjNode: Dummy node for uninitialized objects
181  // └────────
182 
183  // ┌── VFGNodeKinds: Various Value Flow Graph (VFG) node kinds with operations
184  // │ ├── Represents a comparison operation
186  // │ ├── Represents a binary operation
188  // │ ├── Represents a unary operation
190  // │ ├── Represents a branch operation
192  // │ ├── Dummy node for value propagation
194  // │ └── Represents a null pointer operation
196  // │ └── ArgumentVFGNodeKinds: Types of argument nodes in VFG
197  // │ ├── Represents a function return value
199  // │ ├── Represents an argument return value
201  // │ ├── Represents an argument parameter
203  // │ └── FParm: Represents a function parameter
205  // │ └── StmtVFGNodeKinds: Types of statement nodes in VFG
206  // │ ├── Represents an address operation
208  // │ ├── Represents a copy operation
210  // │ ├── Represents a GEP operation
212  // │ ├── Represents a store operation
214  // │ └── Represents a load operation
216  // │ └── PHIVFGNodeKinds: Types of PHI nodes in VFG
217  // │ ├── Represents a type-based PHI node
219  // │ ├── Represents an intra-procedural PHI node
221  // │ └── Represents an inter-procedural PHI node
223  // │ └── MRSVFGNodeKinds: Memory-related SVFG nodes
224  // │ ├── Function parameter input
226  // │ ├── Function parameter output
228  // │ ├── Argument parameter input
230  // │ └── Argument parameter output
232  // │ └── MSSAPHISVFGNodeKinds: Mem SSA PHI nodes for SVFG
233  // │ ├── Memory PHI node
235  // │ ├── Intra-procedural memory PHI node
237  // │ └── MInterPhi: Inter-procedural memory PHI node
239  // └────────
240 
241  // Additional specific graph node types
242  CallNodeKd, // Callgraph node
243  CDNodeKd, // Control dependence graph node
244  CFLNodeKd, // CFL graph node
245  CHNodeKd, // Class hierarchy graph node
246  ConstraintNodeKd, // Constraint graph node
247  TCTNodeKd, // Thread creation tree node
248  DCHNodeKd, // DCHG node
249  OtherKd // Other node kind
250  };
251 
252 
253 
254  SVFBaseNode(NodeID i, GNodeK k, SVFType* ty = nullptr): id(i),nodeKind(k), type(ty)
255  {
256 
257  }
258 
260  inline NodeID getId() const
261  {
262  return id;
263  }
264 
266  inline GNodeK getNodeKind() const
267  {
268  return nodeKind;
269  }
270 
271  virtual const SVFType* getType() const
272  {
273  return type;
274  }
275 
276  inline virtual void setSourceLoc(const std::string& sourceCodeInfo)
277  {
278  sourceLoc = sourceCodeInfo;
279  }
280 
281  virtual const std::string getSourceLoc() const
282  {
283  return sourceLoc;
284  }
285 
286  const std::string valueOnlyToString() const;
287 
288 
289 protected:
292  const SVFType* type;
293 
295 
297  //{@ Check node kind
298  static inline bool isICFGNodeKinds(GNodeK n)
299  {
300  static_assert(FunRetBlock - IntraBlock == 5,
301  "the number of ICFGNodeKinds has changed, make sure "
302  "the range is correct");
303  return n <= FunRetBlock && n >= IntraBlock;
304  }
305 
306  static inline bool isInterICFGNodeKind(GNodeK n)
307  {
308  static_assert(FunRetBlock - FunEntryBlock == 3,
309  "the number of InterICFGNodeKind has changed, make sure "
310  "the range is correct");
311  return n <= FunRetBlock && n >= FunEntryBlock;
312  }
313 
314  static inline bool isSVFVarKind(GNodeK n)
315  {
316  static_assert(DummyObjNode - ValNode == 8,
317  "The number of SVFVarKinds has changed, make sure the "
318  "range is correct");
319 
320  return n <= DummyObjNode && n >= ValNode;
321  }
322 
323  static inline bool isValVarKinds(GNodeK n)
324  {
325  static_assert(DummyValNode - ValNode == 4,
326  "The number of ValVarKinds has changed, make sure the "
327  "range is correct");
328  return n <= DummyValNode && n >= ValNode;
329  }
330 
331  static inline bool isObjVarKinds(GNodeK n)
332  {
333  static_assert(DummyObjNode - ObjNode == 3,
334  "The number of ObjVarKinds has changed, make sure the "
335  "range is correct");
336  return n <= DummyObjNode && n >= ObjNode;
337  }
338 
339  static inline bool isVFGNodeKinds(GNodeK n)
340  {
341  static_assert(MInterPhi - Cmp == 24,
342  "The number of VFGNodeKinds has changed, make sure the "
343  "range is correct");
344  return n <= MInterPhi && n >= Cmp;
345  }
346 
347  static inline bool isArgumentVFGNodeKinds(GNodeK n)
348  {
349  static_assert(FParm - FRet == 3,
350  "The number of ArgumentVFGNodeKinds has changed, make "
351  "sure the range is correct");
352  return n <= FParm && n >= FRet;
353  }
354 
355  static inline bool isStmtVFGNodeKinds(GNodeK n)
356  {
357  static_assert(Load - Addr == 4,
358  "The number of StmtVFGNodeKinds has changed, make sure "
359  "the range is correct");
360  return n <= Load && n >= Addr;
361  }
362 
363  static inline bool isPHIVFGNodeKinds(GNodeK n)
364  {
365  static_assert(TInterPhi - TPhi == 2,
366  "The number of PHIVFGNodeKinds has changed, make sure "
367  "the range is correct");
368  return n <= TInterPhi && n >= TPhi;
369  }
370 
371  static inline bool isMRSVFGNodeKinds(GNodeK n)
372  {
373  static_assert(MInterPhi - FPIN == 6,
374  "The number of MRSVFGNodeKinds has changed, make sure "
375  "the range is correct");
376  return n <= MInterPhi && n >= FPIN;
377  }
378 
379  static inline bool isMSSAPHISVFGNodeKinds(GNodeK n)
380  {
381  static_assert(MInterPhi - MPhi == 2,
382  "The number of MSSAPHISVFGNodeKinds has changed, make "
383  "sure the range is correct");
384  return n <= MInterPhi && n >= MPhi;
385  }
387 };
388 
392 template<class NodeTy,class EdgeTy>
394 {
395  friend class SVFIRWriter;
396  friend class SVFIRReader;
397 
398 public:
399  typedef NodeTy NodeType;
400  typedef EdgeTy EdgeType;
405  typedef typename GEdgeSetTy::iterator iterator;
406  typedef typename GEdgeSetTy::const_iterator const_iterator;
408 
409 private:
410 
413 
414 public:
417  {
418 
419  }
420 
422  virtual ~GenericNode()
423  {
424  for (auto * edge : OutEdges)
425  delete edge;
426  }
427 
430  inline const GEdgeSetTy& getOutEdges() const
431  {
432  return OutEdges;
433  }
434  inline const GEdgeSetTy& getInEdges() const
435  {
436  return InEdges;
437  }
439 
441 
442  inline bool hasIncomingEdge() const
443  {
444  return (InEdges.empty() == false);
445  }
446  inline bool hasOutgoingEdge() const
447  {
448  return (OutEdges.empty() == false);
449  }
451 
453 
455  {
456  return OutEdges.begin();
457  }
459  {
460  return OutEdges.end();
461  }
463  {
464  return InEdges.begin();
465  }
467  {
468  return InEdges.end();
469  }
471  {
472  return OutEdges.begin();
473  }
474  inline const_iterator OutEdgeEnd() const
475  {
476  return OutEdges.end();
477  }
479  {
480  return InEdges.begin();
481  }
482  inline const_iterator InEdgeEnd() const
483  {
484  return InEdges.end();
485  }
487 
489 
490  virtual inline iterator directOutEdgeBegin()
491  {
492  return OutEdges.begin();
493  }
494  virtual inline iterator directOutEdgeEnd()
495  {
496  return OutEdges.end();
497  }
498  virtual inline iterator directInEdgeBegin()
499  {
500  return InEdges.begin();
501  }
502  virtual inline iterator directInEdgeEnd()
503  {
504  return InEdges.end();
505  }
506 
507  virtual inline const_iterator directOutEdgeBegin() const
508  {
509  return OutEdges.begin();
510  }
511  virtual inline const_iterator directOutEdgeEnd() const
512  {
513  return OutEdges.end();
514  }
515  virtual inline const_iterator directInEdgeBegin() const
516  {
517  return InEdges.begin();
518  }
519  virtual inline const_iterator directInEdgeEnd() const
520  {
521  return InEdges.end();
522  }
524 
526 
527  inline bool addIncomingEdge(EdgeType* inEdge)
528  {
529  return InEdges.insert(inEdge).second;
530  }
531  inline bool addOutgoingEdge(EdgeType* outEdge)
532  {
533  return OutEdges.insert(outEdge).second;
534  }
536 
540  {
541  iterator it = InEdges.find(edge);
542  assert(it != InEdges.end() && "can not find in edge in SVFG node");
543  InEdges.erase(it);
544  return 1;
545  }
547  {
548  iterator it = OutEdges.find(edge);
549  assert(it != OutEdges.end() && "can not find out edge in SVFG node");
550  OutEdges.erase(it);
551  return 1;
552  }
554 
556 
557  inline EdgeType* hasIncomingEdge(EdgeType* edge) const
558  {
559  const_iterator it = InEdges.find(edge);
560  if (it != InEdges.end())
561  return *it;
562  else
563  return nullptr;
564  }
565  inline EdgeType* hasOutgoingEdge(EdgeType* edge) const
566  {
567  const_iterator it = OutEdges.find(edge);
568  if (it != OutEdges.end())
569  return *it;
570  else
571  return nullptr;
572  }
574 
575  static inline bool classof(const GenericNode<NodeTy, EdgeTy>*)
576  {
577  return true;
578  }
579 
580  static inline bool classof(const SVFBaseNode*)
581  {
582  return true;
583  }
584 };
585 
586 /*
587  * Generic graph for program representation
588  * It is base class and needs to be instantiated
589  */
590 template<class NodeTy, class EdgeTy>
592 {
593  friend class SVFIRWriter;
594  friend class SVFIRReader;
595  friend class GenericGraphWriter<NodeTy, EdgeTy>;
596  friend class GenericGraphReader<NodeTy, EdgeTy>;
597 
598 public:
599  typedef NodeTy NodeType;
600  typedef EdgeTy EdgeType;
603 
605 
606  typedef typename IDToNodeMapTy::iterator iterator;
607  typedef typename IDToNodeMapTy::const_iterator const_iterator;
609 
612 
614  virtual ~GenericGraph()
615  {
616  destroy();
617  }
618 
620  void destroy()
621  {
622  for (auto &entry : IDToNodeMap)
623  delete entry.second;
624  }
626 
627  inline iterator begin()
628  {
629  return IDToNodeMap.begin();
630  }
631  inline iterator end()
632  {
633  return IDToNodeMap.end();
634  }
635  inline const_iterator begin() const
636  {
637  return IDToNodeMap.begin();
638  }
639  inline const_iterator end() const
640  {
641  return IDToNodeMap.end();
642  }
643  //}@
644 
646  inline void addGNode(NodeID id, NodeType* node)
647  {
648  IDToNodeMap[id] = node;
649  nodeNum++;
650  }
651 
653  inline NodeType* getGNode(NodeID id) const
654  {
655  const_iterator it = IDToNodeMap.find(id);
656  assert(it != IDToNodeMap.end() && "Node not found!");
657  return it->second;
658  }
659 
661  inline bool hasGNode(NodeID id) const
662  {
663  const_iterator it = IDToNodeMap.find(id);
664  return it != IDToNodeMap.end();
665  }
666 
668  inline void removeGNode(NodeType* node)
669  {
670  assert(node->hasIncomingEdge() == false
671  && node->hasOutgoingEdge() == false
672  && "node which have edges can't be deleted");
673  iterator it = IDToNodeMap.find(node->getId());
674  assert(it != IDToNodeMap.end() && "can not find the node");
675  IDToNodeMap.erase(it);
676  delete node;
677  }
678 
680  inline u32_t getTotalNodeNum() const
681  {
682  return nodeNum;
683  }
684  inline u32_t getTotalEdgeNum() const
685  {
686  return edgeNum;
687  }
689  inline void incNodeNum()
690  {
691  nodeNum++;
692  }
693  inline void incEdgeNum()
694  {
695  edgeNum++;
696  }
697 
698 protected:
700 
701 public:
704 };
705 
706 } // End namespace SVF
707 
708 /* !
709  * GenericGraphTraits specializations for generic graph algorithms.
710  * Provide graph traits for traversing from a node using standard graph traversals.
711  */
712 namespace SVF
713 {
714 
715 // mapped_iter - This is a simple iterator adapter that causes a function to
716 // be applied whenever operator* is invoked on the iterator.
717 
718 template <typename ItTy, typename FuncTy,
719  typename FuncReturnTy =
720  decltype(std::declval<FuncTy>()(*std::declval<ItTy>()))>
722  : public iter_adaptor_base<
723  mapped_iter<ItTy, FuncTy>, ItTy,
724  typename std::iterator_traits<ItTy>::iterator_category,
725  typename std::remove_reference<FuncReturnTy>::type>
726 {
727 public:
728  mapped_iter(ItTy U, FuncTy F)
729  : mapped_iter::iter_adaptor_base(std::move(U)), F(std::move(F)) {}
730 
731  ItTy getCurrent()
732  {
733  return this->I;
734  }
735 
736  FuncReturnTy operator*() const
737  {
738  return F(*this->I);
739  }
740 
741 private:
742  FuncTy F;
743 };
744 
745 // map_iter - Provide a convenient way to create mapped_iters, just like
746 // make_pair is useful for creating pairs...
747 template <class ItTy, class FuncTy>
748 inline mapped_iter<ItTy, FuncTy> map_iter(ItTy I, FuncTy F)
749 {
751 }
752 
756 template<class NodeTy,class EdgeTy> struct GenericGraphTraits<SVF::GenericNode<NodeTy,EdgeTy>* >
757 {
758  typedef NodeTy NodeType;
759  typedef EdgeTy EdgeType;
760 
761  static inline NodeType* edge_dest(const EdgeType* E)
762  {
763  return E->getDstNode();
764  }
765 
766  // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
768 
770  {
771  return pagN;
772  }
773 
774  static inline ChildIteratorType child_begin(const NodeType* N)
775  {
776  return map_iter(N->OutEdgeBegin(), &edge_dest);
777  }
778  static inline ChildIteratorType child_end(const NodeType* N)
779  {
780  return map_iter(N->OutEdgeEnd(), &edge_dest);
781  }
783  {
784  return map_iter(N->directOutEdgeBegin(), &edge_dest);
785  }
787  {
788  return map_iter(N->directOutEdgeEnd(), &edge_dest);
789  }
790 };
791 
795 template<class NodeTy,class EdgeTy>
796 struct GenericGraphTraits<Inverse<SVF::GenericNode<NodeTy,EdgeTy>* > >
797 {
798  typedef NodeTy NodeType;
799  typedef EdgeTy EdgeType;
800 
801  static inline NodeType* edge_dest(const EdgeType* E)
802  {
803  return E->getSrcNode();
804  }
805 
806  // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
808 
810  {
811  return G.Graph;
812  }
813 
814  static inline ChildIteratorType child_begin(const NodeType* N)
815  {
816  return map_iter(N->InEdgeBegin(), &edge_dest);
817  }
818  static inline ChildIteratorType child_end(const NodeType* N)
819  {
820  return map_iter(N->InEdgeEnd(), &edge_dest);
821  }
822 
823  static inline unsigned getNodeID(const NodeType* N)
824  {
825  return N->getId();
826  }
827 };
828 
832 template<class NodeTy,class EdgeTy> struct GenericGraphTraits<SVF::GenericGraph<NodeTy,EdgeTy>* > : public GenericGraphTraits<SVF::GenericNode<NodeTy,EdgeTy>* >
833 {
835  typedef NodeTy NodeType;
836  typedef EdgeTy EdgeType;
837 
839  {
840  return nullptr; // return null here, maybe later we could create a dummy node
841  }
842 
843  typedef std::pair<SVF::NodeID, NodeType*> PairTy;
844  static inline NodeType* deref_val(PairTy P)
845  {
846  return P.second;
847  }
848 
849  // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
850  typedef mapped_iter<typename GenericGraphTy::iterator, decltype(&deref_val)> nodes_iterator;
851 
853  {
854  return map_iter(G->begin(), &deref_val);
855  }
857  {
858  return map_iter(G->end(), &deref_val);
859  }
860 
861  static unsigned graphSize(GenericGraphTy* G)
862  {
863  return G->getTotalNodeNum();
864  }
865 
866  static inline unsigned getNodeID(NodeType* N)
867  {
868  return N->getId();
869  }
871  {
872  return G->getGNode(id);
873  }
874 };
875 
876 } // End namespace llvm
877 
878 #endif /* GENERICGRAPH_H_ */
#define F(f)
cJSON * n
Definition: cJSON.cpp:2558
const char *const string
Definition: cJSON.h:172
virtual bool operator==(const GenericEdge< NodeType > *rhs) const
Definition: GenericGraph.h:123
NodeTy * src
source node
Definition: GenericGraph.h:64
GEdgeKind getEdgeKindWithoutMask() const
Definition: GenericGraph.h:93
struct SVF::GenericEdge::equalGEdge equalGEdge
Add the hash function for std::set (we also can overload operator< to implement this)
virtual ~GenericEdge()
Destructor.
Definition: GenericGraph.h:75
GenericEdge(NodeTy *s, NodeTy *d, GEdgeFlag k)
Constructor.
Definition: GenericGraph.h:70
static constexpr u64_t EdgeKindMask
Definition: GenericGraph.h:133
GEdgeFlag edgeFlag
edge kind
Definition: GenericGraph.h:66
NodeTy * dst
destination node
Definition: GenericGraph.h:65
NodeType * getSrcNode() const
Definition: GenericGraph.h:97
GEdgeKind getEdgeKind() const
Definition: GenericGraph.h:89
NodeID getDstID() const
Definition: GenericGraph.h:85
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:81
NodeType * getDstNode() const
Definition: GenericGraph.h:101
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
Definition: GenericGraph.h:132
NodeTy NodeType
Node type.
Definition: GenericGraph.h:56
void addGNode(NodeID id, NodeType *node)
Add a Node.
Definition: GenericGraph.h:646
iterator begin()
Iterators.
Definition: GenericGraph.h:627
void removeGNode(NodeType *node)
Delete a node.
Definition: GenericGraph.h:668
u32_t getTotalEdgeNum() const
Definition: GenericGraph.h:684
u32_t edgeNum
total num of node
Definition: GenericGraph.h:702
const_iterator end() const
Definition: GenericGraph.h:639
const_iterator begin() const
Definition: GenericGraph.h:635
u32_t nodeNum
total num of edge
Definition: GenericGraph.h:703
virtual ~GenericGraph()
Destructor.
Definition: GenericGraph.h:614
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:653
IDToNodeMapTy IDToNodeMap
node map
Definition: GenericGraph.h:699
IDToNodeMapTy::const_iterator const_iterator
Definition: GenericGraph.h:607
bool hasGNode(NodeID id) const
Has a node.
Definition: GenericGraph.h:661
void incNodeNum()
Increase number of node/edge.
Definition: GenericGraph.h:689
u32_t getTotalNodeNum() const
Get total number of node/edge.
Definition: GenericGraph.h:680
GenericGraph()
Constructor.
Definition: GenericGraph.h:611
IDToNodeMapTy::iterator iterator
Node Iterators.
Definition: GenericGraph.h:606
void destroy()
Release memory.
Definition: GenericGraph.h:620
OrderedMap< NodeID, NodeType * > IDToNodeMapTy
NodeID to GenericNode map.
Definition: GenericGraph.h:602
const_iterator InEdgeEnd() const
Definition: GenericGraph.h:482
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
Definition: GenericGraph.h:402
GEdgeSetTy OutEdges
all outgoing edge of this node
Definition: GenericGraph.h:412
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
Definition: GenericGraph.h:442
bool hasOutgoingEdge() const
Definition: GenericGraph.h:446
static bool classof(const SVFBaseNode *)
Definition: GenericGraph.h:580
u32_t removeOutgoingEdge(EdgeType *edge)
Definition: GenericGraph.h:546
virtual iterator directInEdgeEnd()
Definition: GenericGraph.h:502
iterator OutEdgeEnd()
Definition: GenericGraph.h:458
GEdgeSetTy InEdges
all incoming edge of this node
Definition: GenericGraph.h:411
const GEdgeSetTy & getOutEdges() const
Definition: GenericGraph.h:430
GEdgeSetTy::iterator iterator
Definition: GenericGraph.h:405
virtual ~GenericNode()
Destructor.
Definition: GenericGraph.h:422
virtual iterator directInEdgeBegin()
Definition: GenericGraph.h:498
const_iterator OutEdgeBegin() const
Definition: GenericGraph.h:470
virtual iterator directOutEdgeEnd()
Definition: GenericGraph.h:494
const_iterator InEdgeBegin() const
Definition: GenericGraph.h:478
virtual const_iterator directOutEdgeEnd() const
Definition: GenericGraph.h:511
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
Definition: GenericGraph.h:527
u32_t removeIncomingEdge(EdgeType *edge)
Definition: GenericGraph.h:539
EdgeType * hasOutgoingEdge(EdgeType *edge) const
Definition: GenericGraph.h:565
virtual iterator directOutEdgeBegin()
Iterators used for SCC detection, overwrite it in child class if necessary.
Definition: GenericGraph.h:490
iterator OutEdgeBegin()
iterators
Definition: GenericGraph.h:454
virtual const_iterator directInEdgeEnd() const
Definition: GenericGraph.h:519
static bool classof(const GenericNode< NodeTy, EdgeTy > *)
Definition: GenericGraph.h:575
virtual const_iterator directInEdgeBegin() const
Definition: GenericGraph.h:515
GEdgeSetTy::const_iterator const_iterator
Definition: GenericGraph.h:406
GenericNode(NodeID i, GNodeK k)
Constructor.
Definition: GenericGraph.h:416
const_iterator OutEdgeEnd() const
Definition: GenericGraph.h:474
virtual const_iterator directOutEdgeBegin() const
Definition: GenericGraph.h:507
EdgeType * hasIncomingEdge(EdgeType *edge) const
Find incoming and outgoing edges.
Definition: GenericGraph.h:557
iterator InEdgeBegin()
Definition: GenericGraph.h:462
bool addOutgoingEdge(EdgeType *outEdge)
Definition: GenericGraph.h:531
const GEdgeSetTy & getInEdges() const
Definition: GenericGraph.h:434
iterator InEdgeEnd()
Definition: GenericGraph.h:466
static bool isArgumentVFGNodeKinds(GNodeK n)
Definition: GenericGraph.h:347
virtual const SVFType * getType() const
Definition: GenericGraph.h:271
static bool isObjVarKinds(GNodeK n)
Definition: GenericGraph.h:331
std::string sourceLoc
Source code information of this value.
Definition: GenericGraph.h:294
NodeID id
Node ID.
Definition: GenericGraph.h:290
static bool isVFGNodeKinds(GNodeK n)
Definition: GenericGraph.h:339
const SVFType * type
SVF type.
Definition: GenericGraph.h:292
static bool isMRSVFGNodeKinds(GNodeK n)
Definition: GenericGraph.h:371
static bool isValVarKinds(GNodeK n)
Definition: GenericGraph.h:323
static bool isPHIVFGNodeKinds(GNodeK n)
Definition: GenericGraph.h:363
GNodeK getNodeKind() const
Get node kind.
Definition: GenericGraph.h:266
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
static bool isICFGNodeKinds(GNodeK n)
Helper functions to check node kinds.
Definition: GenericGraph.h:298
static bool isMSSAPHISVFGNodeKinds(GNodeK n)
Definition: GenericGraph.h:379
GNodeK nodeKind
Node kind.
Definition: GenericGraph.h:291
virtual void setSourceLoc(const std::string &sourceCodeInfo)
Definition: GenericGraph.h:276
static bool isStmtVFGNodeKinds(GNodeK n)
Definition: GenericGraph.h:355
SVFBaseNode(NodeID i, GNodeK k, SVFType *ty=nullptr)
Definition: GenericGraph.h:254
static bool isInterICFGNodeKind(GNodeK n)
Definition: GenericGraph.h:306
static bool isSVFVarKind(GNodeK n)
Definition: GenericGraph.h:314
const std::string valueOnlyToString() const
Definition: LLVMUtil.cpp:688
virtual const std::string getSourceLoc() const
Definition: GenericGraph.h:281
mapped_iter(ItTy U, FuncTy F)
Definition: GenericGraph.h:728
FuncReturnTy operator*() const
Definition: GenericGraph.h:736
constexpr std::remove_reference< T >::type && move(T &&t) noexcept
Definition: SVFUtil.h:447
for isBitcode
Definition: BasicTypes.h:68
unsigned long long u64_t
Definition: GeneralType.h:48
u32_t NodeID
Definition: GeneralType.h:55
std::set< Key, Compare, Allocator > OrderedSet
Definition: GeneralType.h:105
mapped_iter< ItTy, FuncTy > map_iter(ItTy I, FuncTy F)
Definition: GenericGraph.h:748
unsigned u32_t
Definition: GeneralType.h:46
signed long long s64_t
Definition: GeneralType.h:49
std::map< Key, Value, Compare, Allocator > OrderedMap
Definition: GeneralType.h:109
Add the hash function for std::set (we also can overload operator< to implement this)
Definition: GenericGraph.h:111
bool operator()(const GenericEdge< NodeType > *lhs, const GenericEdge< NodeType > *rhs) const
Definition: GenericGraph.h:112
mapped_iter< typename SVF::GenericNode< NodeTy, EdgeTy >::iterator, decltype(&edge_dest)> ChildIteratorType
Definition: GenericGraph.h:807
mapped_iter< typename GenericGraphTy::iterator, decltype(&deref_val)> nodes_iterator
Definition: GenericGraph.h:850
static nodes_iterator nodes_end(GenericGraphTy *G)
Definition: GenericGraph.h:856
static nodes_iterator nodes_begin(GenericGraphTy *G)
Definition: GenericGraph.h:852
static NodeType * getNode(GenericGraphTy *G, SVF::NodeID id)
Definition: GenericGraph.h:870
static ChildIteratorType direct_child_begin(const NodeType *N)
Definition: GenericGraph.h:782
static ChildIteratorType child_end(const NodeType *N)
Definition: GenericGraph.h:778
static ChildIteratorType direct_child_end(const NodeType *N)
Definition: GenericGraph.h:786
mapped_iter< typename SVF::GenericNode< NodeTy, EdgeTy >::iterator, decltype(&edge_dest)> ChildIteratorType
Definition: GenericGraph.h:767
static ChildIteratorType child_begin(const NodeType *N)
Definition: GenericGraph.h:774
const GraphType & Graph
Definition: GraphTraits.h:99