svf-tools 1.0.994 → 1.0.996

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 (69) hide show
  1. package/package.json +1 -1
  2. package/svf/include/Graphs/CDG.h +19 -2
  3. package/svf/include/Graphs/CFLGraph.h +19 -1
  4. package/svf/include/Graphs/CHG.h +29 -9
  5. package/svf/include/Graphs/CallGraph.h +19 -1
  6. package/svf/include/Graphs/ConsGNode.h +19 -1
  7. package/svf/include/Graphs/GenericGraph.h +264 -17
  8. package/svf/include/Graphs/ICFG.h +0 -96
  9. package/svf/include/Graphs/ICFGNode.h +88 -80
  10. package/svf/include/Graphs/SVFG.h +2 -2
  11. package/svf/include/Graphs/SVFGNode.h +5 -17
  12. package/svf/include/Graphs/SVFGOPT.h +2 -1
  13. package/svf/include/Graphs/VFG.h +2 -2
  14. package/svf/include/Graphs/VFGNode.h +99 -26
  15. package/svf/include/MSSA/MSSAMuChi.h +2 -2
  16. package/svf/include/MTA/LockAnalysis.h +2 -2
  17. package/svf/include/MTA/MHP.h +3 -3
  18. package/svf/include/MTA/TCT.h +19 -1
  19. package/svf/include/SABER/SaberCondAllocator.h +2 -2
  20. package/svf/include/SVFIR/SVFFileSystem.h +1 -1
  21. package/svf/include/SVFIR/SVFIR.h +2 -2
  22. package/svf/include/SVFIR/SVFVariables.h +68 -38
  23. package/svf/include/SVFIR/SymbolTableInfo.h +11 -1
  24. package/svf/include/Util/SVFUtil.h +1 -8
  25. package/svf/include/Util/ThreadAPI.h +6 -6
  26. package/svf/include/WPA/Andersen.h +1 -1
  27. package/svf/lib/AE/Svfexe/AEDetector.cpp +18 -22
  28. package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +58 -56
  29. package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +2 -0
  30. package/svf/lib/CFL/CFLAlias.cpp +1 -1
  31. package/svf/lib/DDA/ContextDDA.cpp +12 -8
  32. package/svf/lib/DDA/DDAClient.cpp +2 -2
  33. package/svf/lib/Graphs/CHG.cpp +17 -17
  34. package/svf/lib/Graphs/CallGraph.cpp +2 -1
  35. package/svf/lib/Graphs/ICFG.cpp +18 -102
  36. package/svf/lib/Graphs/SVFG.cpp +7 -7
  37. package/svf/lib/Graphs/ThreadCallGraph.cpp +8 -8
  38. package/svf/lib/Graphs/VFG.cpp +4 -6
  39. package/svf/lib/MSSA/MemRegion.cpp +2 -2
  40. package/svf/lib/MTA/MTAStat.cpp +1 -1
  41. package/svf/lib/MTA/TCT.cpp +3 -3
  42. package/svf/lib/MemoryModel/PointerAnalysis.cpp +11 -11
  43. package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +1 -1
  44. package/svf/lib/SABER/DoubleFreeChecker.cpp +8 -8
  45. package/svf/lib/SABER/LeakChecker.cpp +11 -12
  46. package/svf/lib/SABER/SaberCondAllocator.cpp +13 -16
  47. package/svf/lib/SABER/SaberSVFGBuilder.cpp +2 -2
  48. package/svf/lib/SVFIR/SVFFileSystem.cpp +8 -14
  49. package/svf/lib/SVFIR/SVFVariables.cpp +3 -0
  50. package/svf/lib/SVFIR/SymbolTableInfo.cpp +3 -2
  51. package/svf/lib/Util/CallGraphBuilder.cpp +2 -1
  52. package/svf/lib/Util/SVFUtil.cpp +10 -3
  53. package/svf/lib/Util/ThreadAPI.cpp +14 -16
  54. package/svf/lib/WPA/Andersen.cpp +1 -1
  55. package/svf-llvm/include/SVF-LLVM/CHGBuilder.h +5 -0
  56. package/svf-llvm/include/SVF-LLVM/DCHG.h +3 -3
  57. package/svf-llvm/include/SVF-LLVM/ICFGBuilder.h +93 -23
  58. package/svf-llvm/include/SVF-LLVM/LLVMModule.h +94 -0
  59. package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +15 -0
  60. package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +19 -12
  61. package/svf-llvm/lib/CHGBuilder.cpp +23 -17
  62. package/svf-llvm/lib/DCHG.cpp +18 -18
  63. package/svf-llvm/lib/ICFGBuilder.cpp +132 -54
  64. package/svf-llvm/lib/LLVMLoopAnalysis.cpp +6 -11
  65. package/svf-llvm/lib/LLVMModule.cpp +60 -0
  66. package/svf-llvm/lib/LLVMUtil.cpp +32 -0
  67. package/svf-llvm/lib/SVFIRBuilder.cpp +93 -77
  68. package/svf-llvm/lib/SVFIRExtAPI.cpp +3 -3
  69. package/svf-llvm/lib/SymbolTableBuilder.cpp +6 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.994",
3
+ "version": "1.0.996",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -96,7 +96,7 @@ public:
96
96
 
97
97
  public:
98
98
  /// Constructor
99
- CDGNode(const ICFGNode *icfgNode) : GenericCDGNodeTy(icfgNode->getId(), 0), _icfgNode(icfgNode)
99
+ CDGNode(const ICFGNode *icfgNode) : GenericCDGNodeTy(icfgNode->getId(), CDNodeKd), _icfgNode(icfgNode)
100
100
  {
101
101
 
102
102
  }
@@ -114,6 +114,23 @@ public:
114
114
  return _icfgNode;
115
115
  }
116
116
 
117
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
118
+ //@{
119
+ static inline bool classof(const CDGNode *)
120
+ {
121
+ return true;
122
+ }
123
+
124
+ static inline bool classof(const GenericICFGNodeTy* node)
125
+ {
126
+ return node->getNodeKind() == CDNodeKd;
127
+ }
128
+
129
+ static inline bool classof(const SVFBaseNode* node)
130
+ {
131
+ return node->getNodeKind() == CDNodeKd;
132
+ }
133
+ //@}
117
134
 
118
135
  private:
119
136
  const ICFGNode *_icfgNode;
@@ -354,7 +371,7 @@ struct DOTGraphTraits<SVF::CDG *> : public DOTGraphTraits<SVF::PAG *>
354
371
  SVF::PAG::SVFStmtList &edges = SVF::PAG::getPAG()->getPTASVFStmtList(bNode);
355
372
  if (edges.empty())
356
373
  {
357
- rawstr << bNode->getInst()->toString() << " \t";
374
+ rawstr << (bNode)->toString() << " \t";
358
375
  }
359
376
  else
360
377
  {
@@ -76,7 +76,7 @@ typedef GenericNode<CFLNode,CFLEdge> GenericCFLNodeTy;
76
76
  class CFLNode: public GenericCFLNodeTy
77
77
  {
78
78
  public:
79
- CFLNode (NodeID i = 0, GNodeK k = 0):
79
+ CFLNode (NodeID i = 0, GNodeK k = CFLNodeKd):
80
80
  GenericCFLNodeTy(i, k)
81
81
  {
82
82
  }
@@ -148,6 +148,24 @@ public:
148
148
 
149
149
  return num1 && num2;
150
150
  }
151
+
152
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
153
+ //@{
154
+ static inline bool classof(const CFLNode *)
155
+ {
156
+ return true;
157
+ }
158
+
159
+ static inline bool classof(const GenericICFGNodeTy* node)
160
+ {
161
+ return node->getNodeKind() == CFLNodeKd;
162
+ }
163
+
164
+ static inline bool classof(const SVFBaseNode* node)
165
+ {
166
+ return node->getNodeKind() == CFLNodeKd;
167
+ }
168
+ //@}
151
169
  };
152
170
 
153
171
  /// Edge-labeled graph for CFL Reachability analysis
@@ -61,7 +61,7 @@ public:
61
61
  virtual const VFunSet &getCSVFsBasedonCHA(const CallICFGNode* cs) = 0;
62
62
  virtual bool csHasVtblsBasedonCHA(const CallICFGNode* cs) = 0;
63
63
  virtual const VTableSet &getCSVtblsBasedonCHA(const CallICFGNode* cs) = 0;
64
- virtual void getVFnsFromVtbls(const SVFCallInst* cs, const VTableSet& vtbls,
64
+ virtual void getVFnsFromVtbls(const CallICFGNode* cs, const VTableSet& vtbls,
65
65
  VFunSet& virtualFunctions) = 0;
66
66
 
67
67
  CHGKind getKind(void) const
@@ -120,7 +120,7 @@ public:
120
120
 
121
121
  typedef std::vector<const SVFFunction*> FuncVector;
122
122
 
123
- CHNode (const std::string& name, NodeID i = 0, GNodeK k = 0):
123
+ CHNode (const std::string& name, NodeID i = 0, GNodeK k = CHNodeKd):
124
124
  GenericCHNodeTy(i, k), vtable(nullptr), className(name), flags(0)
125
125
  {
126
126
  }
@@ -191,6 +191,24 @@ public:
191
191
  vtable = vtbl;
192
192
  }
193
193
 
194
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
195
+ //@{
196
+ static inline bool classof(const CHNode *)
197
+ {
198
+ return true;
199
+ }
200
+
201
+ static inline bool classof(const GenericCHNodeTy * node)
202
+ {
203
+ return node->getNodeKind() == CHNodeKd;
204
+ }
205
+
206
+ static inline bool classof(const SVFBaseNode* node)
207
+ {
208
+ return node->getNodeKind() == CHNodeKd;
209
+ }
210
+ //@}
211
+
194
212
  private:
195
213
  const SVFGlobalValue* vtable;
196
214
  std::string className;
@@ -222,9 +240,10 @@ public:
222
240
  typedef Set<const CHNode*> CHNodeSetTy;
223
241
  typedef FIFOWorkList<const CHNode*> WorkList;
224
242
  typedef Map<std::string, CHNodeSetTy> NameToCHNodesMap;
225
- typedef Map<const SVFInstruction*, CHNodeSetTy> CallSiteToCHNodesMap;
226
- typedef Map<const SVFInstruction*, VTableSet> CallSiteToVTableSetMap;
227
- typedef Map<const SVFInstruction*, VFunSet> CallSiteToVFunSetMap;
243
+
244
+ typedef Map<const ICFGNode*, CHNodeSetTy> CallNodeToCHNodesMap;
245
+ typedef Map<const ICFGNode*, VTableSet> CallNodeToVTableSetMap;
246
+ typedef Map<const ICFGNode*, VFunSet> CallNodeToVFunSetMap;
228
247
 
229
248
  typedef enum
230
249
  {
@@ -242,7 +261,7 @@ public:
242
261
  const std::string baseClassName,
243
262
  CHEdge::CHEDGETYPE edgeType);
244
263
  CHNode *getNode(const std::string name) const;
245
- void getVFnsFromVtbls(const SVFCallInst* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
264
+ void getVFnsFromVtbls(const CallICFGNode* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
246
265
  void dump(const std::string& filename);
247
266
  void view();
248
267
  void printCH();
@@ -307,11 +326,12 @@ private:
307
326
  NameToCHNodesMap classNameToAncestorsMap;
308
327
  NameToCHNodesMap classNameToInstAndDescsMap;
309
328
  NameToCHNodesMap templateNameToInstancesMap;
310
- CallSiteToCHNodesMap csToClassesMap;
329
+ CallNodeToCHNodesMap callNodeToClassesMap;
311
330
 
312
331
  Map<const SVFFunction*, u32_t> virtualFunctionToIDMap;
313
- CallSiteToVTableSetMap csToCHAVtblsMap;
314
- CallSiteToVFunSetMap csToCHAVFnsMap;
332
+
333
+ CallNodeToVTableSetMap callNodeToCHAVtblsMap;
334
+ CallNodeToVFunSetMap callNodeToCHAVFnsMap;
315
335
  };
316
336
 
317
337
  } // End namespace SVF
@@ -184,7 +184,7 @@ private:
184
184
 
185
185
  public:
186
186
  /// Constructor
187
- CallGraphNode(NodeID i, const SVFFunction* f) : GenericCallGraphNodeTy(i,0), fun(f)
187
+ CallGraphNode(NodeID i, const SVFFunction* f) : GenericCallGraphNodeTy(i,CallNodeKd), fun(f)
188
188
  {
189
189
 
190
190
  }
@@ -209,6 +209,24 @@ public:
209
209
  //@}
210
210
 
211
211
  virtual const std::string toString() const;
212
+
213
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
214
+ //@{
215
+ static inline bool classof(const CallGraphNode *)
216
+ {
217
+ return true;
218
+ }
219
+
220
+ static inline bool classof(const GenericICFGNodeTy* node)
221
+ {
222
+ return node->getNodeKind() == CallNodeKd;
223
+ }
224
+
225
+ static inline bool classof(const SVFBaseNode* node)
226
+ {
227
+ return node->getNodeKind() == CallNodeKd;
228
+ }
229
+ //@}
212
230
  };
213
231
 
214
232
  /*!
@@ -71,7 +71,7 @@ public:
71
71
  NodeBS strides;
72
72
  NodeBS baseIds;
73
73
 
74
- ConstraintNode(NodeID i) : GenericConsNodeTy(i, 0), _isPWCNode(false)
74
+ ConstraintNode(NodeID i) : GenericConsNodeTy(i, ConstraintNodeKd), _isPWCNode(false)
75
75
  {
76
76
 
77
77
  }
@@ -393,6 +393,24 @@ public:
393
393
  return o;
394
394
  }
395
395
  //@}
396
+
397
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
398
+ //@{
399
+ static inline bool classof(const ConstraintNode *)
400
+ {
401
+ return true;
402
+ }
403
+
404
+ static inline bool classof(const GenericICFGNodeTy* node)
405
+ {
406
+ return node->getNodeKind() == ConstraintNodeKd;
407
+ }
408
+
409
+ static inline bool classof(const SVFBaseNode* node)
410
+ {
411
+ return node->getNodeKind() == ConstraintNodeKd;
412
+ }
413
+ //@}
396
414
  };
397
415
 
398
416
  } // End namespace SVF
@@ -134,11 +134,263 @@ protected:
134
134
  };
135
135
 
136
136
 
137
+ class SVFBaseNode
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
146
+ IntraBlock,
147
+ // │ └── Represents a global-level block
148
+ GlobalBlock,
149
+ // │ └─ InterICFGNodeKinds: Types of inter-procedural control flow graph nodes
150
+ // │ ├── Entry point of a function
151
+ FunEntryBlock,
152
+ // │ ├── Exit point of a function
153
+ FunExitBlock,
154
+ // │ ├── Call site in the function
155
+ FunCallBlock,
156
+ // │ └── Return site in the function
157
+ FunRetBlock,
158
+ // └────────
159
+
160
+ // ┌── SVFVarKinds: Combines ValVarKinds and ObjVarKinds for variable nodes
161
+ // │ ┌── ValVarKinds: Types of value variable nodes
162
+ // │ │ ├── Represents a standard value variable
163
+ ValNode,
164
+ // │ │ ├── Represents a GEP value variable
165
+ GepValNode,
166
+ // │ │ ├── Represents a return value node
167
+ RetNode,
168
+ // │ │ ├── Represents a variadic argument node
169
+ VarargNode,
170
+ // │ │ └── Dummy node for uninitialized values
171
+ DummyValNode,
172
+ // │ └── ObjVarKinds: Types of object variable nodes
173
+ // │ ├── Represents an object variable
174
+ ObjNode,
175
+ // │ ├── GepObjNode: Represents a GEP object variable
176
+ GepObjNode,
177
+ // │ ├── FIObjNode: Represents a flow-insensitive object node
178
+ FIObjNode,
179
+ // │ └── DummyObjNode: Dummy node for uninitialized objects
180
+ DummyObjNode,
181
+ // └────────
182
+
183
+ // ┌── VFGNodeKinds: Various Value Flow Graph (VFG) node kinds with operations
184
+ // │ ├── Represents a comparison operation
185
+ Cmp,
186
+ // │ ├── Represents a binary operation
187
+ BinaryOp,
188
+ // │ ├── Represents a unary operation
189
+ UnaryOp,
190
+ // │ ├── Represents a branch operation
191
+ Branch,
192
+ // │ ├── Dummy node for value propagation
193
+ DummyVProp,
194
+ // │ └── Represents a null pointer operation
195
+ NPtr,
196
+ // │ └── ArgumentVFGNodeKinds: Types of argument nodes in VFG
197
+ // │ ├── Represents a function return value
198
+ FRet,
199
+ // │ ├── Represents an argument return value
200
+ ARet,
201
+ // │ ├── Represents an argument parameter
202
+ AParm,
203
+ // │ └── FParm: Represents a function parameter
204
+ FParm,
205
+ // │ └── StmtVFGNodeKinds: Types of statement nodes in VFG
206
+ // │ ├── Represents an address operation
207
+ Addr,
208
+ // │ ├── Represents a copy operation
209
+ Copy,
210
+ // │ ├── Represents a GEP operation
211
+ Gep,
212
+ // │ ├── Represents a store operation
213
+ Store,
214
+ // │ └── Represents a load operation
215
+ Load,
216
+ // │ └── PHIVFGNodeKinds: Types of PHI nodes in VFG
217
+ // │ ├── Represents a type-based PHI node
218
+ TPhi,
219
+ // │ ├── Represents an intra-procedural PHI node
220
+ TIntraPhi,
221
+ // │ └── Represents an inter-procedural PHI node
222
+ TInterPhi,
223
+ // │ └── MRSVFGNodeKinds: Memory-related SVFG nodes
224
+ // │ ├── Function parameter input
225
+ FPIN,
226
+ // │ ├── Function parameter output
227
+ FPOUT,
228
+ // │ ├── Argument parameter input
229
+ APIN,
230
+ // │ └── Argument parameter output
231
+ APOUT,
232
+ // │ └── MSSAPHISVFGNodeKinds: Mem SSA PHI nodes for SVFG
233
+ // │ ├── Memory PHI node
234
+ MPhi,
235
+ // │ ├── Intra-procedural memory PHI node
236
+ MIntraPhi,
237
+ // │ └── MInterPhi: Inter-procedural memory PHI node
238
+ MInterPhi,
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
+
259
+ /// Get ID
260
+ inline NodeID getId() const
261
+ {
262
+ return id;
263
+ }
264
+
265
+ /// Get node kind
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
+ virtual const std::string toString() const;
287
+
288
+
289
+ protected:
290
+ NodeID id; ///< Node ID
291
+ GNodeK nodeKind; ///< Node kind
292
+ const SVFType* type; ///< SVF type
293
+
294
+ std::string sourceLoc; ///< Source code information of this value
295
+
296
+ /// Helper functions to check node kinds
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
+ }
386
+ //@}
387
+ };
388
+
137
389
  /*!
138
390
  * Generic node on the graph as base class
139
391
  */
140
392
  template<class NodeTy,class EdgeTy>
141
- class GenericNode
393
+ class GenericNode: public SVFBaseNode
142
394
  {
143
395
  friend class SVFIRWriter;
144
396
  friend class SVFIRReader;
@@ -147,7 +399,6 @@ public:
147
399
  typedef NodeTy NodeType;
148
400
  typedef EdgeTy EdgeType;
149
401
  /// Edge kind
150
- typedef s64_t GNodeK;
151
402
  typedef OrderedSet<EdgeType*, typename EdgeType::equalGEdge> GEdgeSetTy;
152
403
  /// Edge iterator
153
404
  ///@{
@@ -156,15 +407,13 @@ public:
156
407
  ///@}
157
408
 
158
409
  private:
159
- NodeID id; ///< Node ID
160
- GNodeK nodeKind; ///< Node kind
161
410
 
162
411
  GEdgeSetTy InEdges; ///< all incoming edge of this node
163
412
  GEdgeSetTy OutEdges; ///< all outgoing edge of this node
164
413
 
165
414
  public:
166
415
  /// Constructor
167
- GenericNode(NodeID i, GNodeK k): id(i),nodeKind(k)
416
+ GenericNode(NodeID i, GNodeK k): SVFBaseNode(i, k)
168
417
  {
169
418
 
170
419
  }
@@ -176,18 +425,6 @@ public:
176
425
  delete edge;
177
426
  }
178
427
 
179
- /// Get ID
180
- inline NodeID getId() const
181
- {
182
- return id;
183
- }
184
-
185
- /// Get node kind
186
- inline GNodeK getNodeKind() const
187
- {
188
- return nodeKind;
189
- }
190
-
191
428
  /// Get incoming/outgoing edge set
192
429
  ///@{
193
430
  inline const GEdgeSetTy& getOutEdges() const
@@ -334,6 +571,16 @@ public:
334
571
  return nullptr;
335
572
  }
336
573
  //@}
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
+ }
337
584
  };
338
585
 
339
586
  /*