svf-lib 1.0.2179 → 1.0.2181

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
@@ -154,6 +154,7 @@ public:
154
154
  // ┌── SVFVar: Classes of top-level variables (ValVar) and address-taken variables (ObjVar)
155
155
  // │ └── ValVar: Classes of top-level variable nodes
156
156
  ValNode, // ├──Represents a standard value variable
157
+ ArgNode, // ├──Represents an argument value variable
157
158
  FunValNode, // ├──Represents a Function value variable
158
159
  GepValNode, // ├──Represents a GEP value variable
159
160
  RetNode, // ├──Represents a return value node
@@ -289,7 +290,7 @@ protected:
289
290
 
290
291
  static inline bool isSVFVarKind(GNodeK n)
291
292
  {
292
- static_assert(DummyObjNode - ValNode == 23,
293
+ static_assert(DummyObjNode - ValNode == 24,
293
294
  "The number of SVFVarKinds has changed, make sure the "
294
295
  "range is correct");
295
296
 
@@ -298,7 +299,7 @@ protected:
298
299
 
299
300
  static inline bool isValVarKinds(GNodeK n)
300
301
  {
301
- static_assert(DummyValNode - ValNode == 11,
302
+ static_assert(DummyValNode - ValNode == 12,
302
303
  "The number of ValVarKinds has changed, make sure the "
303
304
  "range is correct");
304
305
  return n <= DummyValNode && n >= ValNode;
@@ -578,6 +578,13 @@ private:
578
578
  return addValNode(nullptr, node, i);
579
579
  }
580
580
 
581
+ NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode, bool isUncalled = false)
582
+ {
583
+ ArgValVar* node =
584
+ new ArgValVar(i, argNo, icfgNode, callGraphNode, isUncalled);
585
+ return addValNode(nullptr, node, i);
586
+ }
587
+
581
588
  inline NodeID addConstantFPValNode(const SVFValue* curInst, double dval, const NodeID i,
582
589
  const ICFGNode* icfgNode)
583
590
  {
@@ -133,11 +133,6 @@ public:
133
133
  {
134
134
  return inst->getParent()->getParent();
135
135
  }
136
- // For function arguments, return their parent function
137
- else if (auto arg = SVFUtil::dyn_cast<SVFArgument>(value))
138
- {
139
- return arg->getParent();
140
- }
141
136
  }
142
137
 
143
138
  // Return nullptr for globals/constants with no parent function
@@ -388,6 +383,83 @@ public:
388
383
  };
389
384
 
390
385
 
386
+ /**
387
+ * @brief Class representing a function argument variable in the SVFIR
388
+ *
389
+ * This class models function argument in the program analysis. It extends ValVar
390
+ * to specifically handle function argument.
391
+ */
392
+ class ArgValVar: public ValVar
393
+ {
394
+ friend class SVFIRWriter;
395
+ friend class SVFIRReader;
396
+
397
+ private:
398
+ const CallGraphNode* cgNode;
399
+ u32_t argNo;
400
+ bool uncalled;
401
+
402
+ protected:
403
+ /// Constructor to create function argument (for SVFIRReader/deserialization)
404
+ ArgValVar(NodeID i, PNODEK ty = ArgNode) : ValVar(i, ty) {}
405
+
406
+ public:
407
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
408
+ //@{
409
+ static inline bool classof(const ArgValVar*)
410
+ {
411
+ return true;
412
+ }
413
+ static inline bool classof(const ValVar* node)
414
+ {
415
+ return node->getNodeKind() == ArgNode;
416
+ }
417
+ static inline bool classof(const SVFVar* node)
418
+ {
419
+ return node->getNodeKind() == ArgNode;
420
+ }
421
+ static inline bool classof(const GenericPAGNodeTy* node)
422
+ {
423
+ return node->getNodeKind() == ArgNode;
424
+ }
425
+ static inline bool classof(const SVFBaseNode* node)
426
+ {
427
+ return node->getNodeKind() == ArgNode;
428
+ }
429
+ //@}
430
+
431
+ /// Constructor
432
+ ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const CallGraphNode* callGraphNode,
433
+ bool isUncalled = false, PNODEK ty = ArgNode);
434
+
435
+ /// Return name of a LLVM value
436
+ inline const std::string getValueName() const
437
+ {
438
+ if (value)
439
+ return value->getName() + " (argument valvar)";
440
+ return " (argument valvar)";
441
+ }
442
+
443
+ virtual const SVFFunction* getFunction() const;
444
+
445
+ const SVFFunction* getParent() const;
446
+
447
+ /// Return the index of this formal argument in its containing function.
448
+ /// For example in "void foo(int a, float b)" a is 0 and b is 1.
449
+ inline u32_t getArgNo() const
450
+ {
451
+ return argNo;
452
+ }
453
+
454
+ inline bool isArgOfUncalledFunction() const
455
+ {
456
+ return uncalled;
457
+ }
458
+
459
+ virtual const std::string toString() const;
460
+ };
461
+
462
+
391
463
  /*
392
464
  * Gep Value (Pointer) variable, this variable can be dynamic generated for field sensitive analysis
393
465
  * e.g. memcpy, temp gep value variable needs to be created
@@ -351,6 +351,8 @@ inline bool isArgOfUncalledFunction(const SVFValue* svfval)
351
351
  return false;
352
352
  }
353
353
 
354
+ bool isArgOfUncalledFunction(const SVFVar* svfvar);
355
+
354
356
  const ObjVar* getObjVarOfValVar(const ValVar* valVar);
355
357
 
356
358
  /// Return thread fork function
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -572,9 +572,9 @@ private:
572
572
  return addValNode(val, node, i);
573
573
  }
574
574
 
575
- NodeID addFunValNode(const CallGraphNode* callGraphNode, NodeID i, const ICFGNode* icfgNode)
575
+ NodeID addFunValNode(NodeID i, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode)
576
576
  {
577
- FunValVar* node = new FunValVar(callGraphNode, i, icfgNode);
577
+ FunValVar* node = new FunValVar(i, icfgNode, callGraphNode);
578
578
  return addValNode(nullptr, node, i);
579
579
  }
580
580
 
@@ -585,17 +585,17 @@ private:
585
585
  return addValNode(nullptr, node, i);
586
586
  }
587
587
 
588
- inline NodeID addConstantFPValNode(const SVFValue* curInst, double dval, const NodeID i,
588
+ inline NodeID addConstantFPValNode(const SVFValue* curInst, const NodeID i, double dval,
589
589
  const ICFGNode* icfgNode)
590
590
  {
591
- SVFVar* node = new ConstantFPValVar(curInst, dval, i, icfgNode);
591
+ SVFVar* node = new ConstantFPValVar(curInst, i, dval, icfgNode);
592
592
  return addNode(node, i);
593
593
  }
594
594
 
595
- inline NodeID addConstantIntValNode(const SVFValue* curInst, const std::pair<s64_t, u64_t>& intValue, const NodeID i,
595
+ inline NodeID addConstantIntValNode(const SVFValue* curInst, NodeID i, const std::pair<s64_t, u64_t>& intValue,
596
596
  const ICFGNode* icfgNode)
597
597
  {
598
- SVFVar* node = new ConstantIntValVar(curInst, intValue.first, intValue.second, i, icfgNode);
598
+ SVFVar* node = new ConstantIntValVar(curInst, i, intValue.first, intValue.second, icfgNode);
599
599
  return addNode(node, i);
600
600
  }
601
601
 
@@ -629,47 +629,47 @@ private:
629
629
  /**
630
630
  * Creates and adds a heap object node to the SVFIR
631
631
  */
632
- inline NodeID addHeapObjNode(const SVFValue* val, const SVFFunction* f, NodeID i)
632
+ inline NodeID addHeapObjNode(const SVFValue* val, NodeID i, const SVFFunction* f)
633
633
  {
634
634
  const MemObj* mem = getMemObj(val);
635
635
  assert(mem->getId() == i && "not same object id?");
636
636
  memToFieldsMap[i].set(i);
637
- HeapObjVar *node = new HeapObjVar(f, val->getType(), i, mem);
637
+ HeapObjVar *node = new HeapObjVar(i, mem, val->getType(), f);
638
638
  return addObjNode(val, node, i);
639
639
  }
640
640
 
641
641
  /**
642
642
  * Creates and adds a stack object node to the SVFIR
643
643
  */
644
- inline NodeID addStackObjNode(const SVFValue* val, const SVFFunction* f, NodeID i)
644
+ inline NodeID addStackObjNode(const SVFValue* val, NodeID i, const SVFFunction* f)
645
645
  {
646
646
  const MemObj* mem = getMemObj(val);
647
647
  assert(mem->getId() == i && "not same object id?");
648
648
  memToFieldsMap[i].set(i);
649
- StackObjVar *node = new StackObjVar(f, val->getType(), i, mem);
649
+ StackObjVar *node = new StackObjVar(i, mem, val->getType(), f);
650
650
  return addObjNode(val, node, i);
651
651
  }
652
652
 
653
- NodeID addFunObjNode(const CallGraphNode* callGraphNode, NodeID id);
653
+ NodeID addFunObjNode(NodeID id, const CallGraphNode* callGraphNode);
654
654
 
655
655
 
656
- inline NodeID addConstantFPObjNode(const SVFValue* curInst, double dval, const NodeID i)
656
+ inline NodeID addConstantFPObjNode(const SVFValue* curInst, NodeID i, double dval)
657
657
  {
658
658
  const MemObj* mem = getMemObj(curInst);
659
659
  NodeID base = mem->getId();
660
660
  memToFieldsMap[base].set(mem->getId());
661
- ConstantFPObjVar* node = new ConstantFPObjVar(curInst, dval, mem->getId(), mem);
661
+ ConstantFPObjVar* node = new ConstantFPObjVar(curInst, i, dval, mem);
662
662
  return addObjNode(curInst, node, mem->getId());
663
663
  }
664
664
 
665
665
 
666
- inline NodeID addConstantIntObjNode(const SVFValue* curInst, const std::pair<s64_t, u64_t>& intValue, const NodeID i)
666
+ inline NodeID addConstantIntObjNode(const SVFValue* curInst, NodeID i, const std::pair<s64_t, u64_t>& intValue)
667
667
  {
668
668
  const MemObj* mem = getMemObj(curInst);
669
669
  NodeID base = mem->getId();
670
670
  memToFieldsMap[base].set(mem->getId());
671
671
  ConstantIntObjVar* node =
672
- new ConstantIntObjVar(curInst, intValue.first, intValue.second, mem->getId(), mem);
672
+ new ConstantIntObjVar(curInst, i, intValue.first, intValue.second, mem);
673
673
  return addObjNode(curInst, node, mem->getId());
674
674
  }
675
675
 
@@ -702,15 +702,15 @@ private:
702
702
  }
703
703
 
704
704
  /// Add a unique return node for a procedure
705
- inline NodeID addRetNode(const CallGraphNode* callGraphNode, NodeID i)
705
+ inline NodeID addRetNode(NodeID i, const CallGraphNode* callGraphNode)
706
706
  {
707
- SVFVar *node = new RetPN(callGraphNode,i);
707
+ SVFVar *node = new RetPN(i, callGraphNode);
708
708
  return addRetNode(callGraphNode, node, i);
709
709
  }
710
710
  /// Add a unique vararg node for a procedure
711
- inline NodeID addVarargNode(const CallGraphNode* val, NodeID i)
711
+ inline NodeID addVarargNode(NodeID i, const CallGraphNode* val)
712
712
  {
713
- SVFVar *node = new VarArgPN(val,i);
713
+ SVFVar *node = new VarArgPN(i, val);
714
714
  return addNode(node,i);
715
715
  }
716
716
 
@@ -724,8 +724,8 @@ public:
724
724
  //@}
725
725
 
726
726
  /// Constructor
727
- HeapObjVar(const SVFFunction* func, const SVFType* svfType, NodeID i,
728
- const MemObj* mem, PNODEK ty = HeapObjNode);
727
+ HeapObjVar(NodeID i, const MemObj* mem, const SVFType* svfType,
728
+ const SVFFunction* fun, PNODEK ty = HeapObjNode);
729
729
 
730
730
  /// Return name of a LLVM value
731
731
  inline const std::string getValueName() const
@@ -785,8 +785,8 @@ public:
785
785
  //@}
786
786
 
787
787
  /// Constructor
788
- StackObjVar(const SVFFunction* f, const SVFType* svfType, NodeID i,
789
- const MemObj* mem, PNODEK ty = StackObjNode);
788
+ StackObjVar(NodeID i, const MemObj* mem, const SVFType* svfType,
789
+ const SVFFunction* fun, PNODEK ty = StackObjNode);
790
790
 
791
791
  /// Return name of a LLVM value
792
792
  inline const std::string getValueName() const
@@ -838,7 +838,7 @@ public:
838
838
  }
839
839
 
840
840
  /// Constructor
841
- FunValVar(const CallGraphNode* cgn, NodeID i, const ICFGNode* icn,
841
+ FunValVar(NodeID i, const ICFGNode* icn, const CallGraphNode* cgn,
842
842
  PNODEK ty = FunValNode);
843
843
 
844
844
  virtual const std::string toString() const;
@@ -886,7 +886,7 @@ public:
886
886
  //@}
887
887
 
888
888
  /// Constructor
889
- FunObjVar(const CallGraphNode* cgNode, NodeID i, const MemObj* mem,
889
+ FunObjVar(NodeID i, const MemObj* mem, const CallGraphNode* cgNode,
890
890
  PNODEK ty = FunObjNode);
891
891
 
892
892
  inline const CallGraphNode* getCallGraphNode() const
@@ -1069,7 +1069,7 @@ public:
1069
1069
  }
1070
1070
 
1071
1071
  /// Constructor
1072
- ConstantFPValVar(const SVFValue* val, double dv, NodeID i, const ICFGNode* icn,
1072
+ ConstantFPValVar(const SVFValue* val, NodeID i, double dv, const ICFGNode* icn,
1073
1073
  PNODEK ty = ConstantFPValNode)
1074
1074
  : ConstantDataValVar(val, i, icn, ty), dval(dv)
1075
1075
  {
@@ -1128,7 +1128,7 @@ public:
1128
1128
  }
1129
1129
 
1130
1130
  /// Constructor
1131
- ConstantIntValVar(const SVFValue* val, s64_t sv, u64_t zv, NodeID i, const ICFGNode* icn,
1131
+ ConstantIntValVar(const SVFValue* val, NodeID i, s64_t sv, u64_t zv, const ICFGNode* icn,
1132
1132
  PNODEK ty = ConstantIntValNode)
1133
1133
  : ConstantDataValVar(val, i, icn, ty), zval(zv), sval(sv)
1134
1134
  {
@@ -1327,7 +1327,7 @@ public:
1327
1327
  //@}
1328
1328
 
1329
1329
  /// Constructor
1330
- ConstantFPObjVar(const SVFValue* val, double dv, NodeID i, const MemObj* m, PNODEK ty = ConstantFPObjNode)
1330
+ ConstantFPObjVar(const SVFValue* val, NodeID i, double dv, const MemObj* m, PNODEK ty = ConstantFPObjNode)
1331
1331
  : ConstantDataObjVar(val, i, m, ty), dval(dv)
1332
1332
  {
1333
1333
  }
@@ -1402,7 +1402,7 @@ public:
1402
1402
  //@}
1403
1403
 
1404
1404
  /// Constructor
1405
- ConstantIntObjVar(const SVFValue* val, s64_t sv, u64_t zv, NodeID i, const MemObj* m, PNODEK ty = ConstantIntObjNode)
1405
+ ConstantIntObjVar(const SVFValue* val, NodeID i, s64_t sv, u64_t zv, const MemObj* m, PNODEK ty = ConstantIntObjNode)
1406
1406
  : ConstantDataObjVar(val, i, m, ty), zval(zv), sval(sv)
1407
1407
  {
1408
1408
  }
@@ -1505,7 +1505,7 @@ public:
1505
1505
 
1506
1506
 
1507
1507
  /// Constructor
1508
- RetPN(const CallGraphNode* node, NodeID i);
1508
+ RetPN(NodeID i, const CallGraphNode* node);
1509
1509
 
1510
1510
  inline const CallGraphNode* getCallGraphNode() const
1511
1511
  {
@@ -1559,7 +1559,7 @@ public:
1559
1559
  //@}
1560
1560
 
1561
1561
  /// Constructor
1562
- VarArgPN(const CallGraphNode* node, NodeID i) : ValVar(nullptr, i, VarargNode), callGraphNode(node) {}
1562
+ VarArgPN(NodeID i, const CallGraphNode* node) : ValVar(nullptr, i, VarargNode), callGraphNode(node) {}
1563
1563
 
1564
1564
  virtual const SVFFunction* getFunction() const;
1565
1565
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2179",
3
+ "version": "1.0.2181",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {