svf-tools 1.0.1027 → 1.0.1028

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.1027",
3
+ "version": "1.0.1028",
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": {
@@ -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
 
@@ -472,14 +472,14 @@ NodeID SVFIR::addFIObjNode(const MemObj* obj)
472
472
  return addObjNode(obj->getValue(), node, obj->getId());
473
473
  }
474
474
 
475
- NodeID SVFIR::addFunObjNode(const CallGraphNode* callGraphNode, NodeID id)
475
+ NodeID SVFIR::addFunObjNode(NodeID id, const CallGraphNode* callGraphNode)
476
476
  {
477
477
  const MemObj* mem = getMemObj(callGraphNode->getFunction());
478
478
  assert(mem->getId() == id && "not same object id?");
479
479
  //assert(findPAGNode(i) == false && "this node should not be created before");
480
480
  NodeID base = mem->getId();
481
481
  memToFieldsMap[base].set(mem->getId());
482
- FunObjVar*node = new FunObjVar(callGraphNode, mem->getId(), mem);
482
+ FunObjVar*node = new FunObjVar(id, mem, callGraphNode);
483
483
  return addObjNode(mem->getValue(), node, mem->getId());
484
484
  }
485
485
 
@@ -191,7 +191,7 @@ const std::string GepValVar::toString() const
191
191
  return rawstr.str();
192
192
  }
193
193
 
194
- RetPN::RetPN(const CallGraphNode* node, NodeID i) : ValVar(i, RetNode), callGraphNode(node)
194
+ RetPN::RetPN(NodeID i, const CallGraphNode* node) : ValVar(i, RetNode), callGraphNode(node)
195
195
  {
196
196
  isPtr = node->getFunction()->getReturnType()->isPointerTy();
197
197
  }
@@ -232,8 +232,8 @@ const std::string BaseObjVar::toString() const
232
232
  return rawstr.str();
233
233
  }
234
234
 
235
- HeapObjVar::HeapObjVar(const SVFFunction* f, const SVFType* svfType, NodeID i,
236
- const MemObj* mem, PNODEK ty)
235
+ HeapObjVar::HeapObjVar(NodeID i, const MemObj* mem, const SVFType* svfType,
236
+ const SVFFunction* f, PNODEK ty)
237
237
  : BaseObjVar(mem->getValue(), i, mem, ty)
238
238
  {
239
239
  isPtr = svfType->isPointerTy();
@@ -253,8 +253,7 @@ const std::string HeapObjVar::toString() const
253
253
  return rawstr.str();
254
254
  }
255
255
 
256
- StackObjVar::StackObjVar(const SVFFunction* f, const SVFType* svfType, NodeID i,
257
- const MemObj* mem, PNODEK ty)
256
+ StackObjVar::StackObjVar(NodeID i, const MemObj* mem, const SVFType* svfType, const SVFFunction* f, PNODEK ty)
258
257
  : BaseObjVar(mem->getValue(), i, mem, ty)
259
258
  {
260
259
  isPtr = svfType->isPointerTy();
@@ -276,8 +275,7 @@ const std::string StackObjVar::toString() const
276
275
 
277
276
 
278
277
 
279
- FunValVar::FunValVar(const CallGraphNode* cgn, NodeID i, const ICFGNode* icn,
280
- PNODEK ty)
278
+ FunValVar::FunValVar(NodeID i, const ICFGNode* icn, const CallGraphNode* cgn, PNODEK ty)
281
279
  : ValVar(cgn->getFunction(), i, ty, icn), callGraphNode(cgn)
282
280
  {
283
281
  isPtr = cgn->getFunction()->getType()->isPointerTy();
@@ -426,7 +424,7 @@ const std::string ConstantNullPtrObjVar::toString() const
426
424
  return rawstr.str();
427
425
  }
428
426
 
429
- FunObjVar::FunObjVar(const CallGraphNode* cgNode, NodeID i, const MemObj* mem,
427
+ FunObjVar::FunObjVar(NodeID i, const MemObj* mem, const CallGraphNode* cgNode,
430
428
  PNODEK ty)
431
429
  : BaseObjVar(mem->getValue(), i, mem, ty), callGraphNode(cgNode)
432
430
  {
@@ -243,7 +243,7 @@ void SVFIRBuilder::initialiseNodes()
243
243
  {
244
244
  const CallGraphNode* cgn = llvmModuleSet()->getCallGraphNode(func);
245
245
  // add value node representing the function
246
- pag->addFunValNode(cgn, iter->second, icfgNode);
246
+ pag->addFunValNode(iter->second, icfgNode, cgn);
247
247
  }
248
248
  else if (auto argval = SVFUtil::dyn_cast<Argument>(llvmValue))
249
249
  {
@@ -256,13 +256,13 @@ void SVFIRBuilder::initialiseNodes()
256
256
  }
257
257
  else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
258
258
  {
259
- pag->addConstantFPValNode(iter->first, LLVMUtil::getDoubleValue(fpValue), iter->second, icfgNode);
259
+ pag->addConstantFPValNode(iter->first, iter->second, LLVMUtil::getDoubleValue(fpValue), icfgNode);
260
260
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
261
261
  fpValue, pag->getGNode(iter->second));
262
262
  }
263
263
  else if (auto intValue = SVFUtil::dyn_cast<ConstantInt>(llvmValue))
264
264
  {
265
- pag->addConstantIntValNode(iter->first, LLVMUtil::getIntegerValue(intValue), iter->second, icfgNode);
265
+ pag->addConstantIntValNode(iter->first, iter->second, LLVMUtil::getIntegerValue(intValue), icfgNode);
266
266
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
267
267
  intValue, pag->getGNode(iter->second));
268
268
  }
@@ -309,14 +309,14 @@ void SVFIRBuilder::initialiseNodes()
309
309
  // Check if the value is a function and add a function object node
310
310
  if (const Function* func = SVFUtil::dyn_cast<Function>(llvmValue))
311
311
  {
312
- pag->addFunObjNode(llvmModuleSet()->getCallGraphNode(func), iter->second);
312
+ pag->addFunObjNode(iter->second, llvmModuleSet()->getCallGraphNode(func));
313
313
  }
314
314
  // Check if the value is a heap object and add a heap object node
315
315
  else if (LLVMUtil::isHeapObj(llvmValue))
316
316
  {
317
317
  const SVFFunction* f =
318
318
  SVFUtil::cast<SVFInstruction>(iter->first)->getFunction();
319
- pag->addHeapObjNode(iter->first, f, iter->second);
319
+ pag->addHeapObjNode(iter->first, iter->second, f);
320
320
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
321
321
  llvmValue, pag->getGNode(iter->second));
322
322
  }
@@ -325,19 +325,19 @@ void SVFIRBuilder::initialiseNodes()
325
325
  {
326
326
  const SVFFunction* f =
327
327
  SVFUtil::cast<SVFInstruction>(iter->first)->getFunction();
328
- pag->addStackObjNode(iter->first, f, iter->second);
328
+ pag->addStackObjNode(iter->first, iter->second, f);
329
329
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
330
330
  llvmValue, pag->getGNode(iter->second));
331
331
  }
332
332
  else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
333
333
  {
334
- pag->addConstantFPObjNode(iter->first, LLVMUtil::getDoubleValue(fpValue), iter->second);
334
+ pag->addConstantFPObjNode(iter->first, iter->second, LLVMUtil::getDoubleValue(fpValue));
335
335
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
336
336
  fpValue, pag->getGNode(iter->second));
337
337
  }
338
338
  else if (auto intValue = SVFUtil::dyn_cast<ConstantInt>(llvmValue))
339
339
  {
340
- pag->addConstantIntObjNode(iter->first, LLVMUtil::getIntegerValue(intValue), iter->second);
340
+ pag->addConstantIntObjNode(iter->first, iter->second, LLVMUtil::getIntegerValue(intValue));
341
341
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
342
342
  intValue, pag->getGNode(iter->second));
343
343
  }
@@ -371,10 +371,9 @@ void SVFIRBuilder::initialiseNodes()
371
371
  ++iter)
372
372
  {
373
373
  DBOUT(DPAGBuild, outs() << "add ret node " << iter->second << "\n");
374
- pag->addRetNode(
375
- llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
376
- llvmModuleSet()->getLLVMValue(iter->first))),
377
- iter->second);
374
+ pag->addRetNode(iter->second,
375
+ llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
376
+ llvmModuleSet()->getLLVMValue(iter->first))));
378
377
  }
379
378
 
380
379
  for (SymbolTableInfo::FunToIDMapTy::iterator iter =
@@ -382,10 +381,9 @@ void SVFIRBuilder::initialiseNodes()
382
381
  iter != symTable->varargSyms().end(); ++iter)
383
382
  {
384
383
  DBOUT(DPAGBuild, outs() << "add vararg node " << iter->second << "\n");
385
- pag->addVarargNode(
386
- llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
387
- llvmModuleSet()->getLLVMValue(iter->first))),
388
- iter->second);
384
+ pag->addVarargNode(iter->second,
385
+ llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
386
+ llvmModuleSet()->getLLVMValue(iter->first))));
389
387
  }
390
388
 
391
389
  /// add address edges for constant nodes.
@@ -65,7 +65,7 @@ const Type* SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value* V, std::vec
65
65
  {
66
66
  SymbolTableBuilder builder(pag->getSymbolInfo());
67
67
  builder.collectSym(offset);
68
- pag->addConstantIntValNode(svfOffset, LLVMUtil::getIntegerValue(offset), pag->getSymbolInfo()->getValSym(svfOffset), nullptr);
68
+ pag->addConstantIntValNode(svfOffset, pag->getSymbolInfo()->getValSym(svfOffset), LLVMUtil::getIntegerValue(offset), nullptr);
69
69
  }
70
70
  ls.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(svfOffset)), nullptr);
71
71
  fields.push_back(ls);