svf-lib 1.0.2113 → 1.0.2114

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 (36) hide show
  1. package/SVF-osx/Release-build/bin/ae +0 -0
  2. package/SVF-osx/Release-build/bin/cfl +0 -0
  3. package/SVF-osx/Release-build/bin/dvf +0 -0
  4. package/SVF-osx/Release-build/bin/llvm2svf +0 -0
  5. package/SVF-osx/Release-build/bin/mta +0 -0
  6. package/SVF-osx/Release-build/bin/saber +0 -0
  7. package/SVF-osx/Release-build/bin/svf-ex +0 -0
  8. package/SVF-osx/Release-build/bin/wpa +0 -0
  9. package/SVF-osx/Release-build/include/Graphs/CDG.h +18 -1
  10. package/SVF-osx/Release-build/include/Graphs/CFLGraph.h +19 -1
  11. package/SVF-osx/Release-build/include/Graphs/CHG.h +19 -1
  12. package/SVF-osx/Release-build/include/Graphs/CallGraph.h +19 -1
  13. package/SVF-osx/Release-build/include/Graphs/ConsGNode.h +19 -1
  14. package/SVF-osx/Release-build/include/Graphs/GenericGraph.h +243 -17
  15. package/SVF-osx/Release-build/include/Graphs/ICFG.h +0 -96
  16. package/SVF-osx/Release-build/include/Graphs/ICFGNode.h +55 -22
  17. package/SVF-osx/Release-build/include/Graphs/SVFG.h +2 -2
  18. package/SVF-osx/Release-build/include/Graphs/SVFGNode.h +5 -17
  19. package/SVF-osx/Release-build/include/Graphs/SVFGOPT.h +2 -1
  20. package/SVF-osx/Release-build/include/Graphs/VFG.h +2 -2
  21. package/SVF-osx/Release-build/include/Graphs/VFGNode.h +99 -26
  22. package/SVF-osx/Release-build/include/MTA/TCT.h +19 -1
  23. package/SVF-osx/Release-build/include/SABER/SaberCondAllocator.h +2 -2
  24. package/SVF-osx/Release-build/include/SVF-LLVM/DCHG.h +1 -1
  25. package/SVF-osx/Release-build/include/SVF-LLVM/ICFGBuilder.h +93 -23
  26. package/SVF-osx/Release-build/include/SVF-LLVM/LLVMModule.h +84 -0
  27. package/SVF-osx/Release-build/include/SVF-LLVM/LLVMUtil.h +15 -0
  28. package/SVF-osx/Release-build/include/SVF-LLVM/SVFIRBuilder.h +19 -12
  29. package/SVF-osx/Release-build/include/SVFIR/SVFFileSystem.h +1 -1
  30. package/SVF-osx/Release-build/include/SVFIR/SVFIR.h +2 -2
  31. package/SVF-osx/Release-build/include/SVFIR/SVFVariables.h +68 -38
  32. package/SVF-osx/Release-build/include/SVFIR/SymbolTableInfo.h +11 -1
  33. package/SVF-osx/Release-build/include/WPA/Andersen.h +1 -1
  34. package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
  35. package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
  36. package/package.json +1 -1
@@ -33,6 +33,7 @@
33
33
  #include "Graphs/ICFG.h"
34
34
  #include "Util/WorkList.h"
35
35
  #include "BasicTypes.h"
36
+ #include "LLVMModule.h"
36
37
 
37
38
  namespace SVF
38
39
  {
@@ -44,6 +45,12 @@ public:
44
45
 
45
46
  typedef std::vector<const Instruction*> InstVec;
46
47
  typedef Set<const Instruction*> BBSet;
48
+ typedef Map<const Instruction*, CallICFGNode *> CSToCallNodeMapTy;
49
+ typedef Map<const Instruction*, RetICFGNode *> CSToRetNodeMapTy;
50
+ typedef Map<const Instruction*, IntraICFGNode *> InstToBlockNodeMapTy;
51
+ typedef Map<const Function*, FunEntryICFGNode *> FunToFunEntryNodeMapTy;
52
+ typedef Map<const Function*, FunExitICFGNode *> FunToFunExitNodeMapTy;
53
+
47
54
 
48
55
  private:
49
56
  ICFG* icfg;
@@ -55,9 +62,42 @@ public:
55
62
  {
56
63
 
57
64
  }
58
- void build(SVFModule* svfModule);
65
+ void build();
59
66
 
60
67
  private:
68
+
69
+ LLVMModuleSet* llvmModuleSet()
70
+ {
71
+ return LLVMModuleSet::getLLVMModuleSet();
72
+ }
73
+
74
+ CSToRetNodeMapTy& csToRetNodeMap()
75
+ {
76
+ return llvmModuleSet()->CSToRetNodeMap;
77
+ }
78
+
79
+ CSToCallNodeMapTy& csToCallNodeMap()
80
+ {
81
+ return llvmModuleSet()->CSToCallNodeMap;
82
+ }
83
+
84
+ InstToBlockNodeMapTy& instToBlockNodeMap()
85
+ {
86
+ return llvmModuleSet()->InstToBlockNodeMap;
87
+ }
88
+
89
+ FunToFunEntryNodeMapTy& funToFunEntryNodeMap()
90
+ {
91
+ return llvmModuleSet()->FunToFunEntryNodeMap;
92
+ }
93
+
94
+ FunToFunExitNodeMapTy& funToFunExitNodeMap()
95
+ {
96
+ return llvmModuleSet()->FunToFunExitNodeMap;
97
+ }
98
+
99
+ private:
100
+
61
101
  /// Create edges between ICFG nodes within a function
62
102
  ///@{
63
103
  void processFunEntry(const Function* fun, WorkList& worklist);
@@ -71,41 +111,71 @@ private:
71
111
 
72
112
  void checkICFGNodesVisited(const Function* fun);
73
113
 
74
- void connectGlobalToProgEntry(SVFModule* svfModule);
114
+ void connectGlobalToProgEntry();
75
115
 
76
- /// Add/Get an inter block ICFGNode
77
- InterICFGNode* addInterBlockICFGNode(const SVFInstruction* inst);
78
116
 
79
- /// Add/Get a basic block ICFGNode
80
- inline ICFGNode* addBlockICFGNode(const SVFInstruction* inst)
117
+ /// Create edges between ICFG nodes across functions
118
+ void addICFGInterEdges(const Instruction* cs, const Function* callee);
119
+
120
+ inline ICFGNode* getICFGNode(const Instruction* inst)
81
121
  {
82
- ICFGNode* node;
83
- if(SVFUtil::isNonInstricCallSite(inst))
84
- node = addInterBlockICFGNode(inst);
85
- else
86
- node = addIntraBlockICFGNode(inst);
87
- const_cast<SVFBasicBlock*>(inst->getParent())->addICFGNode(node);
88
- return node;
122
+ return llvmModuleSet()->getICFGNode(inst);
89
123
  }
90
124
 
91
- /// Create edges between ICFG nodes across functions
92
- void addICFGInterEdges(const SVFInstruction* cs, const SVFFunction* callee);
125
+ inline bool hasICFGNode(const Instruction* inst)
126
+ {
127
+ return llvmModuleSet()->hasICFGNode(inst);
128
+ }
93
129
 
94
- /// Add a call node
95
- inline CallICFGNode* getCallICFGNode(const SVFInstruction* cs)
130
+ /// get a call node
131
+ inline CallICFGNode* getCallICFGNode(const Instruction* cs)
96
132
  {
97
- return icfg->getCallICFGNode(cs);
133
+ return llvmModuleSet()->getCallICFGNode(cs);
98
134
  }
99
- /// Add a return node
100
- inline RetICFGNode* getRetICFGNode(const SVFInstruction* cs)
135
+ /// get a return node
136
+ inline RetICFGNode* getRetICFGNode(const Instruction* cs)
101
137
  {
102
- return icfg->getRetICFGNode(cs);
138
+ return llvmModuleSet()->getRetICFGNode(cs);
139
+ }
140
+ /// get a intra node
141
+ inline IntraICFGNode* getIntraICFGNode(const Instruction* inst)
142
+ {
143
+ return llvmModuleSet()->getIntraICFGNode(inst);
103
144
  }
104
145
 
146
+ /// get a function entry node
147
+ inline FunEntryICFGNode* getFunEntryICFGNode(const Function* fun)
148
+ {
149
+ return llvmModuleSet()->getFunEntryICFGNode(fun);
150
+ }
151
+ /// get a function exit node
152
+ inline FunExitICFGNode* getFunExitICFGNode(const Function* fun)
153
+ {
154
+ return llvmModuleSet()->getFunExitICFGNode(fun);
155
+ }
156
+
157
+ inline GlobalICFGNode* getGlobalICFGNode() const
158
+ {
159
+ return icfg->getGlobalICFGNode();
160
+ }
161
+
162
+ /// Add/Get an inter block ICFGNode
163
+ InterICFGNode* addInterBlockICFGNode(const Instruction* inst);
164
+
165
+ /// Add/Get a basic block ICFGNode
166
+ inline ICFGNode* addBlockICFGNode(const Instruction* inst);
167
+
105
168
  /// Add and get IntraBlock ICFGNode
106
- IntraICFGNode* addIntraBlockICFGNode(const SVFInstruction* inst)
169
+ IntraICFGNode* addIntraBlockICFGNode(const Instruction* inst);
170
+
171
+ FunEntryICFGNode* addFunEntryBlock(const Function* fun);
172
+
173
+ FunExitICFGNode* addFunExitBlock(const Function* fun);
174
+
175
+ inline void addGlobalICFGNode()
107
176
  {
108
- return icfg->addIntraICFGNode(inst);
177
+ icfg->globalBlockNode = new GlobalICFGNode(icfg->totalICFGNode++);
178
+ icfg->addICFGNode(icfg->globalBlockNode);
109
179
  }
110
180
 
111
181
  private:
@@ -44,6 +44,7 @@ class ObjTypeInference;
44
44
  class LLVMModuleSet
45
45
  {
46
46
  friend class SVFIRBuilder;
47
+ friend class ICFGBuilder;
47
48
 
48
49
  public:
49
50
 
@@ -63,6 +64,12 @@ public:
63
64
  typedef Map<const Type*, StInfo*> Type2TypeInfoMap;
64
65
  typedef Map<std::string, std::vector<std::string>> Fun2AnnoMap;
65
66
 
67
+ typedef Map<const Instruction*, CallICFGNode *> CSToCallNodeMapTy;
68
+ typedef Map<const Instruction*, RetICFGNode *> CSToRetNodeMapTy;
69
+ typedef Map<const Instruction*, IntraICFGNode *> InstToBlockNodeMapTy;
70
+ typedef Map<const Function*, FunEntryICFGNode *> FunToFunEntryNodeMapTy;
71
+ typedef Map<const Function*, FunExitICFGNode *> FunToFunExitNodeMapTy;
72
+
66
73
  private:
67
74
  static LLVMModuleSet* llvmModuleSet;
68
75
  static bool preProcessed;
@@ -90,6 +97,12 @@ private:
90
97
  Type2TypeInfoMap Type2TypeInfo;
91
98
  ObjTypeInference* typeInference;
92
99
 
100
+ CSToCallNodeMapTy CSToCallNodeMap; ///< map a callsite to its CallICFGNode
101
+ CSToRetNodeMapTy CSToRetNodeMap; ///< map a callsite to its RetICFGNode
102
+ InstToBlockNodeMapTy InstToBlockNodeMap; ///< map a basic block to its ICFGNode
103
+ FunToFunEntryNodeMapTy FunToFunEntryNodeMap; ///< map a function to its FunExitICFGNode
104
+ FunToFunExitNodeMapTy FunToFunExitNodeMap; ///< map a function to its FunEntryICFGNode
105
+
93
106
  /// Constructor
94
107
  LLVMModuleSet();
95
108
 
@@ -266,6 +279,33 @@ public:
266
279
  return nullptr;
267
280
  }
268
281
 
282
+ ICFGNode* getICFGNode(const Instruction* inst);
283
+
284
+ bool hasICFGNode(const Instruction* inst);
285
+
286
+ /// get a call node
287
+ CallICFGNode* getCallICFGNode(const Instruction* cs);
288
+ /// get a return node
289
+ RetICFGNode* getRetICFGNode(const Instruction* cs);
290
+ /// get a intra node
291
+ IntraICFGNode* getIntraICFGNode(const Instruction* inst);
292
+
293
+ /// Add a function entry node
294
+ inline FunEntryICFGNode* getFunEntryICFGNode(const Function* fun)
295
+ {
296
+ FunEntryICFGNode* b = getFunEntryBlock(fun);
297
+ assert(b && "Function entry not created?");
298
+ return b;
299
+ }
300
+ /// Add a function exit node
301
+ inline FunExitICFGNode* getFunExitICFGNode(const Function* fun)
302
+ {
303
+ FunExitICFGNode* b = getFunExitBlock(fun);
304
+ assert(b && "Function exit not created?");
305
+ return b;
306
+ }
307
+
308
+
269
309
  /// Global to rep
270
310
  bool hasGlobalRep(const GlobalVariable* val) const
271
311
  {
@@ -344,6 +384,50 @@ private:
344
384
  void prePassSchedule();
345
385
  void buildSymbolTable() const;
346
386
  void collectExtFunAnnotations(const Module* mod);
387
+
388
+ /// Get/Add a call node
389
+ inline CallICFGNode* getCallBlock(const Instruction* cs)
390
+ {
391
+ CSToCallNodeMapTy::const_iterator it = CSToCallNodeMap.find(cs);
392
+ if (it == CSToCallNodeMap.end())
393
+ return nullptr;
394
+ return it->second;
395
+ }
396
+
397
+ /// Get/Add a return node
398
+ inline RetICFGNode* getRetBlock(const Instruction* cs)
399
+ {
400
+ CSToRetNodeMapTy::const_iterator it = CSToRetNodeMap.find(cs);
401
+ if (it == CSToRetNodeMap.end())
402
+ return nullptr;
403
+ return it->second;
404
+ }
405
+
406
+ inline IntraICFGNode* getIntraBlock(const Instruction* inst)
407
+ {
408
+ InstToBlockNodeMapTy::const_iterator it = InstToBlockNodeMap.find(inst);
409
+ if (it == InstToBlockNodeMap.end())
410
+ return nullptr;
411
+ return it->second;
412
+ }
413
+
414
+ /// Get/Add a function entry node
415
+ inline FunEntryICFGNode* getFunEntryBlock(const Function* fun)
416
+ {
417
+ FunToFunEntryNodeMapTy::const_iterator it = FunToFunEntryNodeMap.find(fun);
418
+ if (it == FunToFunEntryNodeMap.end())
419
+ return nullptr;
420
+ return it->second;
421
+ }
422
+
423
+ /// Get/Add a function exit node
424
+ inline FunExitICFGNode* getFunExitBlock(const Function* fun)
425
+ {
426
+ FunToFunExitNodeMapTy::const_iterator it = FunToFunExitNodeMap.find(fun);
427
+ if (it == FunToFunExitNodeMap.end())
428
+ return nullptr;
429
+ return it->second;
430
+ }
347
431
  };
348
432
 
349
433
  } // End namespace SVF
@@ -360,6 +360,21 @@ inline bool isHeapAllocExtCall(const Instruction *inst)
360
360
  return isHeapAllocExtCallViaRet(inst) || isHeapAllocExtCallViaArg(inst);
361
361
  }
362
362
 
363
+ /// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
364
+ bool isNonInstricCallSite(const Instruction* inst);
365
+
366
+ /// Get program entry function from module.
367
+ inline const Function* getProgEntryFunction(Module& module)
368
+ {
369
+ for (auto it = module.begin(), eit = module.end(); it != eit; ++it)
370
+ {
371
+ const Function *fun = &(*it);
372
+ if (isProgEntryFunction(fun))
373
+ return (fun);
374
+ }
375
+ return nullptr;
376
+ }
377
+
363
378
  } // End namespace LLVMUtil
364
379
 
365
380
  } // End namespace SVF
@@ -90,14 +90,14 @@ public:
90
90
  processCE(V);
91
91
 
92
92
  // strip off the constant cast and return the value node
93
- SVFValue* svfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(V);
93
+ SVFValue* svfVal = llvmModuleSet()->getSVFValue(V);
94
94
  return pag->getValueNode(svfVal);
95
95
  }
96
96
 
97
97
  /// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
98
98
  inline NodeID getObjectNode(const Value* V)
99
99
  {
100
- SVFValue* svfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(V);
100
+ SVFValue* svfVal = llvmModuleSet()->getSVFValue(V);
101
101
  return pag->getObjectNode(svfVal);
102
102
  }
103
103
 
@@ -240,8 +240,8 @@ protected:
240
240
  /// Set current basic block in order to keep track of control flow information
241
241
  inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
242
242
  {
243
- curBB = (bb == nullptr? nullptr : LLVMModuleSet::getLLVMModuleSet()->getSVFBasicBlock(bb));
244
- curVal = (val == nullptr ? nullptr: LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val));
243
+ curBB = (bb == nullptr? nullptr : llvmModuleSet()->getSVFBasicBlock(bb));
244
+ curVal = (val == nullptr ? nullptr: llvmModuleSet()->getSVFValue(val));
245
245
  }
246
246
  inline void setCurrentLocation(const SVFValue* val, const SVFBasicBlock* bb)
247
247
  {
@@ -270,9 +270,9 @@ protected:
270
270
  /// Add NullPtr PAGNode
271
271
  inline NodeID addNullPtrNode()
272
272
  {
273
- LLVMContext& cxt = LLVMModuleSet::getLLVMModuleSet()->getContext();
273
+ LLVMContext& cxt = llvmModuleSet()->getContext();
274
274
  ConstantPointerNull* constNull = ConstantPointerNull::get(PointerType::getUnqual(cxt));
275
- NodeID nullPtr = pag->addValNode(LLVMModuleSet::getLLVMModuleSet()->getSVFValue(constNull),pag->getNullPtr());
275
+ NodeID nullPtr = pag->addValNode(llvmModuleSet()->getSVFValue(constNull),pag->getNullPtr(), nullptr);
276
276
  setCurrentLocation(constNull, nullptr);
277
277
  addBlackHoleAddrEdge(pag->getBlkPtr());
278
278
  return nullPtr;
@@ -305,7 +305,7 @@ protected:
305
305
  AddrStmt* edge = addAddrEdge(src, dst);
306
306
  if (inst.getArraySize())
307
307
  {
308
- SVFValue* arrSz = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(inst.getArraySize());
308
+ SVFValue* arrSz = llvmModuleSet()->getSVFValue(inst.getArraySize());
309
309
  edge->addArrSize(arrSz);
310
310
  }
311
311
  return edge;
@@ -332,7 +332,7 @@ protected:
332
332
  if (cs->arg_size() > 0)
333
333
  {
334
334
  const llvm::Value* val = cs->getArgOperand(0);
335
- SVFValue* svfval = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val);
335
+ SVFValue* svfval = llvmModuleSet()->getSVFValue(val);
336
336
  edge->addArrSize(svfval);
337
337
  }
338
338
  }
@@ -342,8 +342,8 @@ protected:
342
342
  {
343
343
  if (cs->arg_size() > 1)
344
344
  {
345
- edge->addArrSize(LLVMModuleSet::getLLVMModuleSet()->getSVFValue(cs->getArgOperand(0)));
346
- edge->addArrSize(LLVMModuleSet::getLLVMModuleSet()->getSVFValue(cs->getArgOperand(1)));
345
+ edge->addArrSize(llvmModuleSet()->getSVFValue(cs->getArgOperand(0)));
346
+ edge->addArrSize(llvmModuleSet()->getSVFValue(cs->getArgOperand(1)));
347
347
  }
348
348
  }
349
349
  else
@@ -351,7 +351,7 @@ protected:
351
351
  if (cs->arg_size() > 0)
352
352
  {
353
353
  const llvm::Value* val = cs->getArgOperand(0);
354
- SVFValue* svfval = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val);
354
+ SVFValue* svfval = llvmModuleSet()->getSVFValue(val);
355
355
  edge->addArrSize(svfval);
356
356
  }
357
357
  }
@@ -452,7 +452,8 @@ protected:
452
452
  {
453
453
  ICFGNode* node;
454
454
  if (const SVFInstruction* inst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
455
- node = pag->getICFG()->getICFGNode(inst);
455
+ node = llvmModuleSet()->getICFGNode(
456
+ SVFUtil::cast<Instruction>(llvmModuleSet()->getLLVMValue(inst)));
456
457
  else
457
458
  node = nullptr;
458
459
  if (StoreStmt* edge = pag->addStoreStmt(src, dst, node))
@@ -503,6 +504,12 @@ protected:
503
504
  //@}
504
505
 
505
506
  AccessPath getAccessPathFromBaseNode(NodeID nodeId);
507
+
508
+ private:
509
+ LLVMModuleSet* llvmModuleSet()
510
+ {
511
+ return LLVMModuleSet::getLLVMModuleSet();
512
+ }
506
513
  };
507
514
 
508
515
  } // End namespace SVF
@@ -1064,7 +1064,7 @@ public:
1064
1064
  }
1065
1065
 
1066
1066
  private:
1067
- using GNodeK = GenericNode<int, GenericEdge<void>>::GNodeK;
1067
+ using GNodeK = s32_t;
1068
1068
  using GEdgeFlag = GenericEdge<void>::GEdgeFlag;
1069
1069
  using GEdgeKind = GenericEdge<void>::GEdgeKind;
1070
1070
  static ICFGNode* createICFGNode(NodeID id, GNodeK type);
@@ -531,9 +531,9 @@ private:
531
531
  /// add node into SVFIR
532
532
  //@{
533
533
  /// Add a value (pointer) node
534
- inline NodeID addValNode(const SVFValue* val, NodeID i)
534
+ inline NodeID addValNode(const SVFValue* val, NodeID i, const SVFBaseNode* gNode)
535
535
  {
536
- SVFVar *node = new ValVar(val,i);
536
+ SVFVar *node = new ValVar(val,i, ValVar::ValNode, gNode);
537
537
  return addValNode(val, node, i);
538
538
  }
539
539
  /// Add a memory obj node
@@ -60,19 +60,8 @@ public:
60
60
  /// GepValNode: temporary gep obj node for field sensitivity
61
61
  /// FIObjNode: for field insensitive analysis
62
62
  /// DummyValNode and DummyObjNode: for non-llvm-value node
63
- enum PNODEK
64
- {
65
- ValNode,
66
- ObjNode,
67
- RetNode,
68
- VarargNode,
69
- GepValNode,
70
- GepObjNode,
71
- FIObjNode,
72
- DummyValNode,
73
- DummyObjNode,
74
- };
75
-
63
+ typedef GNodeK PNODEK;
64
+ typedef s64_t GEdgeKind;
76
65
 
77
66
  protected:
78
67
  const SVFValue* value; ///< value of this SVFIR node
@@ -206,19 +195,34 @@ public:
206
195
  }
207
196
  //@}
208
197
 
198
+ static inline bool classof(const SVFVar *)
199
+ {
200
+ return true;
201
+ }
202
+
203
+ static inline bool classof(const GenericPAGNodeTy * node)
204
+ {
205
+ return isSVFVarKind(node->getNodeKind());
206
+ }
207
+
208
+ static inline bool classof(const SVFBaseNode* node)
209
+ {
210
+ return isSVFVarKind(node->getNodeKind());
211
+ }
212
+
209
213
  private:
210
214
  /// add methods of the components
211
215
  //@{
212
216
  inline void addInEdge(SVFStmt* inEdge)
213
217
  {
214
- GNodeK kind = inEdge->getEdgeKind();
218
+ GEdgeKind kind = inEdge->getEdgeKind();
215
219
  InEdgeKindToSetMap[kind].insert(inEdge);
216
220
  addIncomingEdge(inEdge);
217
221
  }
218
222
 
219
223
  inline void addOutEdge(SVFStmt* outEdge)
220
224
  {
221
- GNodeK kind = outEdge->getEdgeKind();
225
+ GEdgeKind kind = outEdge->getEdgeKind();
222
226
  OutEdgeKindToSetMap[kind].insert(outEdge);
223
227
  addOutgoingEdge(outEdge);
224
228
  }
@@ -264,9 +268,11 @@ class ValVar: public SVFVar
264
268
  friend class SVFIRWriter;
265
269
  friend class SVFIRReader;
266
270
 
271
+ private:
272
+ const SVFBaseNode* gNode; // constant, gepValvar, retPN, dummy could be null
267
273
  protected:
268
274
  /// Constructor to create an empty ValVar (for SVFIRReader/deserialization)
269
- ValVar(NodeID i, PNODEK ty = ValNode) : SVFVar(i, ty) {}
275
+ ValVar(NodeID i, PNODEK ty = ValNode) : SVFVar(i, ty), gNode(nullptr) {}
270
276
 
271
277
  public:
272
278
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -277,25 +283,21 @@ public:
277
283
  }
278
284
  static inline bool classof(const SVFVar* node)
279
285
  {
280
- return node->getNodeKind() == SVFVar::ValNode ||
281
- node->getNodeKind() == SVFVar::GepValNode ||
282
- node->getNodeKind() == SVFVar::RetNode ||
283
- node->getNodeKind() == SVFVar::VarargNode ||
284
- node->getNodeKind() == SVFVar::DummyValNode;
286
+ return isValVarKinds(node->getNodeKind());
285
287
  }
286
288
  static inline bool classof(const GenericPAGNodeTy* node)
287
289
  {
288
- return node->getNodeKind() == SVFVar::ValNode ||
289
- node->getNodeKind() == SVFVar::GepValNode ||
290
- node->getNodeKind() == SVFVar::RetNode ||
291
- node->getNodeKind() == SVFVar::VarargNode ||
292
- node->getNodeKind() == SVFVar::DummyValNode;
290
+ return isValVarKinds(node->getNodeKind());
291
+ }
292
+ static inline bool classof(const SVFBaseNode* node)
293
+ {
294
+ return isValVarKinds(node->getNodeKind());
293
295
  }
294
296
  //@}
295
297
 
296
298
  /// Constructor
297
- ValVar(const SVFValue* val, NodeID i, PNODEK ty = ValNode)
298
- : SVFVar(val, i, ty)
299
+ ValVar(const SVFValue* val, NodeID i, PNODEK ty = ValNode, const SVFBaseNode* node = nullptr)
300
+ : SVFVar(val, i, ty), gNode(node)
299
301
  {
300
302
  }
301
303
  /// Return name of a LLVM value
@@ -306,6 +308,11 @@ public:
306
308
  return "";
307
309
  }
308
310
 
311
+ const SVFBaseNode* getGNode() const
312
+ {
313
+ return gNode;
314
+ }
315
+
309
316
  virtual const std::string toString() const;
310
317
  };
311
318
 
@@ -335,17 +342,15 @@ public:
335
342
  }
336
343
  static inline bool classof(const SVFVar* node)
337
344
  {
338
- return node->getNodeKind() == SVFVar::ObjNode ||
339
- node->getNodeKind() == SVFVar::GepObjNode ||
340
- node->getNodeKind() == SVFVar::FIObjNode ||
341
- node->getNodeKind() == SVFVar::DummyObjNode;
345
+ return isObjVarKinds(node->getNodeKind());
342
346
  }
343
347
  static inline bool classof(const GenericPAGNodeTy* node)
344
348
  {
345
- return node->getNodeKind() == SVFVar::ObjNode ||
346
- node->getNodeKind() == SVFVar::GepObjNode ||
347
- node->getNodeKind() == SVFVar::FIObjNode ||
348
- node->getNodeKind() == SVFVar::DummyObjNode;
349
+ return isObjVarKinds(node->getNodeKind());
350
+ }
351
+ static inline bool classof(const SVFBaseNode* node)
352
+ {
353
+ return isObjVarKinds(node->getNodeKind());
349
354
  }
350
355
  //@}
351
356
 
@@ -477,6 +482,10 @@ public:
477
482
  {
478
483
  return node->getNodeKind() == SVFVar::GepObjNode;
479
484
  }
485
+ static inline bool classof(const SVFBaseNode* node)
486
+ {
487
+ return node->getNodeKind() == SVFVar::GepObjNode;
488
+ }
480
489
  //@}
481
490
 
482
491
  /// Constructor
@@ -494,9 +503,9 @@ public:
494
503
  }
495
504
 
496
505
  /// Set the base object from which this GEP node came from.
497
- inline void setBaseNode(NodeID base)
506
+ inline void setBaseNode(NodeID bs)
498
507
  {
499
- this->base = base;
508
+ this->base = bs;
500
509
  }
501
510
 
502
511
  /// Return the base object from which this GEP node came from.
@@ -554,6 +563,10 @@ public:
554
563
  {
555
564
  return node->getNodeKind() == SVFVar::FIObjNode;
556
565
  }
566
+ static inline bool classof(const SVFBaseNode* node)
567
+ {
568
+ return node->getNodeKind() == SVFVar::FIObjNode;
569
+ }
557
570
  //@}
558
571
 
559
572
  /// Constructor
@@ -604,6 +617,10 @@ public:
604
617
  {
605
618
  return node->getNodeKind() == SVFVar::RetNode;
606
619
  }
620
+ static inline bool classof(const SVFBaseNode* node)
621
+ {
622
+ return node->getNodeKind() == SVFVar::RetNode;
623
+ }
607
624
  //@}
608
625
 
609
626
  /// Constructor
@@ -648,6 +665,10 @@ public:
648
665
  {
649
666
  return node->getNodeKind() == SVFVar::VarargNode;
650
667
  }
668
+ static inline bool classof(const SVFBaseNode* node)
669
+ {
670
+ return node->getNodeKind() == SVFVar::VarargNode;
671
+ }
651
672
  //@}
652
673
 
653
674
  /// Constructor
@@ -688,6 +709,10 @@ public:
688
709
  {
689
710
  return node->getNodeKind() == SVFVar::DummyValNode;
690
711
  }
712
+ static inline bool classof(const SVFBaseNode* node)
713
+ {
714
+ return node->getNodeKind() == SVFVar::DummyValNode;
715
+ }
691
716
  //@}
692
717
 
693
718
  /// Constructor
@@ -732,6 +757,11 @@ public:
732
757
  {
733
758
  return node->getNodeKind() == SVFVar::DummyObjNode;
734
759
  }
760
+
761
+ static inline bool classof(const SVFBaseNode* node)
762
+ {
763
+ return node->getNodeKind() == SVFVar::DummyObjNode;
764
+ }
735
765
  //@}
736
766
 
737
767
  /// Constructor
@@ -373,6 +373,7 @@ protected:
373
373
  Set<const StInfo*> stInfos;
374
374
  };
375
375
 
376
+ class SVFBaseNode;
376
377
 
377
378
  /*!
378
379
  * Memory object symbols or MemObj (address-taken variables in LLVM-based languages)
@@ -381,6 +382,7 @@ class MemObj
381
382
  {
382
383
  friend class SVFIRWriter;
383
384
  friend class SVFIRReader;
385
+ friend class SVFIRBuilder;
384
386
 
385
387
  private:
386
388
  /// Type information of this object
@@ -390,9 +392,11 @@ private:
390
392
  /// The unique id to represent this symbol
391
393
  SymID symId;
392
394
 
395
+ const SVFBaseNode* gNode;
396
+
393
397
  public:
394
398
  /// Constructor
395
- MemObj(SymID id, ObjTypeInfo* ti, const SVFValue* val = nullptr);
399
+ MemObj(SymID id, ObjTypeInfo* ti, const SVFValue* val = nullptr, const SVFBaseNode* node = nullptr);
396
400
 
397
401
  /// Destructor
398
402
  virtual ~MemObj()
@@ -408,6 +412,12 @@ public:
408
412
  return refVal;
409
413
  }
410
414
 
415
+ /// Get the reference value to this object
416
+ inline const SVFBaseNode* getGNode() const
417
+ {
418
+ return gNode;
419
+ }
420
+
411
421
  /// Get the memory object id
412
422
  inline SymID getId() const
413
423
  {
@@ -137,7 +137,7 @@ public:
137
137
  //@}
138
138
 
139
139
  /// Add copy edge on constraint graph
140
- virtual inline bool addCopyEdge(NodeID src, NodeID dst) = 0;
140
+ virtual bool addCopyEdge(NodeID src, NodeID dst) = 0;
141
141
 
142
142
  /// dump statistics
143
143
  inline void printStat()