svf-tools 1.0.1001 → 1.0.1002

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.1001",
3
+ "version": "1.0.1002",
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": {
@@ -58,11 +58,11 @@ private:
58
58
  public:
59
59
  typedef FIFOWorkList<const Instruction*> WorkList;
60
60
 
61
- ICFGBuilder(ICFG* i): icfg(i)
61
+ ICFGBuilder(): icfg(new ICFG())
62
62
  {
63
63
 
64
64
  }
65
- void build();
65
+ ICFG* build();
66
66
 
67
67
  private:
68
68
 
@@ -76,6 +76,7 @@ private:
76
76
  static bool preProcessed;
77
77
  SymbolTableInfo* symInfo;
78
78
  SVFModule* svfModule; ///< Borrowed from singleton SVFModule::svfModule
79
+ ICFG* icfg;
79
80
  std::unique_ptr<LLVMContext> owned_ctx;
80
81
  std::vector<std::unique_ptr<Module>> owned_modules;
81
82
  std::vector<std::reference_wrapper<Module>> modules;
@@ -362,6 +363,11 @@ public:
362
363
 
363
364
  ObjTypeInference* getTypeInference();
364
365
 
366
+ inline ICFG* getICFG()
367
+ {
368
+ return icfg;
369
+ }
370
+
365
371
  private:
366
372
  /// Create SVFTypes
367
373
  SVFType* addSVFTypeInfo(const Type* t);
@@ -40,7 +40,7 @@ using namespace SVFUtil;
40
40
  /*!
41
41
  * Create ICFG nodes and edges
42
42
  */
43
- void ICFGBuilder::build()
43
+ ICFG* ICFGBuilder::build()
44
44
  {
45
45
  DBOUT(DGENERAL, outs() << pasMsg("\t Building ICFG ...\n"));
46
46
  // Add the unique global ICFGNode at the entry of a program (before the main method).
@@ -78,6 +78,7 @@ void ICFGBuilder::build()
78
78
 
79
79
  }
80
80
  connectGlobalToProgEntry();
81
+ return icfg;
81
82
  }
82
83
 
83
84
  void ICFGBuilder::checkICFGNodesVisited(const Function* fun)
@@ -235,8 +236,6 @@ void ICFGBuilder::processFunExit(const Function* f)
235
236
  */
236
237
  InterICFGNode* ICFGBuilder::addInterBlockICFGNode(const Instruction* inst)
237
238
  {
238
- SVFInstruction* svfInst =
239
- llvmModuleSet()->getSVFInstruction(inst);
240
239
  assert(LLVMUtil::isCallSite(inst) && "not a call instruction?");
241
240
  assert(LLVMUtil::isNonInstricCallSite(inst) && "associating an intrinsic debug instruction with an ICFGNode!");
242
241
  assert(llvmModuleSet()->getCallBlock(inst)==nullptr && "duplicate CallICFGNode");
@@ -254,8 +253,10 @@ InterICFGNode* ICFGBuilder::addInterBlockICFGNode(const Instruction* inst)
254
253
  llvmModuleSet()->getSVFValue(called_llvmval));
255
254
  }
256
255
 
256
+ SVFBasicBlock* bb = llvmModuleSet()->getSVFBasicBlock(inst->getParent());
257
+
257
258
  CallICFGNode* callICFGNode = icfg->addCallICFGNode(
258
- svfInst->getParent(), llvmModuleSet()->getSVFType(inst->getType()),
259
+ bb, llvmModuleSet()->getSVFType(inst->getType()),
259
260
  calledFunc, cb->getFunctionType()->isVarArg(), isvcall,
260
261
  isvcall ? cppUtil::getVCallIdx(cb) : 0,
261
262
  isvcall ? cppUtil::getFunNameOfVCallSite(cb) : "");
@@ -330,25 +331,22 @@ void ICFGBuilder::connectGlobalToProgEntry()
330
331
  inline ICFGNode* ICFGBuilder::addBlockICFGNode(const Instruction* inst)
331
332
  {
332
333
  ICFGNode* node;
333
- SVFInstruction* svfINst =
334
- llvmModuleSet()->getSVFInstruction(inst);
335
334
  if(LLVMUtil::isNonInstricCallSite(inst))
336
335
  node = addInterBlockICFGNode(inst);
337
336
  else
338
337
  node = addIntraBlockICFGNode(inst);
339
- const_cast<SVFBasicBlock*>(svfINst->getParent())
338
+ const_cast<SVFBasicBlock*>(
339
+ llvmModuleSet()->getSVFBasicBlock(inst->getParent()))
340
340
  ->addICFGNode(node);
341
341
  return node;
342
342
  }
343
343
 
344
344
  IntraICFGNode* ICFGBuilder::addIntraBlockICFGNode(const Instruction* inst)
345
345
  {
346
- SVFInstruction* svfInst =
347
- llvmModuleSet()->getSVFInstruction(inst);
348
346
  IntraICFGNode* node = llvmModuleSet()->getIntraBlock(inst);
349
347
  assert (node==nullptr && "no IntraICFGNode for this instruction?");
350
348
  IntraICFGNode* sNode = icfg->addIntraICFGNode(
351
- svfInst->getParent(), SVFUtil::isa<ReturnInst>(inst));
349
+ llvmModuleSet()->getSVFBasicBlock(inst->getParent()), SVFUtil::isa<ReturnInst>(inst));
352
350
  instToBlockNodeMap()[inst] = sNode;
353
351
  llvmModuleSet()->setValueAttr(inst, sNode);
354
352
  return sNode;
@@ -40,6 +40,7 @@
40
40
  #include "llvm/Support/FileSystem.h"
41
41
  #include "SVF-LLVM/ObjTypeInference.h"
42
42
  #include "llvm/Transforms/Utils/Cloning.h"
43
+ #include "SVF-LLVM/ICFGBuilder.h"
43
44
 
44
45
  using namespace std;
45
46
  using namespace SVF;
@@ -166,6 +167,8 @@ void LLVMModuleSet::build()
166
167
 
167
168
  createSVFDataStructure();
168
169
  initSVFFunction();
170
+ ICFGBuilder icfgbuilder;
171
+ icfg = icfgbuilder.build();
169
172
  }
170
173
 
171
174
  void LLVMModuleSet::createSVFDataStructure()
@@ -60,10 +60,7 @@ SVFIR* SVFIRBuilder::build()
60
60
  pag->setModule(svfModule);
61
61
 
62
62
  // Build ICFG
63
- ICFG* icfg = new ICFG();
64
- ICFGBuilder icfgbuilder(icfg);
65
- icfgbuilder.build();
66
- pag->setICFG(icfg);
63
+ pag->setICFG(llvmModuleSet()->getICFG());
67
64
 
68
65
  // Set icfgnode in memobj
69
66
  for (auto& it : SymbolTableInfo::SymbolInfo()->idToObjMap())