svf-lib 1.0.2192 → 1.0.2193
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SVF-osx/Release-build/bin/ae +0 -0
- package/SVF-osx/Release-build/bin/cfl +0 -0
- package/SVF-osx/Release-build/bin/dvf +0 -0
- package/SVF-osx/Release-build/bin/llvm2svf +0 -0
- package/SVF-osx/Release-build/bin/mta +0 -0
- package/SVF-osx/Release-build/bin/saber +0 -0
- package/SVF-osx/Release-build/bin/svf-ex +0 -0
- package/SVF-osx/Release-build/bin/wpa +0 -0
- package/SVF-osx/Release-build/include/Graphs/BasicBlockG.h +310 -0
- package/SVF-osx/Release-build/include/Graphs/GenericGraph.h +1 -0
- package/SVF-osx/Release-build/include/SVF-LLVM/LLVMModule.h +8 -4
- package/SVF-osx/Release-build/include/SVFIR/SVFValue.h +25 -124
- package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
//===- BasicBlockG.h -- BasicBlock node------------------------------------------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-2025> <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
|
+
* ICFGNode.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: 23 Jan, 2025
|
|
27
|
+
* Author: Jiawei, Xiao
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef BASICBLOCKGRAPH_H_
|
|
31
|
+
#define BASICBLOCKGRAPH_H_
|
|
32
|
+
#include "GenericGraph.h"
|
|
33
|
+
#include <sstream>
|
|
34
|
+
#include <algorithm>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
namespace SVF
|
|
38
|
+
{
|
|
39
|
+
class SVFBasicBlock;
|
|
40
|
+
class BasicBlockEdge;
|
|
41
|
+
class ICFGNode;
|
|
42
|
+
class SVFFunction;
|
|
43
|
+
typedef GenericEdge<SVFBasicBlock> GenericBasicBlockEdgeTy;
|
|
44
|
+
class BasicBlockEdge: public GenericBasicBlockEdgeTy
|
|
45
|
+
{
|
|
46
|
+
friend class SVFIRWriter;
|
|
47
|
+
friend class SVFIRReader;
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
public:
|
|
51
|
+
/// Constructor
|
|
52
|
+
BasicBlockEdge(SVFBasicBlock* s, SVFBasicBlock* d) : GenericBasicBlockEdgeTy(s, d, 0)
|
|
53
|
+
{
|
|
54
|
+
}
|
|
55
|
+
/// Destructor
|
|
56
|
+
~BasicBlockEdge() {}
|
|
57
|
+
|
|
58
|
+
/// Overloading operator << for dumping ICFG node ID
|
|
59
|
+
//@{
|
|
60
|
+
friend OutStream& operator<<(OutStream& o, const BasicBlockEdge& edge)
|
|
61
|
+
{
|
|
62
|
+
o << edge.toString();
|
|
63
|
+
return o;
|
|
64
|
+
}
|
|
65
|
+
//@}
|
|
66
|
+
|
|
67
|
+
virtual const std::string toString() const;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
typedef GenericNode<SVFBasicBlock, BasicBlockEdge> GenericBasicBlockNodeTy;
|
|
72
|
+
class SVFBasicBlock : public GenericBasicBlockNodeTy
|
|
73
|
+
{
|
|
74
|
+
friend class LLVMModuleSet;
|
|
75
|
+
friend class SVFIRWriter;
|
|
76
|
+
friend class SVFIRReader;
|
|
77
|
+
friend class SVFIRBuilder;
|
|
78
|
+
friend class SVFFunction;
|
|
79
|
+
friend class ICFGBuilder;
|
|
80
|
+
friend class ICFG;
|
|
81
|
+
|
|
82
|
+
public:
|
|
83
|
+
typedef std::vector<const ICFGNode*>::const_iterator const_iterator;
|
|
84
|
+
std::vector<const SVFBasicBlock*> succBBs;
|
|
85
|
+
std::vector<const SVFBasicBlock*> predBBs;
|
|
86
|
+
|
|
87
|
+
private:
|
|
88
|
+
std::vector<const ICFGNode*> allICFGNodes; ///< all ICFGNodes in this BasicBlock
|
|
89
|
+
const SVFFunction* fun; /// Function where this BasicBlock is
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
protected:
|
|
94
|
+
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
95
|
+
|
|
96
|
+
inline void addICFGNode(const ICFGNode* icfgNode)
|
|
97
|
+
{
|
|
98
|
+
assert(std::find(getICFGNodeList().begin(), getICFGNodeList().end(),
|
|
99
|
+
icfgNode) == getICFGNodeList().end() && "duplicated icfgnode");
|
|
100
|
+
allICFGNodes.push_back(icfgNode);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/// @}
|
|
104
|
+
|
|
105
|
+
public:
|
|
106
|
+
/// Constructor without name
|
|
107
|
+
SVFBasicBlock(NodeID id, const SVFFunction* f): GenericBasicBlockNodeTy(id, BasicBlockKd), fun(f)
|
|
108
|
+
{
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
SVFBasicBlock() = delete;
|
|
112
|
+
~SVFBasicBlock()
|
|
113
|
+
{
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static inline bool classof(const SVFBaseNode* node)
|
|
118
|
+
{
|
|
119
|
+
return node->getNodeKind() == SVFBaseNode::BasicBlockKd;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static inline bool classof(const SVFBasicBlock* node)
|
|
123
|
+
{
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//@{
|
|
128
|
+
friend OutStream &operator<<(OutStream &o, const SVFBasicBlock&node)
|
|
129
|
+
{
|
|
130
|
+
o << node.toString();
|
|
131
|
+
return o;
|
|
132
|
+
}
|
|
133
|
+
//@}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
inline const std::vector<const ICFGNode*>& getICFGNodeList() const
|
|
137
|
+
{
|
|
138
|
+
return allICFGNodes;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
inline const_iterator begin() const
|
|
142
|
+
{
|
|
143
|
+
return allICFGNodes.begin();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
inline const_iterator end() const
|
|
147
|
+
{
|
|
148
|
+
return allICFGNodes.end();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
inline void addSuccBasicBlock(const SVFBasicBlock* succ2)
|
|
152
|
+
{
|
|
153
|
+
// check if the edge already exists
|
|
154
|
+
for (auto edge: this->getOutEdges())
|
|
155
|
+
{
|
|
156
|
+
if (edge->getDstNode() == succ2)
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
SVFBasicBlock* succ = const_cast<SVFBasicBlock*>(succ2);
|
|
161
|
+
BasicBlockEdge* edge = new BasicBlockEdge(this, succ);
|
|
162
|
+
this->addOutgoingEdge(edge);
|
|
163
|
+
succ->addIncomingEdge(edge);
|
|
164
|
+
this->succBBs.push_back(succ);
|
|
165
|
+
succ->predBBs.push_back(this);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
inline void addPredBasicBlock(const SVFBasicBlock* pred2)
|
|
169
|
+
{
|
|
170
|
+
// check if the edge already exists
|
|
171
|
+
for (auto edge: this->getInEdges())
|
|
172
|
+
{
|
|
173
|
+
if (edge->getSrcNode() == pred2)
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
SVFBasicBlock* pred = const_cast<SVFBasicBlock*>(pred2);
|
|
177
|
+
BasicBlockEdge* edge = new BasicBlockEdge(pred, this);
|
|
178
|
+
this->addIncomingEdge(edge);
|
|
179
|
+
pred->addOutgoingEdge(edge);
|
|
180
|
+
this->predBBs.push_back(pred);
|
|
181
|
+
pred->succBBs.push_back(this);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
inline const SVFFunction* getParent() const
|
|
185
|
+
{
|
|
186
|
+
return fun;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
inline const SVFFunction* getFunction() const
|
|
190
|
+
{
|
|
191
|
+
return fun;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
inline const ICFGNode* front() const
|
|
195
|
+
{
|
|
196
|
+
assert(!allICFGNodes.empty() && "bb empty?");
|
|
197
|
+
return allICFGNodes.front();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
inline const ICFGNode* back() const
|
|
201
|
+
{
|
|
202
|
+
assert(!allICFGNodes.empty() && "bb empty?");
|
|
203
|
+
return allICFGNodes.back();
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
inline std::vector<const SVFBasicBlock*> getSuccessors() const
|
|
207
|
+
{
|
|
208
|
+
std::vector<const SVFBasicBlock*> res;
|
|
209
|
+
for (auto edge : this->getOutEdges())
|
|
210
|
+
{
|
|
211
|
+
res.push_back(edge->getDstNode());
|
|
212
|
+
}
|
|
213
|
+
return res;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
inline std::vector<const SVFBasicBlock*> getPredecessors() const
|
|
217
|
+
{
|
|
218
|
+
std::vector<const SVFBasicBlock*> res;
|
|
219
|
+
for (auto edge : this->getInEdges())
|
|
220
|
+
{
|
|
221
|
+
res.push_back(edge->getSrcNode());
|
|
222
|
+
}
|
|
223
|
+
return res;
|
|
224
|
+
}
|
|
225
|
+
u32_t getNumSuccessors() const
|
|
226
|
+
{
|
|
227
|
+
return this->getOutEdges().size();
|
|
228
|
+
}
|
|
229
|
+
u32_t getBBSuccessorPos(const SVFBasicBlock* Succ)
|
|
230
|
+
{
|
|
231
|
+
u32_t i = 0;
|
|
232
|
+
for (const SVFBasicBlock* SuccBB: succBBs)
|
|
233
|
+
{
|
|
234
|
+
if (SuccBB == Succ)
|
|
235
|
+
return i;
|
|
236
|
+
i++;
|
|
237
|
+
}
|
|
238
|
+
assert(false && "Didn't find successor edge?");
|
|
239
|
+
return 0;
|
|
240
|
+
}
|
|
241
|
+
u32_t getBBSuccessorPos(const SVFBasicBlock* Succ) const
|
|
242
|
+
{
|
|
243
|
+
u32_t i = 0;
|
|
244
|
+
for (const SVFBasicBlock* SuccBB: succBBs)
|
|
245
|
+
{
|
|
246
|
+
if (SuccBB == Succ)
|
|
247
|
+
return i;
|
|
248
|
+
i++;
|
|
249
|
+
}
|
|
250
|
+
assert(false && "Didn't find successor edge?");
|
|
251
|
+
return 0;
|
|
252
|
+
|
|
253
|
+
}
|
|
254
|
+
u32_t getBBPredecessorPos(const SVFBasicBlock* succbb)
|
|
255
|
+
{
|
|
256
|
+
u32_t pos = 0;
|
|
257
|
+
for (const SVFBasicBlock* PredBB : succbb->getPredecessors())
|
|
258
|
+
{
|
|
259
|
+
if(PredBB == this)
|
|
260
|
+
return pos;
|
|
261
|
+
++pos;
|
|
262
|
+
}
|
|
263
|
+
assert(false && "Didn't find predecessor edge?");
|
|
264
|
+
return pos;
|
|
265
|
+
}
|
|
266
|
+
u32_t getBBPredecessorPos(const SVFBasicBlock* succbb) const
|
|
267
|
+
{
|
|
268
|
+
u32_t pos = 0;
|
|
269
|
+
for (const SVFBasicBlock* PredBB : succbb->getPredecessors())
|
|
270
|
+
{
|
|
271
|
+
if(PredBB == this)
|
|
272
|
+
return pos;
|
|
273
|
+
++pos;
|
|
274
|
+
}
|
|
275
|
+
assert(false && "Didn't find predecessor edge?");
|
|
276
|
+
return pos;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const std::string toString() const;
|
|
280
|
+
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
typedef GenericGraph<SVFBasicBlock, BasicBlockEdge> GenericBasicBlockGraphTy;
|
|
286
|
+
class BasicBlockGraph: public GenericBasicBlockGraphTy
|
|
287
|
+
{
|
|
288
|
+
private:
|
|
289
|
+
NodeID id{0};
|
|
290
|
+
const SVFFunction* fun;
|
|
291
|
+
public:
|
|
292
|
+
/// Constructor
|
|
293
|
+
BasicBlockGraph(const SVFFunction* f): fun(f)
|
|
294
|
+
{
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
SVFBasicBlock* addBasicBlock(const std::string& bbname)
|
|
299
|
+
{
|
|
300
|
+
id++;
|
|
301
|
+
SVFBasicBlock* bb = new SVFBasicBlock(id, fun);
|
|
302
|
+
addGNode(id, bb);
|
|
303
|
+
bb->setName(bbname);
|
|
304
|
+
return bb;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
#endif
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
#include "SVFIR/SVFValue.h"
|
|
35
35
|
#include "SVFIR/SVFModule.h"
|
|
36
36
|
#include "Util/Options.h"
|
|
37
|
+
#include "Graphs/BasicBlockG.h"
|
|
37
38
|
|
|
38
39
|
namespace SVF
|
|
39
40
|
{
|
|
@@ -177,11 +178,14 @@ public:
|
|
|
177
178
|
|
|
178
179
|
void addFunctionMap(const Function* func, CallGraphNode* svfFunc);
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
// create a SVFBasicBlock according to LLVM BasicBlock, then add it to SVFFunction's BasicBlockGraph
|
|
182
|
+
inline void addBasicBlock(SVFFunction* fun, const BasicBlock* bb)
|
|
181
183
|
{
|
|
184
|
+
SVFBasicBlock* svfBB = fun->getBasicBlockGraph()->addBasicBlock(bb->getName().str());
|
|
182
185
|
LLVMBB2SVFBB[bb] = svfBB;
|
|
183
|
-
|
|
186
|
+
SVFBaseNode2LLVMValue[svfBB] = bb;
|
|
184
187
|
}
|
|
188
|
+
|
|
185
189
|
inline void addInstructionMap(const Instruction* inst, SVFInstruction* svfInst)
|
|
186
190
|
{
|
|
187
191
|
LLVMInst2SVFInst[inst] = svfInst;
|
|
@@ -246,7 +250,7 @@ public:
|
|
|
246
250
|
const Value* getLLVMValue(const SVFBaseNode* value) const
|
|
247
251
|
{
|
|
248
252
|
SVFBaseNode2LLVMValueMap ::const_iterator it = SVFBaseNode2LLVMValue.find(value);
|
|
249
|
-
assert(it!=SVFBaseNode2LLVMValue.end() && "can't find corresponding llvm value!");
|
|
253
|
+
assert(it != SVFBaseNode2LLVMValue.end() && "can't find corresponding llvm value!");
|
|
250
254
|
return it->second;
|
|
251
255
|
}
|
|
252
256
|
|
|
@@ -264,7 +268,7 @@ public:
|
|
|
264
268
|
return it->second;
|
|
265
269
|
}
|
|
266
270
|
|
|
267
|
-
|
|
271
|
+
SVFBasicBlock* getSVFBasicBlock(const BasicBlock* bb)
|
|
268
272
|
{
|
|
269
273
|
LLVMBB2SVFBBMap::const_iterator it = LLVMBB2SVFBB.find(bb);
|
|
270
274
|
assert(it!=LLVMBB2SVFBB.end() && "SVF BasicBlock not found!");
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
#include "SVFIR/SVFType.h"
|
|
34
34
|
#include "Graphs/GraphPrinter.h"
|
|
35
35
|
#include "Util/Casting.h"
|
|
36
|
+
#include "Graphs/BasicBlockG.h"
|
|
36
37
|
|
|
37
38
|
namespace SVF
|
|
38
39
|
{
|
|
@@ -299,7 +300,8 @@ class SVFFunction : public SVFValue
|
|
|
299
300
|
friend class SVFIRBuilder;
|
|
300
301
|
|
|
301
302
|
public:
|
|
302
|
-
|
|
303
|
+
typename BasicBlockGraph::IDToNodeMapTy::iterator iterator;
|
|
304
|
+
typedef BasicBlockGraph::IDToNodeMapTy::const_iterator const_iterator;
|
|
303
305
|
typedef SVFLoopAndDomInfo::BBSet BBSet;
|
|
304
306
|
typedef SVFLoopAndDomInfo::BBList BBList;
|
|
305
307
|
typedef SVFLoopAndDomInfo::LoopBBs LoopBBs;
|
|
@@ -314,10 +316,10 @@ private:
|
|
|
314
316
|
const SVFFunctionType* funcType; /// FunctionType, which is different from the type (PointerType) of this SVFFunction
|
|
315
317
|
SVFLoopAndDomInfo* loopAndDom; /// the loop and dominate information
|
|
316
318
|
const SVFFunction* realDefFun; /// the definition of a function across multiple modules
|
|
317
|
-
std::vector<const SVFBasicBlock*> allBBs; /// all BasicBlocks of this function
|
|
318
319
|
std::vector<const SVFArgument*> allArgs; /// all formal arguments of this function
|
|
319
320
|
SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
|
|
320
321
|
const CallGraphNode *callGraphNode; /// call graph node for this function
|
|
322
|
+
BasicBlockGraph* bbGraph; /// the basic block graph of this function
|
|
321
323
|
|
|
322
324
|
protected:
|
|
323
325
|
inline void setCallGraphNode(CallGraphNode *cgn)
|
|
@@ -325,12 +327,6 @@ protected:
|
|
|
325
327
|
callGraphNode = cgn;
|
|
326
328
|
}
|
|
327
329
|
|
|
328
|
-
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
329
|
-
inline void addBasicBlock(const SVFBasicBlock* bb)
|
|
330
|
-
{
|
|
331
|
-
allBBs.push_back(bb);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
330
|
inline void addArgument(SVFArgument* arg)
|
|
335
331
|
{
|
|
336
332
|
allArgs.push_back(arg);
|
|
@@ -376,6 +372,21 @@ public:
|
|
|
376
372
|
return isDecl;
|
|
377
373
|
}
|
|
378
374
|
|
|
375
|
+
void setBasicBlockGraph(BasicBlockGraph* graph)
|
|
376
|
+
{
|
|
377
|
+
this->bbGraph = graph;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
BasicBlockGraph* getBasicBlockGraph()
|
|
381
|
+
{
|
|
382
|
+
return bbGraph;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const BasicBlockGraph* getBasicBlockGraph() const
|
|
386
|
+
{
|
|
387
|
+
return bbGraph;
|
|
388
|
+
}
|
|
389
|
+
|
|
379
390
|
inline bool isIntrinsic() const
|
|
380
391
|
{
|
|
381
392
|
return intrinsic;
|
|
@@ -411,13 +422,14 @@ public:
|
|
|
411
422
|
|
|
412
423
|
inline bool hasBasicBlock() const
|
|
413
424
|
{
|
|
414
|
-
return
|
|
425
|
+
return bbGraph && bbGraph->begin() != bbGraph->end();
|
|
415
426
|
}
|
|
416
427
|
|
|
417
428
|
inline const SVFBasicBlock* getEntryBlock() const
|
|
418
429
|
{
|
|
419
430
|
assert(hasBasicBlock() && "function does not have any Basicblock, external function?");
|
|
420
|
-
|
|
431
|
+
assert(bbGraph->begin()->second->getInEdges().size() == 0 && "the first basic block is not entry block");
|
|
432
|
+
return bbGraph->begin()->second;
|
|
421
433
|
}
|
|
422
434
|
|
|
423
435
|
/// Carefully! when you call getExitBB, you need ensure the function has return instruction
|
|
@@ -437,23 +449,19 @@ public:
|
|
|
437
449
|
/// Carefully! 'back' is just the last basic block of function,
|
|
438
450
|
/// but not necessarily a exit basic block
|
|
439
451
|
/// more refer to: https://github.com/SVF-tools/SVF/pull/1262
|
|
440
|
-
return
|
|
452
|
+
return std::prev(bbGraph->end())->second;
|
|
441
453
|
}
|
|
442
454
|
|
|
443
455
|
inline const_iterator begin() const
|
|
444
456
|
{
|
|
445
|
-
return
|
|
457
|
+
return bbGraph->begin();
|
|
446
458
|
}
|
|
447
459
|
|
|
448
460
|
inline const_iterator end() const
|
|
449
461
|
{
|
|
450
|
-
return
|
|
462
|
+
return bbGraph->end();
|
|
451
463
|
}
|
|
452
464
|
|
|
453
|
-
inline const std::vector<const SVFBasicBlock*>& getBasicBlockList() const
|
|
454
|
-
{
|
|
455
|
-
return allBBs;
|
|
456
|
-
}
|
|
457
465
|
|
|
458
466
|
inline const std::vector<const SVFBasicBlock*>& getReachableBBs() const
|
|
459
467
|
{
|
|
@@ -523,113 +531,6 @@ public:
|
|
|
523
531
|
|
|
524
532
|
class ICFGNode;
|
|
525
533
|
|
|
526
|
-
class SVFBasicBlock : public SVFValue
|
|
527
|
-
{
|
|
528
|
-
friend class LLVMModuleSet;
|
|
529
|
-
friend class SVFIRWriter;
|
|
530
|
-
friend class SVFIRReader;
|
|
531
|
-
friend class SVFIRBuilder;
|
|
532
|
-
friend class SVFFunction;
|
|
533
|
-
friend class ICFGBuilder;
|
|
534
|
-
friend class ICFG;
|
|
535
|
-
|
|
536
|
-
public:
|
|
537
|
-
typedef std::vector<const ICFGNode*>::const_iterator const_iterator;
|
|
538
|
-
|
|
539
|
-
private:
|
|
540
|
-
std::vector<const ICFGNode*> allICFGNodes; ///< all ICFGNodes in this BasicBlock
|
|
541
|
-
std::vector<const SVFBasicBlock*> succBBs; ///< all successor BasicBlocks of this BasicBlock
|
|
542
|
-
std::vector<const SVFBasicBlock*> predBBs; ///< all predecessor BasicBlocks of this BasicBlock
|
|
543
|
-
const SVFFunction* fun; /// Function where this BasicBlock is
|
|
544
|
-
|
|
545
|
-
protected:
|
|
546
|
-
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
547
|
-
|
|
548
|
-
inline void addICFGNode(const ICFGNode* icfgNode)
|
|
549
|
-
{
|
|
550
|
-
assert(std::find(getICFGNodeList().begin(), getICFGNodeList().end(),
|
|
551
|
-
icfgNode) == getICFGNodeList().end() && "duplicated icfgnode");
|
|
552
|
-
allICFGNodes.push_back(icfgNode);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
inline void addSuccBasicBlock(const SVFBasicBlock* succ)
|
|
556
|
-
{
|
|
557
|
-
succBBs.push_back(succ);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
inline void addPredBasicBlock(const SVFBasicBlock* pred)
|
|
561
|
-
{
|
|
562
|
-
predBBs.push_back(pred);
|
|
563
|
-
}
|
|
564
|
-
/// @}
|
|
565
|
-
|
|
566
|
-
public:
|
|
567
|
-
/// Constructor without name
|
|
568
|
-
SVFBasicBlock(const SVFType* ty, const SVFFunction* f);
|
|
569
|
-
SVFBasicBlock() = delete;
|
|
570
|
-
~SVFBasicBlock() override;
|
|
571
|
-
|
|
572
|
-
static inline bool classof(const SVFValue *node)
|
|
573
|
-
{
|
|
574
|
-
return node->getKind() == SVFBB;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
inline const std::vector<const ICFGNode*>& getICFGNodeList() const
|
|
578
|
-
{
|
|
579
|
-
return allICFGNodes;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
inline const_iterator begin() const
|
|
583
|
-
{
|
|
584
|
-
return allICFGNodes.begin();
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
inline const_iterator end() const
|
|
588
|
-
{
|
|
589
|
-
return allICFGNodes.end();
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
inline const SVFFunction* getParent() const
|
|
593
|
-
{
|
|
594
|
-
return fun;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
inline const SVFFunction* getFunction() const
|
|
598
|
-
{
|
|
599
|
-
return fun;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
inline const ICFGNode* front() const
|
|
603
|
-
{
|
|
604
|
-
assert(!allICFGNodes.empty() && "bb empty?");
|
|
605
|
-
return allICFGNodes.front();
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
inline const ICFGNode* back() const
|
|
609
|
-
{
|
|
610
|
-
assert(!allICFGNodes.empty() && "bb empty?");
|
|
611
|
-
return allICFGNodes.back();
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
inline const std::vector<const SVFBasicBlock*>& getSuccessors() const
|
|
615
|
-
{
|
|
616
|
-
return succBBs;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
inline const std::vector<const SVFBasicBlock*>& getPredecessors() const
|
|
620
|
-
{
|
|
621
|
-
return predBBs;
|
|
622
|
-
}
|
|
623
|
-
u32_t getNumSuccessors() const
|
|
624
|
-
{
|
|
625
|
-
return succBBs.size();
|
|
626
|
-
}
|
|
627
|
-
u32_t getBBSuccessorPos(const SVFBasicBlock* succbb);
|
|
628
|
-
u32_t getBBSuccessorPos(const SVFBasicBlock* succbb) const;
|
|
629
|
-
u32_t getBBPredecessorPos(const SVFBasicBlock* succbb);
|
|
630
|
-
u32_t getBBPredecessorPos(const SVFBasicBlock* succbb) const;
|
|
631
|
-
};
|
|
632
|
-
|
|
633
534
|
class SVFInstruction : public SVFValue
|
|
634
535
|
{
|
|
635
536
|
friend class SVFIRWriter;
|
|
Binary file
|
|
Binary file
|