svf-lib 1.0.733 → 1.0.737

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.
Files changed (59) hide show
  1. package/SVF-linux/Release-build/lib/libSvf.a +0 -0
  2. package/SVF-linux/include/DDA/ContextDDA.h +1 -1
  3. package/SVF-linux/include/DDA/DDAClient.h +8 -8
  4. package/SVF-linux/include/DDA/DDAVFSolver.h +5 -5
  5. package/SVF-linux/include/DDA/FlowDDA.h +1 -1
  6. package/SVF-linux/include/Graphs/CHG.h +351 -0
  7. package/SVF-linux/include/Graphs/ConsG.h +6 -6
  8. package/SVF-linux/include/Graphs/ConsGEdge.h +2 -2
  9. package/SVF-linux/include/Graphs/ConsGNode.h +1 -1
  10. package/SVF-linux/include/Graphs/ExternalPAG.h +14 -14
  11. package/SVF-linux/include/Graphs/GenericGraph.h +1 -1
  12. package/SVF-linux/include/Graphs/ICFGNode.h +14 -14
  13. package/SVF-linux/include/Graphs/IRGraph.h +236 -0
  14. package/SVF-linux/include/Graphs/OfflineConsG.h +1 -1
  15. package/SVF-linux/include/Graphs/SVFG.h +1 -1
  16. package/SVF-linux/include/Graphs/SVFGOPT.h +3 -3
  17. package/SVF-linux/include/Graphs/VFG.h +53 -52
  18. package/SVF-linux/include/Graphs/VFGNode.h +60 -8
  19. package/SVF-linux/include/MSSA/MemRegion.h +11 -11
  20. package/SVF-linux/include/MSSA/MemSSA.h +4 -4
  21. package/SVF-linux/include/MTA/FSMPTA.h +1 -1
  22. package/SVF-linux/include/MemoryModel/PAGBuilderFromFile.h +8 -8
  23. package/SVF-linux/include/MemoryModel/PTAStat.h +31 -31
  24. package/SVF-linux/include/MemoryModel/PointerAnalysis.h +9 -9
  25. package/SVF-linux/include/MemoryModel/PointerAnalysisImpl.h +3 -3
  26. package/SVF-linux/include/MemoryModel/SVFIR.h +525 -233
  27. package/SVF-linux/include/MemoryModel/SVFStatements.h +970 -0
  28. package/SVF-linux/include/MemoryModel/SVFVariables.h +842 -0
  29. package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +346 -55
  30. package/SVF-linux/include/SABER/SaberSVFGBuilder.h +0 -2
  31. package/SVF-linux/include/SABER/SrcSnkDDA.h +3 -3
  32. package/SVF-linux/include/SVF-FE/CHGBuilder.h +69 -0
  33. package/SVF-linux/include/SVF-FE/DCHG.h +1 -1
  34. package/SVF-linux/include/SVF-FE/Graph2Json.h +1 -3
  35. package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +405 -0
  36. package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +0 -1
  37. package/SVF-linux/include/Util/CFLSolver.h +1 -1
  38. package/SVF-linux/include/Util/ExtAPI.h +1 -1
  39. package/SVF-linux/include/Util/IRAnnotator.h +6 -6
  40. package/SVF-linux/include/Util/Options.h +1 -1
  41. package/SVF-linux/include/Util/TypeBasedHeapCloning.h +11 -11
  42. package/SVF-linux/include/WPA/Andersen.h +11 -11
  43. package/SVF-linux/include/WPA/AndersenSFR.h +4 -4
  44. package/SVF-linux/include/WPA/FlowSensitive.h +2 -2
  45. package/SVF-linux/include/WPA/FlowSensitiveTBHC.h +1 -1
  46. package/SVF-linux/include/WPA/Steensgaard.h +2 -2
  47. package/SVF-linux/include/WPA/TypeAnalysis.h +1 -1
  48. package/SVF-linux/include/WPA/VersionedFlowSensitive.h +2 -2
  49. package/SVF-linux/include/WPA/WPAStat.h +1 -2
  50. package/SVF-osx/Release-build/lib/CUDD/libCudd.a +0 -0
  51. package/SVF-osx/Release-build/lib/libSvf.a +0 -0
  52. package/SVF-osx/include/Graphs/GenericGraph.h +1 -1
  53. package/SVF-osx/include/Graphs/IRGraph.h +6 -15
  54. package/SVF-osx/include/Graphs/VFG.h +26 -41
  55. package/SVF-osx/include/Graphs/VFGNode.h +2 -2
  56. package/SVF-osx/include/MemoryModel/SVFIR.h +29 -96
  57. package/SVF-osx/include/MemoryModel/SVFStatements.h +156 -22
  58. package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +12 -6
  59. package/package.json +1 -1
@@ -0,0 +1,970 @@
1
+ //===- SVFStatements.h -- SVF statements-------------------------------------------//
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 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 General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+
24
+ /*
25
+ * SVFStatements.h
26
+ *
27
+ * Created on: Nov 10, 2013
28
+ * Author: Yulei Sui
29
+ */
30
+
31
+ #ifndef PAGEDGE_H_
32
+ #define PAGEDGE_H_
33
+
34
+ #include "Graphs/GenericGraph.h"
35
+ #include "MemoryModel/LocationSet.h"
36
+ #include "Graphs/ICFGNode.h"
37
+
38
+ namespace SVF
39
+ {
40
+
41
+ class SVFVar;
42
+
43
+ /*
44
+ * SVFIR edge between nodes
45
+ */
46
+ typedef GenericEdge<SVFVar> GenericPAGEdgeTy;
47
+ class SVFStmt : public GenericPAGEdgeTy
48
+ {
49
+
50
+ public:
51
+ /// Thirteen kinds of SVFIR edges
52
+ /// Gep represents offset edge for field sensitivity
53
+ /// ThreadFork/ThreadJoin is to model parameter passings between thread spawners and spawnees.
54
+ enum PEDGEK
55
+ {
56
+ Addr, Copy, Store, Load, Call, Ret, NormalGep, VariantGep, Phi, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
57
+ };
58
+
59
+ private:
60
+ const Value* value; ///< LLVM value
61
+ const BasicBlock *basicBlock; ///< LLVM BasicBlock
62
+ ICFGNode *icfgNode; ///< ICFGNode
63
+ EdgeID edgeId; ///< Edge ID
64
+ public:
65
+ static Size_t totalEdgeNum; ///< Total edge number
66
+
67
+ /// Constructor
68
+ SVFStmt(SVFVar* s, SVFVar* d, GEdgeFlag k);
69
+ /// Destructor
70
+ ~SVFStmt()
71
+ {
72
+ }
73
+
74
+ /// ClassOf
75
+ //@{
76
+ static inline bool classof(const SVFStmt*)
77
+ {
78
+ return true;
79
+ }
80
+ static inline bool classof(const GenericPAGEdgeTy *edge)
81
+ {
82
+ return edge->getEdgeKind() == SVFStmt::Addr ||
83
+ edge->getEdgeKind() == SVFStmt::Copy ||
84
+ edge->getEdgeKind() == SVFStmt::Store ||
85
+ edge->getEdgeKind() == SVFStmt::Load ||
86
+ edge->getEdgeKind() == SVFStmt::Call ||
87
+ edge->getEdgeKind() == SVFStmt::Ret ||
88
+ edge->getEdgeKind() == SVFStmt::NormalGep ||
89
+ edge->getEdgeKind() == SVFStmt::VariantGep ||
90
+ edge->getEdgeKind() == SVFStmt::Cmp ||
91
+ edge->getEdgeKind() == SVFStmt::BinaryOp ||
92
+ edge->getEdgeKind() == SVFStmt::UnaryOp ||
93
+ edge->getEdgeKind() == SVFStmt::ThreadFork ||
94
+ edge->getEdgeKind() == SVFStmt::ThreadJoin;
95
+ }
96
+ ///@}
97
+
98
+ /// Return Edge ID
99
+ inline EdgeID getEdgeID() const
100
+ {
101
+ return edgeId;
102
+ }
103
+ /// Whether src and dst nodes are both of pointer type
104
+ bool isPTAEdge() const;
105
+
106
+ /// Get/set methods for llvm instruction
107
+ //@{
108
+ inline const Instruction* getInst() const
109
+ {
110
+ return SVFUtil::dyn_cast<Instruction>(value);
111
+ }
112
+ inline void setValue(const Value *val)
113
+ {
114
+ value = val;
115
+ }
116
+ inline const Value* getValue() const
117
+ {
118
+ return value;
119
+ }
120
+ inline void setBB(const BasicBlock *bb)
121
+ {
122
+ basicBlock = bb;
123
+ }
124
+ inline const BasicBlock* getBB() const
125
+ {
126
+ return basicBlock;
127
+ }
128
+ inline void setICFGNode(ICFGNode *node)
129
+ {
130
+ icfgNode = node;
131
+ }
132
+ inline ICFGNode* getICFGNode() const
133
+ {
134
+ return icfgNode;
135
+ }
136
+ //@}
137
+
138
+ /// Compute the unique edgeFlag value from edge kind and second variable operand for MultiOpndStmt.
139
+ static inline GEdgeFlag makeEdgeFlagWithAddionalOpnd(GEdgeKind k, const SVFVar* var)
140
+ {
141
+ Var2LabelMap::const_iterator iter = var2LabelMap.find(var);
142
+ u64_t label = (iter != var2LabelMap.end()) ?
143
+ iter->second : multiOpndLabelCounter++;
144
+ return (label << EdgeKindMaskBits) | k;
145
+ }
146
+
147
+ /// Compute the unique edgeFlag value from edge kind and call site Instruction.
148
+ static inline GEdgeFlag makeEdgeFlagWithCallInst(GEdgeKind k, const ICFGNode* cs)
149
+ {
150
+ Inst2LabelMap::const_iterator iter = inst2LabelMap.find(cs);
151
+ u64_t label = (iter != inst2LabelMap.end()) ?
152
+ iter->second : callEdgeLabelCounter++;
153
+ return (label << EdgeKindMaskBits) | k;
154
+ }
155
+
156
+ /// Compute the unique edgeFlag value from edge kind and store Instruction.
157
+ /// Two store instructions may share the same StorePAGEdge
158
+ static inline GEdgeFlag makeEdgeFlagWithStoreInst(GEdgeKind k, const ICFGNode* store)
159
+ {
160
+ Inst2LabelMap::const_iterator iter = inst2LabelMap.find(store);
161
+ u64_t label = (iter != inst2LabelMap.end()) ?
162
+ iter->second : storeEdgeLabelCounter++;
163
+ return (label << EdgeKindMaskBits) | k;
164
+ }
165
+
166
+ virtual const std::string toString() const;
167
+
168
+ //@}
169
+ /// Overloading operator << for dumping SVFVar value
170
+ //@{
171
+ friend raw_ostream& operator<< (raw_ostream &o, const SVFStmt &edge)
172
+ {
173
+ o << edge.toString();
174
+ return o;
175
+ }
176
+ //@}
177
+
178
+ typedef GenericNode<SVFVar,SVFStmt>::GEdgeSetTy PAGEdgeSetTy;
179
+ typedef Map<EdgeID, PAGEdgeSetTy> PAGEdgeToSetMapTy;
180
+ typedef PAGEdgeToSetMapTy PAGKindToEdgeSetMapTy;
181
+
182
+ private:
183
+ typedef Map<const ICFGNode*, u32_t> Inst2LabelMap;
184
+ typedef Map<const SVFVar*, u32_t> Var2LabelMap;
185
+ static Inst2LabelMap inst2LabelMap; ///< Call site Instruction to label map
186
+ static Var2LabelMap var2LabelMap; ///< Second operand of MultiOpndStmt to label map
187
+ static u64_t callEdgeLabelCounter; ///< Call site Instruction counter
188
+ static u64_t storeEdgeLabelCounter; ///< Store Instruction counter
189
+ static u64_t multiOpndLabelCounter; ///< MultiOpndStmt counter
190
+ };
191
+
192
+
193
+ /*!
194
+ * Copy edge
195
+ */
196
+ class AddrPE: public SVFStmt
197
+ {
198
+ private:
199
+ AddrPE(); ///< place holder
200
+ AddrPE(const AddrPE &); ///< place holder
201
+ void operator=(const AddrPE &); ///< place holder
202
+ public:
203
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
204
+ //@{
205
+ static inline bool classof(const AddrPE *)
206
+ {
207
+ return true;
208
+ }
209
+ static inline bool classof(const SVFStmt *edge)
210
+ {
211
+ return edge->getEdgeKind() == SVFStmt::Addr;
212
+ }
213
+ static inline bool classof(const GenericPAGEdgeTy *edge)
214
+ {
215
+ return edge->getEdgeKind() == SVFStmt::Addr;
216
+ }
217
+ //@}
218
+
219
+ /// constructor
220
+ AddrPE(SVFVar* s, SVFVar* d) : SVFStmt(s,d,SVFStmt::Addr)
221
+ {
222
+ }
223
+
224
+ virtual const std::string toString() const override;
225
+ };
226
+
227
+
228
+ /*!
229
+ * Copy edge
230
+ */
231
+ class CopyPE: public SVFStmt
232
+ {
233
+ private:
234
+ CopyPE(); ///< place holder
235
+ CopyPE(const CopyPE &); ///< place holder
236
+ void operator=(const CopyPE &); ///< place holder
237
+ public:
238
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
239
+ //@{
240
+ static inline bool classof(const CopyPE *)
241
+ {
242
+ return true;
243
+ }
244
+ static inline bool classof(const SVFStmt *edge)
245
+ {
246
+ return edge->getEdgeKind() == SVFStmt::Copy;
247
+ }
248
+ static inline bool classof(const GenericPAGEdgeTy *edge)
249
+ {
250
+ return edge->getEdgeKind() == SVFStmt::Copy;
251
+ }
252
+ //@}
253
+
254
+ /// constructor
255
+ CopyPE(SVFVar* s, SVFVar* d) : SVFStmt(s,d,SVFStmt::Copy)
256
+ {
257
+ }
258
+
259
+ virtual const std::string toString() const override;
260
+ };
261
+
262
+ class MultiOpndStmt : public SVFStmt{
263
+ public:
264
+ typedef std::vector<SVFVar*> OPVars;
265
+ protected:
266
+ OPVars opVars;
267
+ public:
268
+ /// Constructor, only used by subclassess but not external users
269
+ MultiOpndStmt(SVFVar* r, const OPVars& opnds, GEdgeFlag k): SVFStmt(opnds.at(0), r, k), opVars(opnds)
270
+ {
271
+ }
272
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
273
+ //@{
274
+ static inline bool classof(const MultiOpndStmt *)
275
+ {
276
+ return true;
277
+ }
278
+ static inline bool classof(const SVFStmt *node)
279
+ {
280
+ return node->getEdgeKind() == Phi ||
281
+ node->getEdgeKind() == BinaryOp ||
282
+ node->getEdgeKind() == Cmp;
283
+ }
284
+ static inline bool classof(const GenericPAGEdgeTy *node)
285
+ {
286
+ return node->getEdgeKind() == Phi ||
287
+ node->getEdgeKind() == BinaryOp ||
288
+ node->getEdgeKind() == Cmp;
289
+ }
290
+ //@}
291
+ /// Operands and result at a BinaryNode e.g., p = q + r, `p` is resVar and `r` is OpVar
292
+ //@{
293
+ /// Operand SVFVars
294
+ inline const SVFVar* getOpVar(u32_t pos) const
295
+ {
296
+ return opVars.at(pos);
297
+ }
298
+ /// Result SVFVar
299
+ inline const SVFVar* getRes() const
300
+ {
301
+ return getDstNode();
302
+ }
303
+
304
+ NodeID getOpVarID(u32_t pos) const;
305
+ NodeID getResID() const;
306
+
307
+ inline u32_t getOpVarNum() const
308
+ {
309
+ return opVars.size();
310
+ }
311
+ inline const OPVars& getOpndVars() const{
312
+ return opVars;
313
+ }
314
+ inline OPVars::const_iterator opVarBegin() const
315
+ {
316
+ return opVars.begin();
317
+ }
318
+ inline OPVars::const_iterator opVerEnd() const
319
+ {
320
+ return opVars.end();
321
+ }
322
+ //@}
323
+ };
324
+
325
+ /*!
326
+ * Phi instruction edge
327
+ */
328
+ class PhiPE: public MultiOpndStmt
329
+ {
330
+ private:
331
+ PhiPE(); ///< place holder
332
+ PhiPE(const PhiPE &); ///< place holder
333
+ void operator=(const PhiPE &); ///< place holder
334
+ SVFVar* getSrcNode(); ///< place holder, not allowed since this SVFStmt has multiple operands but not a single source
335
+ SVFVar* getDstNode(); ///< place holder, use getRes() instead
336
+ SVFVar* getSrcID(); ///< place holder, use getOpVarID(pos) instead
337
+ SVFVar* getDstID(); ///< place holder, use getResID() instead
338
+
339
+ public:
340
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
341
+ //@{
342
+ static inline bool classof(const PhiPE *)
343
+ {
344
+ return true;
345
+ }
346
+ static inline bool classof(const SVFStmt *edge)
347
+ {
348
+ return edge->getEdgeKind() == SVFStmt::Phi;
349
+ }
350
+ static inline bool classof(const MultiOpndStmt *edge)
351
+ {
352
+ return edge->getEdgeKind() == SVFStmt::Phi;
353
+ }
354
+ static inline bool classof(const GenericPAGEdgeTy *edge)
355
+ {
356
+ return edge->getEdgeKind() == SVFStmt::Phi;
357
+ }
358
+ //@}
359
+
360
+ /// constructor
361
+ PhiPE(SVFVar* s, const OPVars& opnds) : MultiOpndStmt(s,opnds,SVFStmt::Phi)
362
+ {
363
+ }
364
+ void addOpVar(SVFVar* op){
365
+ opVars.push_back(op);
366
+ }
367
+ virtual const std::string toString() const override;
368
+ };
369
+
370
+
371
+ /*!
372
+ * Compare instruction edge
373
+ */
374
+ class CmpPE: public MultiOpndStmt
375
+ {
376
+ private:
377
+ CmpPE(); ///< place holder
378
+ CmpPE(const CmpPE &); ///< place holder
379
+ void operator=(const CmpPE &); ///< place holder
380
+ SVFVar* getSrcNode(); ///< place holder, not allowed since this SVFStmt has multiple operands but not a single source
381
+ SVFVar* getDstNode(); ///< place holder, use getRes() instead
382
+ SVFVar* getSrcID(); ///< place holder, use getOpVarID(pos) instead
383
+ SVFVar* getDstID(); ///< place holder, use getResID() instead
384
+
385
+ u32_t opcode;
386
+ public:
387
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
388
+ //@{
389
+ static inline bool classof(const CmpPE *)
390
+ {
391
+ return true;
392
+ }
393
+ static inline bool classof(const SVFStmt *edge)
394
+ {
395
+ return edge->getEdgeKind() == SVFStmt::Cmp;
396
+ }
397
+ static inline bool classof(const MultiOpndStmt *edge)
398
+ {
399
+ return edge->getEdgeKind() == SVFStmt::Cmp;
400
+ }
401
+ static inline bool classof(const GenericPAGEdgeTy *edge)
402
+ {
403
+ return edge->getEdgeKind() == SVFStmt::Cmp;
404
+ }
405
+ //@}
406
+
407
+ /// constructor
408
+ CmpPE(SVFVar* s, const OPVars& opnds, u32_t oc) : MultiOpndStmt(s,opnds,SVFStmt::Cmp), opcode(oc)
409
+ {
410
+ }
411
+
412
+ u32_t getOpcode() const
413
+ {
414
+ return opcode;
415
+ }
416
+
417
+ virtual const std::string toString() const override;
418
+ };
419
+
420
+
421
+ /*!
422
+ * Binary instruction edge
423
+ */
424
+ class BinaryOPPE: public MultiOpndStmt
425
+ {
426
+ private:
427
+ BinaryOPPE(); ///< place holder
428
+ BinaryOPPE(const BinaryOPPE &); ///< place holder
429
+ void operator=(const BinaryOPPE &); ///< place holder
430
+ SVFVar* getSrcNode(); ///< place holder, not allowed since this SVFStmt has multiple operands but not a single source
431
+ SVFVar* getDstNode(); ///< place holder, use getRes() instead
432
+ SVFVar* getSrcID(); ///< place holder, use getOpVarID(pos) instead
433
+ SVFVar* getDstID(); ///< place holder, use getResID() instead
434
+
435
+ u32_t opcode;
436
+
437
+ public:
438
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
439
+ //@{
440
+ static inline bool classof(const BinaryOPPE *)
441
+ {
442
+ return true;
443
+ }
444
+ static inline bool classof(const SVFStmt *edge)
445
+ {
446
+ return edge->getEdgeKind() == SVFStmt::BinaryOp;
447
+ }
448
+ static inline bool classof(const MultiOpndStmt *edge)
449
+ {
450
+ return edge->getEdgeKind() == SVFStmt::BinaryOp;
451
+ }
452
+ static inline bool classof(const GenericPAGEdgeTy *edge)
453
+ {
454
+ return edge->getEdgeKind() == SVFStmt::BinaryOp;
455
+ }
456
+ //@}
457
+
458
+ /// constructor
459
+ BinaryOPPE(SVFVar* s, const OPVars& opnds, u32_t oc) : MultiOpndStmt(s,opnds,SVFStmt::BinaryOp), opcode(oc)
460
+ {
461
+ }
462
+
463
+ u32_t getOpcode() const
464
+ {
465
+ return opcode;
466
+ }
467
+
468
+ virtual const std::string toString() const override;
469
+ };
470
+
471
+ /*!
472
+ * Unary instruction edge
473
+ */
474
+ class UnaryOPPE: public SVFStmt
475
+ {
476
+ private:
477
+ UnaryOPPE(); ///< place holder
478
+ UnaryOPPE(const UnaryOPPE &); ///< place holder
479
+ void operator=(const UnaryOPPE &); ///< place holder
480
+ SVFVar* getSrcNode(); ///< place holder, use getOpVar() instead
481
+ SVFVar* getDstNode(); ///< place holder, use getRes() instead
482
+ SVFVar* getSrcID(); ///< place holder, use getOpVarID() instead
483
+ SVFVar* getDstID(); ///< place holder, use getResID() instead
484
+
485
+ u32_t opcode;
486
+ public:
487
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
488
+ //@{
489
+ static inline bool classof(const UnaryOPPE *)
490
+ {
491
+ return true;
492
+ }
493
+ static inline bool classof(const SVFStmt *edge)
494
+ {
495
+ return edge->getEdgeKind() == SVFStmt::UnaryOp;
496
+ }
497
+ static inline bool classof(const GenericPAGEdgeTy *edge)
498
+ {
499
+ return edge->getEdgeKind() == SVFStmt::UnaryOp;
500
+ }
501
+ //@}
502
+
503
+ /// constructor
504
+ UnaryOPPE(SVFVar* s, SVFVar* d, u32_t oc) : SVFStmt(s,d,SVFStmt::UnaryOp), opcode(oc)
505
+ {
506
+ }
507
+
508
+ u32_t getOpcode() const
509
+ {
510
+ return opcode;
511
+ }
512
+ inline const SVFVar* getOpVar() const{
513
+ return SVFStmt::getSrcNode();
514
+ }
515
+ inline const SVFVar* getRes() const{
516
+ return SVFStmt::getDstNode();
517
+ }
518
+ NodeID getOpVarID() const;
519
+ NodeID getResID() const;
520
+
521
+ virtual const std::string toString() const override;
522
+ };
523
+
524
+
525
+ /*!
526
+ * Branch statements including if/else and switch
527
+ */
528
+ class BranchStmt: public SVFStmt
529
+ {
530
+ private:
531
+ BranchStmt(); ///< place holder
532
+ BranchStmt(const BranchStmt &); ///< place holder
533
+ void operator=(const BranchStmt &); ///< place holder
534
+ SVFVar* getSrcNode(); ///< place holder, not allowed
535
+ SVFVar* getDstNode(); ///< place holder, not allowed
536
+ SVFVar* getSrcID(); ///< place holder, not allowed
537
+ SVFVar* getDstID(); ///< place holder, not allowed
538
+
539
+ std::vector<const ICFGNode*> successors;
540
+ const SVFVar* cond;
541
+ const SVFVar* brInst;
542
+ public:
543
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
544
+ //@{
545
+ static inline bool classof(const BranchStmt *)
546
+ {
547
+ return true;
548
+ }
549
+ static inline bool classof(const SVFStmt *edge)
550
+ {
551
+ return edge->getEdgeKind() == SVFStmt::Branch;
552
+ }
553
+ static inline bool classof(const GenericPAGEdgeTy *edge)
554
+ {
555
+ return edge->getEdgeKind() == SVFStmt::Branch;
556
+ }
557
+ //@}
558
+
559
+ /// constructor
560
+ BranchStmt(SVFVar* inst, SVFVar* c, const std::vector<const ICFGNode*>& succs) : SVFStmt(c,inst,SVFStmt::Branch), successors(succs), cond(c), brInst(inst)
561
+ {
562
+ }
563
+
564
+ /// The branch is unconditional if cond is a null value
565
+ bool isUnconditional() const;
566
+ /// The branch is conditional if cond is not a null value
567
+ bool isConditional() const;
568
+ /// Return the condition
569
+ const SVFVar* getCondition() const;
570
+ const SVFVar* getBranchInst() const{
571
+ return brInst;
572
+ }
573
+ /// Successors of this branch statement
574
+ ///@{
575
+ u32_t getNumSuccessors() const{
576
+ return successors.size();
577
+ }
578
+ const std::vector<const ICFGNode*>& getSuccessors() const{
579
+ return successors;
580
+ }
581
+ const ICFGNode* getSuccessor (u32_t i) const{
582
+ return successors.at(i);
583
+ }
584
+ ///@}
585
+ virtual const std::string toString() const override;
586
+ };
587
+
588
+ /*!
589
+ * Store edge
590
+ */
591
+ class StorePE: public SVFStmt
592
+ {
593
+ private:
594
+ StorePE(); ///< place holder
595
+ StorePE(const StorePE &); ///< place holder
596
+ void operator=(const StorePE &); ///< place holder
597
+
598
+ public:
599
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
600
+ //@{
601
+ static inline bool classof(const StorePE *)
602
+ {
603
+ return true;
604
+ }
605
+ static inline bool classof(const SVFStmt *edge)
606
+ {
607
+ return edge->getEdgeKind() == SVFStmt::Store;
608
+ }
609
+ static inline bool classof(const GenericPAGEdgeTy *edge)
610
+ {
611
+ return edge->getEdgeKind() == SVFStmt::Store;
612
+ }
613
+ //@}
614
+
615
+ /// constructor
616
+ StorePE(SVFVar* s, SVFVar* d, const IntraBlockNode* st) :
617
+ SVFStmt(s, d, makeEdgeFlagWithStoreInst(SVFStmt::Store, st))
618
+ {
619
+ }
620
+
621
+ virtual const std::string toString() const override;
622
+ };
623
+
624
+
625
+ /*!
626
+ * Load edge
627
+ */
628
+ class LoadPE: public SVFStmt
629
+ {
630
+ private:
631
+ LoadPE(); ///< place holder
632
+ LoadPE(const LoadPE &); ///< place holder
633
+ void operator=(const LoadPE &); ///< place holder
634
+
635
+ public:
636
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
637
+ //@{
638
+ static inline bool classof(const LoadPE *)
639
+ {
640
+ return true;
641
+ }
642
+ static inline bool classof(const SVFStmt *edge)
643
+ {
644
+ return edge->getEdgeKind() == SVFStmt::Load;
645
+ }
646
+ static inline bool classof(const GenericPAGEdgeTy *edge)
647
+ {
648
+ return edge->getEdgeKind() == SVFStmt::Load;
649
+ }
650
+ //@}
651
+
652
+ /// constructor
653
+ LoadPE(SVFVar* s, SVFVar* d) : SVFStmt(s,d,SVFStmt::Load)
654
+ {
655
+ }
656
+
657
+ virtual const std::string toString() const override;
658
+ };
659
+
660
+
661
+ /*!
662
+ * Gep edge
663
+ */
664
+ class GepPE: public SVFStmt
665
+ {
666
+ private:
667
+ GepPE(); ///< place holder
668
+ GepPE(const GepPE &); ///< place holder
669
+ void operator=(const GepPE &); ///< place holder
670
+
671
+ public:
672
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
673
+ //@{
674
+ static inline bool classof(const GepPE *)
675
+ {
676
+ return true;
677
+ }
678
+ static inline bool classof(const SVFStmt *edge)
679
+ {
680
+ return edge->getEdgeKind() == SVFStmt::NormalGep ||
681
+ edge->getEdgeKind() == SVFStmt::VariantGep;
682
+ }
683
+ static inline bool classof(const GenericPAGEdgeTy *edge)
684
+ {
685
+ return edge->getEdgeKind() == SVFStmt::NormalGep ||
686
+ edge->getEdgeKind() == SVFStmt::VariantGep;
687
+ }
688
+ //@}
689
+
690
+ protected:
691
+ /// constructor
692
+ GepPE(SVFVar* s, SVFVar* d, PEDGEK k) : SVFStmt(s,d,k)
693
+ {
694
+
695
+ }
696
+
697
+ virtual const std::string toString() const;
698
+ };
699
+
700
+
701
+ /*!
702
+ * Gep edge with a fixed offset
703
+ */
704
+ class NormalGepPE : public GepPE
705
+ {
706
+ private:
707
+ NormalGepPE(); ///< place holder
708
+ NormalGepPE(const NormalGepPE&); ///< place holder
709
+ void operator=(const NormalGepPE&); ///< place holder
710
+
711
+ LocationSet ls; ///< location set of the gep edge
712
+
713
+ public:
714
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
715
+ //@{
716
+ static inline bool classof(const NormalGepPE *)
717
+ {
718
+ return true;
719
+ }
720
+ static inline bool classof(const GepPE *edge)
721
+ {
722
+ return edge->getEdgeKind() == SVFStmt::NormalGep;
723
+ }
724
+ static inline bool classof(const SVFStmt *edge)
725
+ {
726
+ return edge->getEdgeKind() == SVFStmt::NormalGep;
727
+ }
728
+ static inline bool classof(const GenericPAGEdgeTy *edge)
729
+ {
730
+ return edge->getEdgeKind() == SVFStmt::NormalGep;
731
+ }
732
+ //@}
733
+
734
+ /// constructor
735
+ NormalGepPE(SVFVar* s, SVFVar* d, const LocationSet& l) : GepPE(s,d,SVFStmt::NormalGep), ls(l)
736
+ {}
737
+
738
+ /// offset of the gep edge
739
+ inline u32_t getOffset() const
740
+ {
741
+ return ls.getOffset();
742
+ }
743
+ inline const LocationSet& getLocationSet() const
744
+ {
745
+ return ls;
746
+ }
747
+
748
+ virtual const std::string toString() const override;
749
+ };
750
+
751
+ /*!
752
+ * Gep edge with a variant offset
753
+ */
754
+ class VariantGepPE : public GepPE
755
+ {
756
+ private:
757
+ VariantGepPE(); ///< place holder
758
+ VariantGepPE(const VariantGepPE&); ///< place holder
759
+ void operator=(const VariantGepPE&); ///< place holder
760
+
761
+ public:
762
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
763
+ //@{
764
+ static inline bool classof(const VariantGepPE *)
765
+ {
766
+ return true;
767
+ }
768
+ static inline bool classof(const GepPE *edge)
769
+ {
770
+ return edge->getEdgeKind() == SVFStmt::VariantGep;
771
+ }
772
+ static inline bool classof(const SVFStmt *edge)
773
+ {
774
+ return edge->getEdgeKind() == SVFStmt::VariantGep;
775
+ }
776
+ static inline bool classof(const GenericPAGEdgeTy *edge)
777
+ {
778
+ return edge->getEdgeKind() == SVFStmt::VariantGep;
779
+ }
780
+ //@}
781
+
782
+ /// constructor
783
+ VariantGepPE(SVFVar* s, SVFVar* d) : GepPE(s,d,SVFStmt::VariantGep) {}
784
+
785
+ virtual const std::string toString() const override;
786
+
787
+ };
788
+
789
+
790
+ /*!
791
+ * Call edge
792
+ */
793
+ class CallPE: public SVFStmt
794
+ {
795
+ private:
796
+ CallPE(); ///< place holder
797
+ CallPE(const CallPE &); ///< place holder
798
+ void operator=(const CallPE &); ///< place holder
799
+
800
+ const CallBlockNode* inst; ///< llvm instruction for this call
801
+ public:
802
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
803
+ //@{
804
+ static inline bool classof(const CallPE *)
805
+ {
806
+ return true;
807
+ }
808
+ static inline bool classof(const SVFStmt *edge)
809
+ {
810
+ return edge->getEdgeKind() == SVFStmt::Call
811
+ || edge->getEdgeKind() == SVFStmt::ThreadFork;
812
+ }
813
+ static inline bool classof(const GenericPAGEdgeTy *edge)
814
+ {
815
+ return edge->getEdgeKind() == SVFStmt::Call
816
+ || edge->getEdgeKind() == SVFStmt::ThreadFork;
817
+ }
818
+ //@}
819
+
820
+ /// constructor
821
+ CallPE(SVFVar* s, SVFVar* d, const CallBlockNode* i, GEdgeKind k = SVFStmt::Call) :
822
+ SVFStmt(s,d,makeEdgeFlagWithCallInst(k,i)), inst(i)
823
+ {
824
+ }
825
+
826
+ /// Get method for the call instruction
827
+ //@{
828
+ inline const CallBlockNode* getCallInst() const
829
+ {
830
+ return inst;
831
+ }
832
+ inline const CallBlockNode* getCallSite() const
833
+ {
834
+ return inst;
835
+ }
836
+ //@}
837
+
838
+ virtual const std::string toString() const override;
839
+ };
840
+
841
+
842
+ /*!
843
+ * Return edge
844
+ */
845
+ class RetPE: public SVFStmt
846
+ {
847
+ private:
848
+ RetPE(); ///< place holder
849
+ RetPE(const RetPE &); ///< place holder
850
+ void operator=(const RetPE &); ///< place holder
851
+
852
+ const CallBlockNode* inst; /// the callsite instruction return to
853
+ public:
854
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
855
+ //@{
856
+ static inline bool classof(const RetPE *)
857
+ {
858
+ return true;
859
+ }
860
+ static inline bool classof(const SVFStmt *edge)
861
+ {
862
+ return edge->getEdgeKind() == SVFStmt::Ret
863
+ || edge->getEdgeKind() == SVFStmt::ThreadJoin;
864
+ }
865
+ static inline bool classof(const GenericPAGEdgeTy *edge)
866
+ {
867
+ return edge->getEdgeKind() == SVFStmt::Ret
868
+ || edge->getEdgeKind() == SVFStmt::ThreadJoin;
869
+ }
870
+ //@}
871
+
872
+ /// constructor
873
+ RetPE(SVFVar* s, SVFVar* d, const CallBlockNode* i, GEdgeKind k = SVFStmt::Ret) :
874
+ SVFStmt(s,d,makeEdgeFlagWithCallInst(k,i)), inst(i)
875
+ {
876
+ }
877
+
878
+ /// Get method for call instruction at caller
879
+ //@{
880
+ inline const CallBlockNode* getCallInst() const
881
+ {
882
+ return inst;
883
+ }
884
+ inline const CallBlockNode* getCallSite() const
885
+ {
886
+ return inst;
887
+ }
888
+ //@}
889
+
890
+ virtual const std::string toString() const override;
891
+ };
892
+
893
+
894
+ /*!
895
+ * Thread Fork Edge
896
+ */
897
+ class TDForkPE: public CallPE
898
+ {
899
+ private:
900
+ TDForkPE(); ///< place holder
901
+ TDForkPE(const TDForkPE &); ///< place holder
902
+ void operator=(const TDForkPE &); ///< place holder
903
+
904
+ public:
905
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
906
+ //@{
907
+ static inline bool classof(const TDForkPE *)
908
+ {
909
+ return true;
910
+ }
911
+ static inline bool classof(const SVFStmt *edge)
912
+ {
913
+ return edge->getEdgeKind() == SVFStmt::ThreadFork;
914
+ }
915
+ static inline bool classof(const GenericPAGEdgeTy *edge)
916
+ {
917
+ return edge->getEdgeKind() == SVFStmt::ThreadFork;
918
+ }
919
+ //@}
920
+
921
+ /// constructor
922
+ TDForkPE(SVFVar* s, SVFVar* d, const CallBlockNode* i) :
923
+ CallPE(s,d,i,SVFStmt::ThreadFork)
924
+ {
925
+ }
926
+
927
+ virtual const std::string toString() const;
928
+ };
929
+
930
+
931
+
932
+ /*!
933
+ * Thread Join Edge
934
+ */
935
+ class TDJoinPE: public RetPE
936
+ {
937
+ private:
938
+ TDJoinPE(); ///< place holder
939
+ TDJoinPE(const TDJoinPE &); ///< place holder
940
+ void operator=(const TDJoinPE &); ///< place holder
941
+
942
+ public:
943
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
944
+ //@{
945
+ static inline bool classof(const TDJoinPE *)
946
+ {
947
+ return true;
948
+ }
949
+ static inline bool classof(const SVFStmt *edge)
950
+ {
951
+ return edge->getEdgeKind() == SVFStmt::ThreadJoin;
952
+ }
953
+ static inline bool classof(const GenericPAGEdgeTy *edge)
954
+ {
955
+ return edge->getEdgeKind() == SVFStmt::ThreadJoin;
956
+ }
957
+ //@}
958
+
959
+ /// Constructor
960
+ TDJoinPE(SVFVar* s, SVFVar* d, const CallBlockNode* i) :
961
+ RetPE(s,d,i,SVFStmt::ThreadJoin)
962
+ {
963
+ }
964
+
965
+ virtual const std::string toString() const;
966
+ };
967
+
968
+ } // End namespace SVF
969
+
970
+ #endif /* PAGEDGE_H_ */