Static Value-Flow Analysis
SVFLoop.h
Go to the documentation of this file.
1 //===- SVFLoop.h -- SVFLoop of SVF ------------------------------//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-> <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  * SVFLoop.h
25  *
26  * Created on: 14, 06, 2022
27  * Author: Jiawei Wang, Xiao Cheng
28  */
29 
30 #ifndef SVF_SVFLOOP_H
31 #define SVF_SVFLOOP_H
32 
33 #include "SVFIR/SVFType.h"
34 
35 namespace SVF
36 {
37 
38 class SVFLoop
39 {
40  friend class SVFIRWriter;
41  friend class SVFIRReader;
42 
45 private:
49 
50 public:
51  SVFLoop(const ICFGNodeSet &_nodes, u32_t _bound) :
52  icfgNodes(_nodes), loopBound(_bound)
53  {
54 
55  }
56 
57  virtual ~SVFLoop() = default;
58 
59  inline ICFGNodeSet::iterator ICFGNodesBegin()
60  {
61  return icfgNodes.begin();
62  }
63 
64  inline ICFGNodeSet::iterator ICFGNodesEnd()
65  {
66  return icfgNodes.end();
67  }
68 
69  inline bool isInLoop(const ICFGNode *icfgNode) const
70  {
71  return icfgNodes.find(icfgNode) != icfgNodes.end();
72  }
73 
74  inline bool isEntryICFGEdge(const ICFGEdge *edge) const
75  {
76  return entryICFGEdges.find(edge) != entryICFGEdges.end();
77  }
78 
79  inline bool isBackICFGEdge(const ICFGEdge *edge) const
80  {
81  return backICFGEdges.find(edge) != backICFGEdges.end();
82  }
83 
84  inline bool isInICFGEdge(const ICFGEdge *edge) const
85  {
86  return inICFGEdges.find(edge) != inICFGEdges.end();
87  }
88 
89  inline bool isOutICFGEdge(const ICFGEdge *edge) const
90  {
91  return outICFGEdges.find(edge) != outICFGEdges.end();
92  }
93 
94  inline void addEntryICFGEdge(const ICFGEdge *edge)
95  {
96  entryICFGEdges.insert(edge);
97  }
98 
99  inline ICFGEdgeSet::iterator entryICFGEdgesBegin()
100  {
101  return entryICFGEdges.begin();
102  }
103 
104  inline ICFGEdgeSet::iterator entryICFGEdgesEnd()
105  {
106  return entryICFGEdges.end();
107  }
108 
109  inline void addOutICFGEdge(const ICFGEdge *edge)
110  {
111  outICFGEdges.insert(edge);
112  }
113 
114  inline ICFGEdgeSet::iterator outICFGEdgesBegin()
115  {
116  return outICFGEdges.begin();
117  }
118 
119  inline ICFGEdgeSet::iterator outICFGEdgesEnd()
120  {
121  return outICFGEdges.end();
122  }
123 
124  inline void addBackICFGEdge(const ICFGEdge *edge)
125  {
126  backICFGEdges.insert(edge);
127  }
128 
129  inline ICFGEdgeSet::iterator backICFGEdgesBegin()
130  {
131  return backICFGEdges.begin();
132  }
133 
134  inline ICFGEdgeSet::iterator backICFGEdgesEnd()
135  {
136  return backICFGEdges.end();
137  }
138 
139  inline void addInICFGEdge(const ICFGEdge *edge)
140  {
141  inICFGEdges.insert(edge);
142  }
143 
144  inline ICFGEdgeSet::iterator inEdgesBegin()
145  {
146  return inICFGEdges.begin();
147  }
148 
149  inline ICFGEdgeSet::iterator inEdgesEnd()
150  {
151  return inICFGEdges.end();
152  }
153 
154  inline void setLoopBound(u32_t _bound)
155  {
156  loopBound = _bound;
157  }
158 
159  inline u32_t getLoopBound() const
160  {
161  return loopBound;
162  }
163 };
164 
165 } // End namespace SVF
166 
167 #endif //SVF_SVFLOOP_H
void addBackICFGEdge(const ICFGEdge *edge)
Definition: SVFLoop.h:124
ICFGNodeSet icfgNodes
Definition: SVFLoop.h:47
SVFLoop(const ICFGNodeSet &_nodes, u32_t _bound)
Definition: SVFLoop.h:51
virtual ~SVFLoop()=default
ICFGNodeSet::iterator ICFGNodesBegin()
Definition: SVFLoop.h:59
bool isEntryICFGEdge(const ICFGEdge *edge) const
Definition: SVFLoop.h:74
Set< const ICFGNode * > ICFGNodeSet
Definition: SVFLoop.h:44
ICFGNodeSet::iterator ICFGNodesEnd()
Definition: SVFLoop.h:64
void addOutICFGEdge(const ICFGEdge *edge)
Definition: SVFLoop.h:109
bool isOutICFGEdge(const ICFGEdge *edge) const
Definition: SVFLoop.h:89
ICFGEdgeSet entryICFGEdges
Definition: SVFLoop.h:46
ICFGEdgeSet::iterator outICFGEdgesBegin()
Definition: SVFLoop.h:114
ICFGEdgeSet::iterator backICFGEdgesEnd()
Definition: SVFLoop.h:134
bool isBackICFGEdge(const ICFGEdge *edge) const
Definition: SVFLoop.h:79
ICFGEdgeSet::iterator outICFGEdgesEnd()
Definition: SVFLoop.h:119
void addEntryICFGEdge(const ICFGEdge *edge)
Definition: SVFLoop.h:94
ICFGEdgeSet inICFGEdges
Definition: SVFLoop.h:46
ICFGEdgeSet::iterator backICFGEdgesBegin()
Definition: SVFLoop.h:129
ICFGEdgeSet::iterator entryICFGEdgesEnd()
Definition: SVFLoop.h:104
u32_t loopBound
Definition: SVFLoop.h:48
ICFGEdgeSet outICFGEdges
Definition: SVFLoop.h:46
ICFGEdgeSet::iterator inEdgesBegin()
Definition: SVFLoop.h:144
void addInICFGEdge(const ICFGEdge *edge)
Definition: SVFLoop.h:139
ICFGEdgeSet::iterator inEdgesEnd()
Definition: SVFLoop.h:149
u32_t getLoopBound() const
Definition: SVFLoop.h:159
ICFGEdgeSet::iterator entryICFGEdgesBegin()
Definition: SVFLoop.h:99
bool isInICFGEdge(const ICFGEdge *edge) const
Definition: SVFLoop.h:84
ICFGEdgeSet backICFGEdges
Definition: SVFLoop.h:46
Set< const ICFGEdge * > ICFGEdgeSet
Definition: SVFLoop.h:43
bool isInLoop(const ICFGNode *icfgNode) const
Definition: SVFLoop.h:69
void setLoopBound(u32_t _bound)
Definition: SVFLoop.h:154
for isBitcode
Definition: BasicTypes.h:68
unsigned u32_t
Definition: GeneralType.h:46
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96