svf-tools 1.0.685 → 1.0.687

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.685",
3
+ "version": "1.0.687",
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": {
@@ -179,6 +179,7 @@ public:
179
179
  return lhs;
180
180
  else
181
181
  assert(false && "undefined operation +oo + -oo");
182
+ abort();
182
183
  }
183
184
 
184
185
  friend BoundedZ3Expr operator-(const BoundedZ3Expr &lhs)
@@ -198,6 +199,7 @@ public:
198
199
  return lhs;
199
200
  else
200
201
  assert(false && "undefined operation +oo - +oo");
202
+ abort();
201
203
  }
202
204
 
203
205
  friend BoundedZ3Expr operator*(const BoundedZ3Expr &lhs, const BoundedZ3Expr &rhs)
@@ -225,7 +227,7 @@ public:
225
227
  else
226
228
  // TODO: +oo/-oo L'Hôpital's rule?
227
229
  return eq(lhs, rhs) ? plus_infinity() : minus_infinity();
228
-
230
+ abort();
229
231
  }
230
232
 
231
233
  friend BoundedZ3Expr operator%(const BoundedZ3Expr &lhs, const BoundedZ3Expr &rhs)
@@ -241,6 +243,7 @@ public:
241
243
  else
242
244
  // TODO: +oo/-oo L'Hôpital's rule?
243
245
  return eq(lhs, rhs) ? plus_infinity() : minus_infinity();
246
+ abort();
244
247
  }
245
248
 
246
249
  friend BoundedZ3Expr operator^(const BoundedZ3Expr &lhs, const BoundedZ3Expr &rhs)
@@ -140,6 +140,7 @@ public:
140
140
  else
141
141
  {
142
142
  assert(false && "other literal?");
143
+ abort();
143
144
  }
144
145
  }
145
146
 
@@ -408,7 +408,7 @@ private:
408
408
  cJSON* toJson(const LocationSet& ls);
409
409
  cJSON* toJson(const SVFLoop* loop);
410
410
  cJSON* toJson(const MemObj* memObj);
411
- cJSON* toJson(const ObjTypeInfo* objTypeInfo); // Ensures ownership
411
+ cJSON* toJson(const ObjTypeInfo* objTypeInfo); // Only owned by MemObj
412
412
  cJSON* toJson(const SVFLoopAndDomInfo* ldInfo); // Only owned by SVFFunction
413
413
  cJSON* toJson(const StInfo* type); // Ensure Only owned by SVFType
414
414
 
@@ -157,7 +157,7 @@ void LLVMModuleSet::build()
157
157
  void LLVMModuleSet::createSVFDataStructure()
158
158
  {
159
159
 
160
- for (Module& mod : modules)
160
+ for (const Module& mod : modules)
161
161
  {
162
162
  /// Function
163
163
  for (const Function& func : mod.functions())
@@ -325,49 +325,35 @@ void LLVMModuleSet::initDomTree(SVFFunction* svffun, const Function* fun)
325
325
  LLVMUtil::getFunReachableBBs(fun, reachableBBs);
326
326
  ld->setReachableBBs(reachableBBs);
327
327
 
328
- for (Function::const_iterator bit = fun->begin(), ebit = fun->end(); bit != ebit; ++bit)
328
+ for (const BasicBlock &bb : fun->getBasicBlockList())
329
329
  {
330
- const BasicBlock* bb = &*bit;
331
- SVFBasicBlock* svf_bb = getSVFBasicBlock(bb);
332
- if(DomTreeNode *dtNode = dt.getNode(const_cast<BasicBlock*>(bb)))
330
+ SVFBasicBlock* svfBB = getSVFBasicBlock(&bb);
331
+ if (DomTreeNode* dtNode = dt.getNode(&bb))
333
332
  {
334
- DomTreeNode::iterator DI = dtNode->begin();
335
- if (DI != dtNode->end())
333
+ SVFLoopAndDomInfo::BBSet& bbSet = ld->getDomTreeMap()[svfBB];
334
+ for (const auto domBB : *dtNode)
336
335
  {
337
- for (DomTreeNode::iterator DI = dtNode->begin(), DE = dtNode->end(); DI != DE; ++DI)
338
- {
339
- const SVFBasicBlock* dombb = getSVFBasicBlock((*DI)->getBlock());
340
- ld->getDomTreeMap()[svf_bb].insert(dombb);
341
- }
342
- }
343
- else
344
- {
345
- ld->getDomTreeMap()[svf_bb] = Set<const SVFBasicBlock* >();
336
+ const auto* domSVFBB = getSVFBasicBlock(domBB->getBlock());
337
+ bbSet.insert(domSVFBB);
346
338
  }
347
339
  }
348
340
 
349
- if(DomTreeNode * pdtNode = pdt.getNode(const_cast<BasicBlock*>(bb)))
341
+ if (DomTreeNode* pdtNode = pdt.getNode(&bb))
350
342
  {
351
- DomTreeNode::iterator DI = pdtNode->begin();
352
- if (DI != pdtNode->end())
343
+ SVFLoopAndDomInfo::BBSet& bbSet = ld->getPostDomTreeMap()[svfBB];
344
+ for (const auto domBB : *pdtNode)
353
345
  {
354
- for (DomTreeNode::iterator DI = pdtNode->begin(), DE = pdtNode->end(); DI != DE; ++DI)
355
- {
356
- const SVFBasicBlock* dombb = getSVFBasicBlock((*DI)->getBlock());
357
- ld->getPostDomTreeMap()[svf_bb].insert(dombb);
358
- }
359
- }
360
- else
361
- {
362
- ld->getPostDomTreeMap()[svf_bb] = Set<const SVFBasicBlock* >();
346
+ const auto* domSVFBB = getSVFBasicBlock(domBB->getBlock());
347
+ bbSet.insert(domSVFBB);
363
348
  }
364
349
  }
365
- if (const Loop *loop = loopInfo.getLoopFor(bb))
350
+
351
+ if (const Loop* loop = loopInfo.getLoopFor(&bb))
366
352
  {
367
- for (BasicBlock* loopBlock:loop->getBlocks())
353
+ for (const BasicBlock* loopBlock : loop->getBlocks())
368
354
  {
369
355
  const SVFBasicBlock* loopbb = getSVFBasicBlock(loopBlock);
370
- ld->addToBB2LoopMap(svf_bb,loopbb);
356
+ ld->addToBB2LoopMap(svfBB, loopbb);
371
357
  }
372
358
  }
373
359
  }
@@ -782,13 +768,6 @@ void LLVMModuleSet::buildGlobalDefToRepMap()
782
768
  : (assert(!globals.empty() && "Empty global set"),
783
769
  *globals.begin());
784
770
 
785
- for (Set<GlobalVariable*>::const_iterator sit = globals.begin(),
786
- seit = globals.end(); sit != seit; ++sit)
787
- {
788
- GlobalVariable *cur = *sit;
789
- GlobalDefToRepMap[cur] = rep;
790
- }
791
-
792
771
  for (const GlobalVariable* cur : globals)
793
772
  {
794
773
  GlobalDefToRepMap[cur] = rep;
@@ -1421,16 +1421,24 @@ void SVFIRBuilder::handleExtCall(CallBase* cs, const Function *callee)
1421
1421
  const Value* src = cs->getArgOperand(1);
1422
1422
  if(const GetElementPtrInst* gep = SVFUtil::dyn_cast<GetElementPtrInst>(src))
1423
1423
  src = stripConstantCasts(gep->getPointerOperand());
1424
- if(const GlobalVariable* glob = SVFUtil::dyn_cast<GlobalVariable>(src))
1424
+
1425
+ auto getHookFn = [](const Value* src)->const Function*
1426
+ {
1427
+ if (!SVFUtil::isa<GlobalVariable>(src))
1428
+ return nullptr;
1429
+
1430
+ auto *glob = SVFUtil::cast<GlobalVariable>(src);
1431
+ if (!glob->hasInitializer() || !SVFUtil::isa<ConstantDataArray>(glob->getInitializer()))
1432
+ return nullptr;
1433
+
1434
+ auto *constarray = SVFUtil::cast<ConstantDataArray>(glob->getInitializer());
1435
+ return LLVMUtil::getProgFunction(constarray->getAsCString().str());
1436
+ };
1437
+
1438
+ if (const Function *fn = getHookFn(src))
1425
1439
  {
1426
- if(const ConstantDataArray* constarray = SVFUtil::dyn_cast<ConstantDataArray>(glob->getInitializer()))
1427
- {
1428
- if(const Function* fun = LLVMUtil::getProgFunction(constarray->getAsCString().str()))
1429
- {
1430
- NodeID srcNode = getValueNode(fun);
1431
- addCopyEdge(srcNode, getValueNode(cs));
1432
- }
1433
- }
1440
+ NodeID srcNode = getValueNode(fn);
1441
+ addCopyEdge(srcNode, getValueNode(cs));
1434
1442
  }
1435
1443
  }
1436
1444
  else if (op.getOperator() == "Rb_tree_ops")