svf-lib 1.0.2115 → 1.0.2116

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -371,7 +371,7 @@ struct DOTGraphTraits<SVF::CDG *> : public DOTGraphTraits<SVF::PAG *>
371
371
  SVF::PAG::SVFStmtList &edges = SVF::PAG::getPAG()->getPTASVFStmtList(bNode);
372
372
  if (edges.empty())
373
373
  {
374
- rawstr << bNode->getInst()->toString() << " \t";
374
+ rawstr << (bNode)->toString() << " \t";
375
375
  }
376
376
  else
377
377
  {
@@ -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
@@ -240,9 +240,10 @@ public:
240
240
  typedef Set<const CHNode*> CHNodeSetTy;
241
241
  typedef FIFOWorkList<const CHNode*> WorkList;
242
242
  typedef Map<std::string, CHNodeSetTy> NameToCHNodesMap;
243
- typedef Map<const SVFInstruction*, CHNodeSetTy> CallSiteToCHNodesMap;
244
- typedef Map<const SVFInstruction*, VTableSet> CallSiteToVTableSetMap;
245
- 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;
246
247
 
247
248
  typedef enum
248
249
  {
@@ -260,7 +261,7 @@ public:
260
261
  const std::string baseClassName,
261
262
  CHEdge::CHEDGETYPE edgeType);
262
263
  CHNode *getNode(const std::string name) const;
263
- void getVFnsFromVtbls(const SVFCallInst* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
264
+ void getVFnsFromVtbls(const CallICFGNode* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
264
265
  void dump(const std::string& filename);
265
266
  void view();
266
267
  void printCH();
@@ -325,11 +326,12 @@ private:
325
326
  NameToCHNodesMap classNameToAncestorsMap;
326
327
  NameToCHNodesMap classNameToInstAndDescsMap;
327
328
  NameToCHNodesMap templateNameToInstancesMap;
328
- CallSiteToCHNodesMap csToClassesMap;
329
+ CallNodeToCHNodesMap callNodeToClassesMap;
329
330
 
330
331
  Map<const SVFFunction*, u32_t> virtualFunctionToIDMap;
331
- CallSiteToVTableSetMap csToCHAVtblsMap;
332
- CallSiteToVFunSetMap csToCHAVFnsMap;
332
+
333
+ CallNodeToVTableSetMap callNodeToCHAVtblsMap;
334
+ CallNodeToVFunSetMap callNodeToCHAVFnsMap;
333
335
  };
334
336
 
335
337
  } // End namespace SVF
@@ -251,7 +251,7 @@ public:
251
251
 
252
252
 
253
253
 
254
- SVFBaseNode(NodeID i, GNodeK k): id(i), nodeKind(k)
254
+ SVFBaseNode(NodeID i, GNodeK k, SVFType* ty = nullptr): id(i),nodeKind(k), type(ty)
255
255
  {
256
256
 
257
257
  }
@@ -268,9 +268,30 @@ public:
268
268
  return nodeKind;
269
269
  }
270
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
+
271
289
  protected:
272
290
  NodeID id; ///< Node ID
273
291
  GNodeK nodeKind; ///< Node kind
292
+ const SVFType* type; ///< SVF type
293
+
294
+ std::string sourceLoc; ///< Source code information of this value
274
295
 
275
296
  /// Helper functions to check node kinds
276
297
  //{@ Check node kind
@@ -122,7 +122,7 @@ public:
122
122
 
123
123
  virtual const std::string toString() const;
124
124
 
125
- virtual const std::string getSourceLoc() const = 0;
125
+
126
126
 
127
127
  void dump() const;
128
128
 
@@ -142,6 +142,8 @@ public:
142
142
  return isICFGNodeKinds(node->getNodeKind());
143
143
  }
144
144
 
145
+
146
+
145
147
  protected:
146
148
  const SVFFunction* fun;
147
149
  const SVFBasicBlock* bb;
@@ -179,9 +181,9 @@ public:
179
181
  }
180
182
  //@}
181
183
 
182
- virtual const std::string toString() const;
184
+ const std::string toString() const override;
183
185
 
184
- virtual const std::string getSourceLoc() const
186
+ const std::string getSourceLoc() const override
185
187
  {
186
188
  return "Global ICFGNode";
187
189
  }
@@ -195,21 +197,16 @@ class IntraICFGNode : public ICFGNode
195
197
  friend class SVFIRWriter;
196
198
  friend class SVFIRReader;
197
199
  private:
198
- const SVFInstruction *inst;
200
+ bool isRet;
199
201
 
200
202
  /// Constructor to create empty IntraICFGNode (for SVFIRReader/deserialization)
201
- IntraICFGNode(NodeID id) : ICFGNode(id, IntraBlock), inst(nullptr) {}
203
+ IntraICFGNode(NodeID id) : ICFGNode(id, IntraBlock), isRet(false) {}
202
204
 
203
205
  public:
204
- IntraICFGNode(NodeID id, const SVFInstruction *i) : ICFGNode(id, IntraBlock), inst(i)
206
+ IntraICFGNode(NodeID id, const SVFBasicBlock* b, bool isReturn) : ICFGNode(id, IntraBlock), isRet(isReturn)
205
207
  {
206
- fun = inst->getFunction();
207
- bb = inst->getParent();
208
- }
209
-
210
- inline const SVFInstruction *getInst() const
211
- {
212
- return inst;
208
+ fun = b->getFunction();
209
+ bb = b;
213
210
  }
214
211
 
215
212
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -230,11 +227,11 @@ public:
230
227
  }
231
228
  //@}
232
229
 
233
- const std::string toString() const;
230
+ const std::string toString() const override;
234
231
 
235
- virtual const std::string getSourceLoc() const
232
+ inline bool isRetInst() const
236
233
  {
237
- return inst->getSourceLoc();
234
+ return isRet;
238
235
  }
239
236
  };
240
237
 
@@ -270,7 +267,6 @@ public:
270
267
  }
271
268
 
272
269
  //@}
273
- virtual const std::string getSourceLoc() const = 0;
274
270
  };
275
271
 
276
272
 
@@ -296,7 +292,7 @@ public:
296
292
  FunEntryICFGNode(NodeID id, const SVFFunction* f);
297
293
 
298
294
  /// Return function
299
- inline const SVFFunction* getFun() const
295
+ inline const SVFFunction* getFun() const override
300
296
  {
301
297
  return fun;
302
298
  }
@@ -341,9 +337,9 @@ public:
341
337
  }
342
338
  //@}
343
339
 
344
- const virtual std::string toString() const;
340
+ const std::string toString() const override;
345
341
 
346
- virtual const std::string getSourceLoc() const
342
+ const std::string getSourceLoc() const override
347
343
  {
348
344
  return "function entry: " + fun->getSourceLoc();
349
345
  }
@@ -367,7 +363,7 @@ public:
367
363
  FunExitICFGNode(NodeID id, const SVFFunction* f);
368
364
 
369
365
  /// Return function
370
- inline const SVFFunction* getFun() const
366
+ inline const SVFFunction* getFun() const override
371
367
  {
372
368
  return fun;
373
369
  }
@@ -412,9 +408,9 @@ public:
412
408
  }
413
409
  //@}
414
410
 
415
- virtual const std::string toString() const;
411
+ const std::string toString() const override;
416
412
 
417
- virtual const std::string getSourceLoc() const
413
+ const std::string getSourceLoc() const override
418
414
  {
419
415
  return "function ret: " + fun->getSourceLoc();
420
416
  }
@@ -430,7 +426,8 @@ class CallICFGNode : public InterICFGNode
430
426
 
431
427
  public:
432
428
  typedef std::vector<const SVFVar *> ActualParmNodeVec;
433
- private:
429
+
430
+ protected:
434
431
  const SVFInstruction* cs;
435
432
  const RetICFGNode* ret;
436
433
  ActualParmNodeVec APNodes;
@@ -439,17 +436,12 @@ private:
439
436
  CallICFGNode(NodeID id) : InterICFGNode(id, FunCallBlock), cs{}, ret{} {}
440
437
 
441
438
  public:
442
- CallICFGNode(NodeID id, const SVFInstruction* c)
439
+ CallICFGNode(NodeID id, const SVFInstruction* c, const SVFType* ty)
443
440
  : InterICFGNode(id, FunCallBlock), cs(c), ret(nullptr)
444
441
  {
445
442
  fun = cs->getFunction();
446
443
  bb = cs->getParent();
447
- }
448
-
449
- /// Return callsite
450
- inline const SVFInstruction* getCallSite() const
451
- {
452
- return cs;
444
+ type = ty;
453
445
  }
454
446
 
455
447
  /// Return callsite
@@ -468,13 +460,13 @@ public:
468
460
  /// Return callsite
469
461
  inline const SVFFunction* getCaller() const
470
462
  {
471
- return cs->getFunction();
463
+ return getFun();
472
464
  }
473
465
 
474
466
  /// Return Basic Block
475
467
  inline const SVFBasicBlock* getParent() const
476
468
  {
477
- return cs->getParent();
469
+ return getBB();
478
470
  }
479
471
 
480
472
  /// Return true if this is an indirect call
@@ -496,35 +488,23 @@ public:
496
488
  }
497
489
  /// Parameter operations
498
490
  //@{
499
- const SVFValue* getArgument(u32_t ArgNo) const
500
- {
501
- return SVFUtil::cast<SVFCallInst>(cs)->getArgOperand(ArgNo);
502
- }
503
-
504
- const SVFVar* getArgumentVar(u32_t ArgNo) const
491
+ const SVFVar* getArgument(u32_t ArgNo) const
505
492
  {
506
493
  return getActualParms()[ArgNo];
507
494
  }
508
495
 
509
- const SVFType* getType() const
510
- {
511
- return SVFUtil::cast<SVFCallInst>(cs)->getType();
512
- }
513
496
  u32_t arg_size() const
514
497
  {
515
- return SVFUtil::cast<SVFCallInst>(cs)->arg_size();
498
+ return APNodes.size();
516
499
  }
517
500
  bool arg_empty() const
518
501
  {
519
- return SVFUtil::cast<SVFCallInst>(cs)->arg_empty();
520
- }
521
- const SVFValue* getArgOperand(u32_t i) const
522
- {
523
- return SVFUtil::cast<SVFCallInst>(cs)->getArgOperand(i);
502
+ return APNodes.empty();
524
503
  }
504
+
525
505
  u32_t getNumArgOperands() const
526
506
  {
527
- return SVFUtil::cast<SVFCallInst>(cs)->arg_size();
507
+ return arg_size();
528
508
  }
529
509
  const SVFFunction* getCalledFunction() const
530
510
  {
@@ -587,11 +567,11 @@ public:
587
567
  }
588
568
  //@}
589
569
 
590
- virtual const std::string toString() const;
570
+ const std::string toString() const override;
591
571
 
592
- virtual const std::string getSourceLoc() const
572
+ const std::string getSourceLoc() const override
593
573
  {
594
- return "CallICFGNode: " + cs->getSourceLoc();
574
+ return "CallICFGNode: " + ICFGNode::getSourceLoc();
595
575
  }
596
576
  };
597
577
 
@@ -621,12 +601,7 @@ public:
621
601
  {
622
602
  fun = cs->getFunction();
623
603
  bb = cs->getParent();
624
- }
625
-
626
- /// Return callsite
627
- inline const SVFInstruction* getCallSite() const
628
- {
629
- return cs;
604
+ type = callBlockNode->getType();
630
605
  }
631
606
 
632
607
  inline const CallICFGNode* getCallICFGNode() const
@@ -672,11 +647,11 @@ public:
672
647
  }
673
648
  //@}
674
649
 
675
- virtual const std::string toString() const;
650
+ const std::string toString() const override;
676
651
 
677
- virtual const std::string getSourceLoc() const
652
+ const std::string getSourceLoc() const override
678
653
  {
679
- return "RetICFGNode: " + cs->getSourceLoc();
654
+ return "RetICFGNode: " + ICFGNode::getSourceLoc();
680
655
  }
681
656
  };
682
657
 
@@ -246,7 +246,7 @@ public:
246
246
  /// Return basic block
247
247
  inline const SVFBasicBlock* getBasicBlock() const
248
248
  {
249
- return callsite->getCallSite()->getParent();
249
+ return callsite->getBB();
250
250
  }
251
251
 
252
252
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -537,7 +537,7 @@ public:
537
537
  /// Return basic block
538
538
  inline const SVFBasicBlock* getBasicBlock() const
539
539
  {
540
- return callsite->getCallSite()->getParent();
540
+ return callsite->getBB();
541
541
  }
542
542
 
543
543
  /// Return callsite
@@ -349,7 +349,7 @@ private:
349
349
  bool isAliasedLocks(const ICFGNode* i1, const ICFGNode* i2)
350
350
  {
351
351
  /// todo: must alias
352
- return tct->getPTA()->alias(getLockVal(i1), getLockVal(i2));
352
+ return tct->getPTA()->alias(getLockVal(i1)->getId(), getLockVal(i2)->getId());
353
353
  }
354
354
 
355
355
  /// Mark thread flags for cxtStmt
@@ -466,7 +466,7 @@ private:
466
466
  return tct->isExtCall(inst);
467
467
  }
468
468
  /// Get lock value
469
- inline const SVFValue* getLockVal(const ICFGNode* call)
469
+ inline const SVFVar* getLockVal(const ICFGNode* call)
470
470
  {
471
471
  return getTCG()->getThreadAPI()->getLockVal(call);
472
472
  }
@@ -381,7 +381,7 @@ private:
381
381
  /// Whether it is a matched fork join pair
382
382
  bool isAliasedForkJoin(const CallICFGNode* forkSite, const CallICFGNode* joinSite)
383
383
  {
384
- return tct->getPTA()->alias(getForkedThread(forkSite), getJoinedThread(joinSite)) && isSameSCEV(forkSite,joinSite);
384
+ return tct->getPTA()->alias(getForkedThread(forkSite)->getId(), getJoinedThread(joinSite)->getId()) && isSameSCEV(forkSite,joinSite);
385
385
  }
386
386
  /// Mark thread flags for cxtStmt
387
387
  //@{
@@ -473,12 +473,12 @@ private:
473
473
  return join && getTCG()->getThreadAPI()->isTDJoin(join);
474
474
  }
475
475
  /// Get forked thread
476
- inline const SVFValue* getForkedThread(const CallICFGNode* call)
476
+ inline const SVFVar* getForkedThread(const CallICFGNode* call)
477
477
  {
478
478
  return getTCG()->getThreadAPI()->getForkedThread(call);
479
479
  }
480
480
  /// Get joined thread
481
- inline const SVFValue* getJoinedThread(const CallICFGNode* call)
481
+ inline const SVFVar* getJoinedThread(const CallICFGNode* call)
482
482
  {
483
483
  return getTCG()->getThreadAPI()->getJoinedThread(call);
484
484
  }
@@ -33,6 +33,8 @@
33
33
  namespace SVF
34
34
  {
35
35
 
36
+ class LLVMModuleSet;
37
+
36
38
  class CHGBuilder
37
39
  {
38
40
 
@@ -67,6 +69,9 @@ public:
67
69
  void buildCSToCHAVtblsAndVfnsMap();
68
70
  const CHNodeSetTy& getCSClasses(const CallBase* cs);
69
71
  void addFuncToFuncVector(CHNode::FuncVector &v, const Function *f);
72
+
73
+ private:
74
+ LLVMModuleSet* llvmModuleSet();
70
75
  };
71
76
 
72
77
  } // End namespace SVF
@@ -93,7 +93,7 @@ public:
93
93
 
94
94
  ~DCHNode() { }
95
95
 
96
- const DIType *getType(void) const
96
+ const DIType * getDIType(void) const
97
97
  {
98
98
  return diType;
99
99
  }
@@ -275,7 +275,7 @@ public:
275
275
  }
276
276
 
277
277
  virtual const VTableSet &getCSVtblsBasedonCHA(const CallICFGNode* cs) override;
278
- virtual void getVFnsFromVtbls(const SVFCallInst* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
278
+ virtual void getVFnsFromVtbls(const CallICFGNode* cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
279
279
 
280
280
  /// Returns true if a is a transitive base of b. firstField determines
281
281
  /// whether to consider first-field edges.
@@ -60,6 +60,7 @@ public:
60
60
  typedef Map<const Constant*, SVFConstant*> LLVMConst2SVFConstMap;
61
61
  typedef Map<const Value*, SVFOtherValue*> LLVMValue2SVFOtherValueMap;
62
62
  typedef Map<const SVFValue*, const Value*> SVFValue2LLVMValueMap;
63
+ typedef Map<const SVFBaseNode*, const Value*> SVFBaseNode2LLVMValueMap;
63
64
  typedef Map<const Type*, SVFType*> LLVMType2SVFTypeMap;
64
65
  typedef Map<const Type*, StInfo*> Type2TypeInfoMap;
65
66
  typedef Map<std::string, std::vector<std::string>> Fun2AnnoMap;
@@ -97,6 +98,7 @@ private:
97
98
  Type2TypeInfoMap Type2TypeInfo;
98
99
  ObjTypeInference* typeInference;
99
100
 
101
+ SVFBaseNode2LLVMValueMap SVFBaseNode2LLVMValue;
100
102
  CSToCallNodeMapTy CSToCallNodeMap; ///< map a callsite to its CallICFGNode
101
103
  CSToRetNodeMapTy CSToRetNodeMap; ///< map a callsite to its RetICFGNode
102
104
  InstToBlockNodeMapTy InstToBlockNodeMap; ///< map a basic block to its ICFGNode
@@ -216,6 +218,13 @@ public:
216
218
  return it->second;
217
219
  }
218
220
 
221
+ const Value* getLLVMValue(const SVFBaseNode* value) const
222
+ {
223
+ SVFBaseNode2LLVMValueMap ::const_iterator it = SVFBaseNode2LLVMValue.find(value);
224
+ assert(it!=SVFBaseNode2LLVMValue.end() && "can't find corresponding llvm value!");
225
+ return it->second;
226
+ }
227
+
219
228
  inline SVFFunction* getSVFFunction(const Function* fun) const
220
229
  {
221
230
  LLVMFun2SVFFunMap::const_iterator it = LLVMFunc2SVFFunc.find(fun);
@@ -378,6 +387,7 @@ private:
378
387
  void initSVFBasicBlock(const Function* func);
379
388
  void initDomTree(SVFFunction* func, const Function* f);
380
389
  void setValueAttr(const Value* val, SVFValue* value);
390
+ void setValueAttr(const Value* val, SVFBaseNode* svfBaseNode);
381
391
  void buildFunToFunMap();
382
392
  void buildGlobalDefToRepMap();
383
393
  /// Invoke llvm passes to modify module
@@ -184,13 +184,6 @@ bool isCallSite(const ICFGNode* inst);
184
184
 
185
185
  bool isRetInstNode(const ICFGNode* node);
186
186
 
187
- /// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
188
- inline bool isNonInstricCallSite(const SVFInstruction* inst)
189
- {
190
- if(isIntrinsicInst(inst))
191
- return false;
192
- return isCallSite(inst);
193
- }
194
187
 
195
188
  /// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
196
189
  inline bool isNonInstricCallSite(const ICFGNode* inst)
@@ -378,7 +371,7 @@ inline bool isArgOfUncalledFunction(const SVFValue* svfval)
378
371
 
379
372
  /// Return thread fork function
380
373
  //@{
381
- inline const SVFValue* getForkedFun(const CallICFGNode *inst)
374
+ inline const SVFVar* getForkedFun(const CallICFGNode *inst)
382
375
  {
383
376
  return ThreadAPI::getThreadAPI()->getForkedFun(inst);
384
377
  }
@@ -124,12 +124,12 @@ public:
124
124
  //@{
125
125
  /// Return the first argument of the call,
126
126
  /// Note that, it is the pthread_t pointer
127
- const SVFValue* getForkedThread(const CallICFGNode *inst) const;
127
+ const SVFVar* getForkedThread(const CallICFGNode *inst) const;
128
128
  /// Return the third argument of the call,
129
129
  /// Note that, it could be function type or a void* pointer
130
- const SVFValue* getForkedFun(const CallICFGNode *inst) const;
130
+ const SVFVar* getForkedFun(const CallICFGNode *inst) const;
131
131
 
132
- /// Return the actual param of forksite
132
+ /// Return the forth argument of the call,
133
133
  /// Note that, it is the sole argument of start routine ( a void* pointer )
134
134
  const SVFVar* getActualParmAtForkSite(const CallICFGNode *inst) const;
135
135
 
@@ -153,10 +153,10 @@ public:
153
153
  //@{
154
154
  /// Return the first argument of the call,
155
155
  /// Note that, it is the pthread_t pointer
156
- const SVFValue* getJoinedThread(const CallICFGNode *inst) const;
156
+ const SVFVar* getJoinedThread(const CallICFGNode *inst) const;
157
157
  /// Return the send argument of the call,
158
158
  /// Note that, it is the pthread_t pointer
159
- const SVFValue* getRetParmAtJoinedSite(const CallICFGNode *inst) const;
159
+ const SVFVar* getRetParmAtJoinedSite(const CallICFGNode *inst) const;
160
160
  //@}
161
161
 
162
162
 
@@ -178,7 +178,7 @@ public:
178
178
  /// Return lock value
179
179
  //@{
180
180
  /// First argument of pthread_mutex_lock/pthread_mutex_unlock
181
- const SVFValue* getLockVal(const ICFGNode *inst) const;
181
+ const SVFVar* getLockVal(const ICFGNode *inst) const;
182
182
  //@}
183
183
 
184
184
  /// Return true if this call waits for a barrier
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2115",
3
+ "version": "1.0.2116",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {