svf-lib 1.0.2151 → 1.0.2153

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
@@ -161,6 +161,8 @@ public:
161
161
  // │ ┌── ValVarKinds: Types of value variable nodes
162
162
  // │ │ ├── Represents a standard value variable
163
163
  ValNode,
164
+ // │ │ ├── Represents a Function value variable
165
+ FunValNode,
164
166
  // │ │ ├── Represents a GEP value variable
165
167
  GepValNode,
166
168
  // │ │ ├── Represents a return value node
@@ -174,8 +176,10 @@ public:
174
176
  ObjNode,
175
177
  // │ ├── GepObjNode: Represents a GEP object variable
176
178
  GepObjNode,
177
- // │ ├── FIObjNode: Represents a flow-insensitive object node
179
+ // │ └── FIObjNode: Represents a flow-insensitive object node
178
180
  FIObjNode,
181
+ // │ ├──FunObjNode: Types of function object
182
+ FunObjNode,
179
183
  // │ └── DummyObjNode: Dummy node for uninitialized objects
180
184
  DummyObjNode,
181
185
  // └────────
@@ -313,7 +317,7 @@ protected:
313
317
 
314
318
  static inline bool isSVFVarKind(GNodeK n)
315
319
  {
316
- static_assert(DummyObjNode - ValNode == 8,
320
+ static_assert(DummyObjNode - ValNode == 10,
317
321
  "The number of SVFVarKinds has changed, make sure the "
318
322
  "range is correct");
319
323
 
@@ -322,7 +326,7 @@ protected:
322
326
 
323
327
  static inline bool isValVarKinds(GNodeK n)
324
328
  {
325
- static_assert(DummyValNode - ValNode == 4,
329
+ static_assert(DummyValNode - ValNode == 5,
326
330
  "The number of ValVarKinds has changed, make sure the "
327
331
  "range is correct");
328
332
  return n <= DummyValNode && n >= ValNode;
@@ -330,12 +334,20 @@ protected:
330
334
 
331
335
  static inline bool isObjVarKinds(GNodeK n)
332
336
  {
333
- static_assert(DummyObjNode - ObjNode == 3,
337
+ static_assert(DummyObjNode - ObjNode == 4,
334
338
  "The number of ObjVarKinds has changed, make sure the "
335
339
  "range is correct");
336
340
  return n <= DummyObjNode && n >= ObjNode;
337
341
  }
338
342
 
343
+ static inline bool isFIObjVarKinds(GNodeK n)
344
+ {
345
+ static_assert(FunObjNode - FIObjNode == 1,
346
+ "The number of FIObjVarKinds has changed, make sure the "
347
+ "range is correct");
348
+ return n <= FunObjNode && n >= FIObjNode;
349
+ }
350
+
339
351
  static inline bool isVFGNodeKinds(GNodeK n)
340
352
  {
341
353
  static_assert(MInterPhi - Cmp == 24,
@@ -425,7 +425,7 @@ class CallICFGNode : public InterICFGNode
425
425
  friend class SVFIRReader;
426
426
 
427
427
  public:
428
- typedef std::vector<const SVFVar *> ActualParmNodeVec;
428
+ typedef std::vector<const ValVar *> ActualParmNodeVec;
429
429
 
430
430
  protected:
431
431
  const RetICFGNode* ret;
@@ -491,13 +491,13 @@ public:
491
491
  }
492
492
 
493
493
  /// Add actual parameters
494
- inline void addActualParms(const SVFVar *ap)
494
+ inline void addActualParms(const ValVar *ap)
495
495
  {
496
496
  APNodes.push_back(ap);
497
497
  }
498
498
  /// Parameter operations
499
499
  //@{
500
- inline const SVFVar* getArgument(u32_t ArgNo) const
500
+ inline const ValVar* getArgument(u32_t ArgNo) const
501
501
  {
502
502
  return getActualParms()[ArgNo];
503
503
  }
@@ -54,6 +54,7 @@ public:
54
54
  typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
55
55
 
56
56
  typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
57
+ typedef Map<const Function*, CallGraphNode*> LLVMFun2CallGraphNodeMap;
57
58
  typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
58
59
  typedef Map<const Instruction*, SVFInstruction*> LLVMInst2SVFInstMap;
59
60
  typedef Map<const Argument*, SVFArgument*> LLVMArgument2SVFArgumentMap;
@@ -89,6 +90,7 @@ private:
89
90
  GlobalDefToRepMapTy GlobalDefToRepMap;
90
91
 
91
92
  LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
93
+ LLVMFun2CallGraphNodeMap LLVMFunc2CallGraphNode; ///< Map an LLVM Function to an CallGraph Node
92
94
  LLVMBB2SVFBBMap LLVMBB2SVFBB;
93
95
  LLVMInst2SVFInstMap LLVMInst2SVFInst;
94
96
  LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
@@ -170,6 +172,8 @@ public:
170
172
  LLVMFunc2SVFFunc[func] = svfFunc;
171
173
  setValueAttr(func,svfFunc);
172
174
  }
175
+ void addFunctionMap(const Function* func, CallGraphNode* svfFunc);
176
+
173
177
  inline void addBasicBlockMap(const BasicBlock* bb, SVFBasicBlock* svfBB)
174
178
  {
175
179
  LLVMBB2SVFBB[bb] = svfBB;
@@ -234,6 +238,13 @@ public:
234
238
  return it->second;
235
239
  }
236
240
 
241
+ inline CallGraphNode* getCallGraphNode(const Function* fun) const
242
+ {
243
+ LLVMFun2CallGraphNodeMap::const_iterator it = LLVMFunc2CallGraphNode.find(fun);
244
+ assert(it!=LLVMFunc2CallGraphNode.end() && "CallGraph Node not found!");
245
+ return it->second;
246
+ }
247
+
237
248
  inline SVFBasicBlock* getSVFBasicBlock(const BasicBlock* bb) const
238
249
  {
239
250
  LLVMBB2SVFBBMap::const_iterator it = LLVMBB2SVFBB.find(bb);
@@ -522,7 +522,7 @@ private:
522
522
  funRetMap[fun] = ret;
523
523
  }
524
524
  /// Add callsite arguments
525
- inline void addCallSiteArgs(CallICFGNode* callBlockNode,const SVFVar* arg)
525
+ inline void addCallSiteArgs(CallICFGNode* callBlockNode,const ValVar* arg)
526
526
  {
527
527
  callBlockNode->addActualParms(arg);
528
528
  callSiteArgsListMap[callBlockNode].push_back(arg);
@@ -545,11 +545,18 @@ private:
545
545
  /// add node into SVFIR
546
546
  //@{
547
547
  /// Add a value (pointer) node
548
- inline NodeID addValNode(const SVFValue* val, NodeID i, const SVFBaseNode* gNode)
548
+ inline NodeID addValNode(const SVFValue* val, NodeID i, const ICFGNode* icfgNode)
549
549
  {
550
- SVFVar *node = new ValVar(val,i, ValVar::ValNode, gNode);
550
+ SVFVar *node = new ValVar(val,i, ValVar::ValNode, icfgNode);
551
551
  return addValNode(val, node, i);
552
552
  }
553
+
554
+ NodeID addFunValNode(const CallGraphNode* callGraphNode, NodeID i, const ICFGNode* icfgNode)
555
+ {
556
+ FunValVar* node = new FunValVar(callGraphNode, i, icfgNode);
557
+ return addValNode(nullptr, node, i);
558
+ }
559
+
553
560
  /// Add a memory obj node
554
561
  inline NodeID addObjNode(const SVFValue* val, NodeID i)
555
562
  {
@@ -557,14 +564,16 @@ private:
557
564
  assert(mem->getId() == i && "not same object id?");
558
565
  return addFIObjNode(mem);
559
566
  }
567
+
568
+ NodeID addFunObjNode(const CallGraphNode* callGraphNode, NodeID id);
560
569
  /// Add a unique return node for a procedure
561
- inline NodeID addRetNode(const SVFFunction* val, NodeID i)
570
+ inline NodeID addRetNode(const CallGraphNode* callGraphNode, NodeID i)
562
571
  {
563
- SVFVar *node = new RetPN(val,i);
564
- return addRetNode(val, node, i);
572
+ SVFVar *node = new RetPN(callGraphNode,i);
573
+ return addRetNode(callGraphNode, node, i);
565
574
  }
566
575
  /// Add a unique vararg node for a procedure
567
- inline NodeID addVarargNode(const SVFFunction* val, NodeID i)
576
+ inline NodeID addVarargNode(const CallGraphNode* val, NodeID i)
568
577
  {
569
578
  SVFVar *node = new VarArgPN(val,i);
570
579
  return addNode(node,i);
@@ -576,6 +585,7 @@ private:
576
585
  NodeID addGepObjNode(const MemObj* obj, const APOffset& apOffset, const NodeID gepId);
577
586
  /// Add a field-insensitive node, this method can only invoked by getFIGepObjNode
578
587
  NodeID addFIObjNode(const MemObj* obj);
588
+
579
589
  //@}
580
590
 
581
591
  /// Add a dummy value/object node according to node ID (llvm value is null)
@@ -628,7 +638,7 @@ private:
628
638
  return addNode(node, i);
629
639
  }
630
640
  /// Add a unique return node for a procedure
631
- inline NodeID addRetNode(const SVFFunction*, SVFVar *node, NodeID i)
641
+ inline NodeID addRetNode(const CallGraphNode*, SVFVar *node, NodeID i)
632
642
  {
633
643
  return addNode(node,i);
634
644
  }
@@ -87,8 +87,7 @@ public:
87
87
  "dummy node do not have value!");
88
88
  assert(!SymbolTableInfo::isBlkObjOrConstantObj(this->getId()) &&
89
89
  "blackhole and constant obj do not have value");
90
- assert(value &&
91
- "value is null (GepObjNode whose basenode is a DummyObj?)");
90
+ assert(value && "value is null (GepObjNode whose basenode is a DummyObj?)");
92
91
  return value;
93
92
  }
94
93
 
@@ -112,7 +111,7 @@ public:
112
111
  bool isConstDataOrAggDataButNotNullPtr() const;
113
112
 
114
113
  /// Whether this is an isolated node on the SVFIR graph
115
- bool isIsolatedNode() const;
114
+ virtual bool isIsolatedNode() const;
116
115
 
117
116
  /// Get name of the LLVM value
118
117
  // TODO: (Optimization) Should it return const reference instead of value?
@@ -127,8 +126,6 @@ public:
127
126
  return inst->getParent()->getParent();
128
127
  else if (auto arg = SVFUtil::dyn_cast<SVFArgument>(value))
129
128
  return arg->getParent();
130
- else if (auto fun = SVFUtil::dyn_cast<SVFFunction>(value))
131
- return fun;
132
129
  }
133
130
  return nullptr;
134
131
  }
@@ -269,10 +266,10 @@ class ValVar: public SVFVar
269
266
  friend class SVFIRReader;
270
267
 
271
268
  private:
272
- const SVFBaseNode* gNode; // constant, gepValvar, retPN, dummy could be null
269
+ const ICFGNode* icfgNode; // icfgnode related to valvar
273
270
  protected:
274
271
  /// Constructor to create an empty ValVar (for SVFIRReader/deserialization)
275
- ValVar(NodeID i, PNODEK ty = ValNode) : SVFVar(i, ty), gNode(nullptr) {}
272
+ ValVar(NodeID i, PNODEK ty = ValNode) : SVFVar(i, ty), icfgNode(nullptr) {}
276
273
 
277
274
  public:
278
275
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -296,8 +293,8 @@ public:
296
293
  //@}
297
294
 
298
295
  /// Constructor
299
- ValVar(const SVFValue* val, NodeID i, PNODEK ty = ValNode, const SVFBaseNode* node = nullptr)
300
- : SVFVar(val, i, ty), gNode(node)
296
+ ValVar(const SVFValue* val, NodeID i, PNODEK ty = ValNode, const ICFGNode* node = nullptr)
297
+ : SVFVar(val, i, ty), icfgNode(node)
301
298
  {
302
299
  }
303
300
  /// Return name of a LLVM value
@@ -308,9 +305,9 @@ public:
308
305
  return "";
309
306
  }
310
307
 
311
- const SVFBaseNode* getGNode() const
308
+ const ICFGNode* getICFGNode() const
312
309
  {
313
- return gNode;
310
+ return icfgNode;
314
311
  }
315
312
 
316
313
  virtual const std::string toString() const;
@@ -540,7 +537,7 @@ class FIObjVar: public ObjVar
540
537
  friend class SVFIRWriter;
541
538
  friend class SVFIRReader;
542
539
 
543
- private:
540
+ protected:
544
541
  /// Constructor to create empty ObjVar (for SVFIRReader/deserialization)
545
542
  FIObjVar(NodeID i, PNODEK ty = FIObjNode) : ObjVar(i, ty) {}
546
543
 
@@ -553,19 +550,19 @@ public:
553
550
  }
554
551
  static inline bool classof(const ObjVar* node)
555
552
  {
556
- return node->getNodeKind() == SVFVar::FIObjNode;
553
+ return isFIObjVarKinds(node->getNodeKind());
557
554
  }
558
555
  static inline bool classof(const SVFVar* node)
559
556
  {
560
- return node->getNodeKind() == SVFVar::FIObjNode;
557
+ return isFIObjVarKinds(node->getNodeKind());
561
558
  }
562
559
  static inline bool classof(const GenericPAGNodeTy* node)
563
560
  {
564
- return node->getNodeKind() == SVFVar::FIObjNode;
561
+ return isFIObjVarKinds(node->getNodeKind());
565
562
  }
566
563
  static inline bool classof(const SVFBaseNode* node)
567
564
  {
568
- return node->getNodeKind() == SVFVar::FIObjNode;
565
+ return isFIObjVarKinds(node->getNodeKind());
569
566
  }
570
567
  //@}
571
568
 
@@ -587,6 +584,111 @@ public:
587
584
  virtual const std::string toString() const;
588
585
  };
589
586
 
587
+ class CallGraphNode;
588
+
589
+ class FunValVar : public ValVar
590
+ {
591
+ friend class SVFIRWriter;
592
+ friend class SVFIRReader;
593
+ private:
594
+ const CallGraphNode* callGraphNode;
595
+
596
+ public:
597
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
598
+ //@{
599
+ static inline bool classof(const FunValVar*)
600
+ {
601
+ return true;
602
+ }
603
+ static inline bool classof(const ValVar* node)
604
+ {
605
+ return node->getNodeKind() == FunValNode;
606
+ }
607
+ static inline bool classof(const SVFVar* node)
608
+ {
609
+ return node->getNodeKind() == FunValNode;
610
+ }
611
+ static inline bool classof(const GenericPAGNodeTy* node)
612
+ {
613
+ return node->getNodeKind() == FunValNode;
614
+ }
615
+ static inline bool classof(const SVFBaseNode* node)
616
+ {
617
+ return node->getNodeKind() == FunValNode;
618
+ }
619
+ //@}
620
+
621
+ inline const CallGraphNode* getCallGraphNode() const
622
+ {
623
+ return callGraphNode;
624
+ }
625
+
626
+ /// Constructor
627
+ FunValVar(const CallGraphNode* cgn, NodeID i, const ICFGNode* icn,
628
+ PNODEK ty = FunValNode)
629
+ : ValVar(nullptr, i, ty, icn), callGraphNode(cgn)
630
+ {
631
+
632
+ }
633
+
634
+ virtual const std::string toString() const;
635
+ };
636
+
637
+ class FunObjVar : public FIObjVar
638
+ {
639
+ friend class SVFIRWriter;
640
+ friend class SVFIRReader;
641
+
642
+ private:
643
+ const CallGraphNode* callGraphNode;
644
+
645
+ private:
646
+ /// Constructor to create empty ObjVar (for SVFIRReader/deserialization)
647
+ FunObjVar(NodeID i, PNODEK ty = FunObjNode) : FIObjVar(i, ty) {}
648
+
649
+ public:
650
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
651
+ //@{
652
+ static inline bool classof(const FunObjVar*)
653
+ {
654
+ return true;
655
+ }
656
+ static inline bool classof(const FIObjVar* node)
657
+ {
658
+ return node->getNodeKind() == FunObjNode;
659
+ }
660
+ static inline bool classof(const ObjVar* node)
661
+ {
662
+ return node->getNodeKind() == FunObjNode;
663
+ }
664
+ static inline bool classof(const SVFVar* node)
665
+ {
666
+ return node->getNodeKind() == FunObjNode;
667
+ }
668
+ static inline bool classof(const GenericPAGNodeTy* node)
669
+ {
670
+ return node->getNodeKind() == FunObjNode;
671
+ }
672
+ static inline bool classof(const SVFBaseNode* node)
673
+ {
674
+ return node->getNodeKind() == FunObjNode;
675
+ }
676
+ //@}
677
+
678
+ /// Constructor
679
+ FunObjVar(const CallGraphNode* cgNode, NodeID i, const MemObj* mem,
680
+ PNODEK ty = FunObjNode);
681
+
682
+ inline const CallGraphNode* getCallGraphNode() const
683
+ {
684
+ return callGraphNode;
685
+ }
686
+
687
+ virtual bool isIsolatedNode() const;
688
+
689
+ virtual const std::string toString() const;
690
+ };
691
+
590
692
  /*
591
693
  * Unique Return node of a procedure
592
694
  */
@@ -595,6 +697,8 @@ class RetPN: public ValVar
595
697
  friend class SVFIRWriter;
596
698
  friend class SVFIRReader;
597
699
 
700
+ private:
701
+ const CallGraphNode* callGraphNode;
598
702
  private:
599
703
  /// Constructor to create empty RetPN (for SVFIRReader/deserialization)
600
704
  RetPN(NodeID i) : ValVar(i, RetNode) {}
@@ -623,15 +727,20 @@ public:
623
727
  }
624
728
  //@}
625
729
 
730
+
626
731
  /// Constructor
627
- RetPN(const SVFFunction* val, NodeID i) : ValVar(val, i, RetNode) {}
732
+ RetPN(const CallGraphNode* node, NodeID i);
628
733
 
629
- /// Return name of a LLVM value
630
- const std::string getValueName() const
734
+ inline const CallGraphNode* getCallGraphNode() const
631
735
  {
632
- return value->getName() + "_ret";
736
+ return callGraphNode;
633
737
  }
634
738
 
739
+ virtual const SVFFunction* getFunction() const;
740
+
741
+ /// Return name of a LLVM value
742
+ const std::string getValueName() const;
743
+
635
744
  virtual const std::string toString() const;
636
745
  };
637
746
 
@@ -642,6 +751,8 @@ class VarArgPN: public ValVar
642
751
  {
643
752
  friend class SVFIRWriter;
644
753
  friend class SVFIRReader;
754
+ private:
755
+ const CallGraphNode* callGraphNode;
645
756
 
646
757
  private:
647
758
  /// Constructor to create empty VarArgPN (for SVFIRReader/deserialization)
@@ -672,13 +783,12 @@ public:
672
783
  //@}
673
784
 
674
785
  /// Constructor
675
- VarArgPN(const SVFFunction* val, NodeID i) : ValVar(val, i, VarargNode) {}
786
+ VarArgPN(const CallGraphNode* node, NodeID i) : ValVar(nullptr, i, VarargNode), callGraphNode(node) {}
787
+
788
+ virtual const SVFFunction* getFunction() const;
676
789
 
677
790
  /// Return name of a LLVM value
678
- inline const std::string getValueName() const
679
- {
680
- return value->getName() + "_vararg";
681
- }
791
+ const std::string getValueName() const;
682
792
 
683
793
  virtual const std::string toString() const;
684
794
  };
@@ -351,9 +351,11 @@ inline bool isArgOfUncalledFunction(const SVFValue* svfval)
351
351
  return false;
352
352
  }
353
353
 
354
+ const ObjVar* getObjVarOfValVar(const ValVar* valVar);
355
+
354
356
  /// Return thread fork function
355
357
  //@{
356
- inline const SVFVar* getForkedFun(const CallICFGNode *inst)
358
+ inline const ValVar* getForkedFun(const CallICFGNode *inst)
357
359
  {
358
360
  return ThreadAPI::getThreadAPI()->getForkedFun(inst);
359
361
  }
@@ -432,7 +434,7 @@ inline bool isBarrierWaitCall(const CallICFGNode* cs)
432
434
 
433
435
  /// Return sole argument of the thread routine
434
436
  //@{
435
- inline const SVFVar* getActualParmAtForkSite(const CallICFGNode* cs)
437
+ inline const ValVar* getActualParmAtForkSite(const CallICFGNode* cs)
436
438
  {
437
439
  return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(cs);
438
440
  }
@@ -39,6 +39,8 @@ class SVFModule;
39
39
  class ICFGNode;
40
40
  class CallICFGNode;
41
41
  class SVFVar;
42
+ class ValVar;
43
+ class ObjVar;
42
44
 
43
45
  /*
44
46
  * ThreadAPI class contains interfaces for pthread programs
@@ -124,14 +126,14 @@ public:
124
126
  //@{
125
127
  /// Return the first argument of the call,
126
128
  /// Note that, it is the pthread_t pointer
127
- const SVFVar* getForkedThread(const CallICFGNode *inst) const;
129
+ const ValVar* getForkedThread(const CallICFGNode *inst) const;
128
130
  /// Return the third argument of the call,
129
131
  /// Note that, it could be function type or a void* pointer
130
- const SVFVar* getForkedFun(const CallICFGNode *inst) const;
132
+ const ValVar* getForkedFun(const CallICFGNode *inst) const;
131
133
 
132
134
  /// Return the forth argument of the call,
133
135
  /// Note that, it is the sole argument of start routine ( a void* pointer )
134
- const SVFVar* getActualParmAtForkSite(const CallICFGNode *inst) const;
136
+ const ValVar* getActualParmAtForkSite(const CallICFGNode *inst) const;
135
137
 
136
138
  /// Return the formal parm of forked function (the first arg in pthread)
137
139
  const SVFVar* getFormalParmOfForkedFun(const SVFFunction* F) const;
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2151",
3
+ "version": "1.0.2153",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {