svf-tools 1.0.1029 → 1.0.1030

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.1029",
3
+ "version": "1.0.1030",
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": {
@@ -529,8 +529,7 @@ public:
529
529
  };
530
530
 
531
531
  /*
532
- * Field-insensitive Gep Obj variable, this is dynamic generated for field sensitive analysis
533
- * Each field-insensitive gep obj node represents all fields of a MemObj (base)
532
+ * Base memory object variable (address-taken variables in LLVM-based languages)
534
533
  */
535
534
  class BaseObjVar : public ObjVar
536
535
  {
@@ -540,7 +539,7 @@ class BaseObjVar : public ObjVar
540
539
  private:
541
540
  ObjTypeInfo* typeInfo;
542
541
 
543
- const SVFBaseNode* gNode;
542
+ const ICFGNode* icfgNode; /// ICFGNode related to the creation of this object
544
543
 
545
544
  protected:
546
545
  /// Constructor to create empty ObjVar (for SVFIRReader/deserialization)
@@ -571,7 +570,7 @@ public:
571
570
  }
572
571
  //@}
573
572
 
574
- /// Constructorx
573
+ /// Constructor
575
574
  BaseObjVar(const SVFValue* val, NodeID i, ObjTypeInfo* ti, PNODEK ty = BaseObjNode)
576
575
  : ObjVar(val, i, ty), typeInfo(ti)
577
576
  {
@@ -582,10 +581,10 @@ public:
582
581
  return this;
583
582
  }
584
583
 
585
- /// Get the reference value to this object
586
- inline const SVFBaseNode* getGNode() const
584
+ /// Get the ICFGNode related to the creation of this object
585
+ inline const ICFGNode* getICFGNode() const
587
586
  {
588
- return gNode;
587
+ return icfgNode;
589
588
  }
590
589
 
591
590
  /// Return name of a LLVM value
@@ -70,8 +70,7 @@ void BufOverflowDetector::detect(AbstractState& as, const ICFGNode* node)
70
70
  }
71
71
  else
72
72
  {
73
- const ICFGNode* addrNode = SVFUtil::cast<ICFGNode>(
74
- svfir->getBaseObject(objId)->getGNode());
73
+ const ICFGNode* addrNode = svfir->getBaseObject(objId)->getICFGNode();
75
74
  for (const SVFStmt* stmt2 : addrNode->getSVFStmts())
76
75
  {
77
76
  if (const AddrStmt* addrStmt = SVFUtil::dyn_cast<AddrStmt>(stmt2))
@@ -472,8 +471,7 @@ bool BufOverflowDetector::canSafelyAccessMemory(AbstractState& as, const SVF::SV
472
471
  else
473
472
  {
474
473
  // if the object is not a constant size object, get the size from the addrStmt
475
- const ICFGNode* addrNode = SVFUtil::cast<ICFGNode>(
476
- svfir->getBaseObject(objId)->getGNode());
474
+ const ICFGNode* addrNode = svfir->getBaseObject(objId)->getICFGNode();
477
475
  for (const SVFStmt* stmt2 : addrNode->getSVFStmts())
478
476
  {
479
477
  if (const AddrStmt* addrStmt = SVFUtil::dyn_cast<AddrStmt>(stmt2))
@@ -284,7 +284,7 @@ void AbsExtAPI::initExtFunMap()
284
284
  }
285
285
  else
286
286
  {
287
- const ICFGNode* addrNode = SVFUtil::cast<ICFGNode>(svfir->getBaseObject(objId)->getGNode());
287
+ const ICFGNode* addrNode = svfir->getBaseObject(objId)->getICFGNode();
288
288
  for (const SVFStmt* stmt2: addrNode->getSVFStmts())
289
289
  {
290
290
  if (const AddrStmt* addrStmt = SVFUtil::dyn_cast<AddrStmt>(stmt2))
@@ -478,7 +478,7 @@ IntervalValue AbsExtAPI::getStrlen(AbstractState& as, const SVF::SVFVar *strValu
478
478
  }
479
479
  else
480
480
  {
481
- const ICFGNode* icfgNode = SVFUtil::cast<ICFGNode>( svfir->getBaseObject(objId)->getGNode());
481
+ const ICFGNode* icfgNode = svfir->getBaseObject(objId)->getICFGNode();
482
482
  for (const SVFStmt* stmt2: icfgNode->getSVFStmts())
483
483
  {
484
484
  if (const AddrStmt* addrStmt = SVFUtil::dyn_cast<AddrStmt>(stmt2))
@@ -356,19 +356,15 @@ bool ContextDDA::isHeapCondMemObj(const CxtVar& var, const StoreSVFGNode*)
356
356
  }
357
357
  return true;
358
358
  }
359
- else if(const SVFBaseNode* gNode = obj->getGNode())
359
+ else if(const ICFGNode* node = obj->getICFGNode())
360
360
  {
361
- if (const auto& node =
362
- SVFUtil::dyn_cast<ICFGNode>(gNode))
363
- {
364
- const SVFFunction* svfFun = node->getFun();
365
- if(_ander->isInRecursion(svfFun))
366
- return true;
367
- if(var.get_cond().isConcreteCxt() == false)
368
- return true;
369
- if(_pag->getICFG()->isInLoop(node))
370
- return true;
371
- }
361
+ const SVFFunction* svfFun = node->getFun();
362
+ if(_ander->isInRecursion(svfFun))
363
+ return true;
364
+ if(var.get_cond().isConcreteCxt() == false)
365
+ return true;
366
+ if(_pag->getICFG()->isInLoop(node))
367
+ return true;
372
368
  }
373
369
  }
374
370
  return false;
@@ -86,7 +86,7 @@ void ThreadCallGraph::updateCallGraph(PointerAnalysis* pta)
86
86
  const BaseObjVar* obj = pag->getBaseObject(objPN->getId());
87
87
  if(obj->isFunction())
88
88
  {
89
- const SVFFunction* svfCallee = SVFUtil::cast<CallGraphNode>(obj->getGNode())->getFunction();
89
+ const SVFFunction* svfCallee = SVFUtil::cast<FunObjVar>(obj)->getFunction();
90
90
  this->addIndirectForkEdge(*it, svfCallee);
91
91
  }
92
92
  }
@@ -541,7 +541,7 @@ void BVDataPTAImpl::onTheFlyThreadCallGraphSolve(const CallSiteToFunPtrMap& call
541
541
  const BaseObjVar* obj = pag->getBaseObject(objPN->getId());
542
542
  if(obj->isFunction())
543
543
  {
544
- const SVFFunction *svfForkedFun = SVFUtil::cast<CallGraphNode>(obj->getGNode())->getFunction();
544
+ const SVFFunction *svfForkedFun = SVFUtil::cast<FunObjVar>(obj)->getFunction();
545
545
  if(tdCallGraph->addIndirectForkEdge(*it, svfForkedFun))
546
546
  newForkEdges[*it].insert(svfForkedFun);
547
547
  }
@@ -190,17 +190,17 @@ public:
190
190
  inline void addInstructionMap(const Instruction* inst, CallICFGNode* svfInst)
191
191
  {
192
192
  CSToCallNodeMap[inst] = svfInst;
193
- addToLLVMVal2SVFVarMap(inst, svfInst);
193
+ addToSVFVar2LLVMValueMap(inst, svfInst);
194
194
  }
195
195
  inline void addInstructionMap(const Instruction* inst, RetICFGNode* svfInst)
196
196
  {
197
197
  CSToRetNodeMap[inst] = svfInst;
198
- addToLLVMVal2SVFVarMap(inst, svfInst);
198
+ addToSVFVar2LLVMValueMap(inst, svfInst);
199
199
  }
200
200
  inline void addInstructionMap(const Instruction* inst, IntraICFGNode* svfInst)
201
201
  {
202
202
  InstToBlockNodeMap[inst] = svfInst;
203
- addToLLVMVal2SVFVarMap(inst, svfInst);
203
+ addToSVFVar2LLVMValueMap(inst, svfInst);
204
204
  }
205
205
 
206
206
  inline void addArgumentMap(const Argument* arg, SVFArgument* svfArg)
@@ -426,7 +426,7 @@ private:
426
426
  void initSVFBasicBlock(const Function* func);
427
427
  void initDomTree(SVFFunction* func, const Function* f);
428
428
  void setValueAttr(const Value* val, SVFValue* value);
429
- void addToLLVMVal2SVFVarMap(const Value* val, SVFBaseNode* svfBaseNode);
429
+ void addToSVFVar2LLVMValueMap(const Value* val, SVFBaseNode* svfBaseNode);
430
430
  void buildFunToFunMap();
431
431
  void buildGlobalDefToRepMap();
432
432
  /// Invoke llvm passes to modify module
@@ -273,7 +273,7 @@ protected:
273
273
  LLVMContext& cxt = llvmModuleSet()->getContext();
274
274
  ConstantPointerNull* constNull = ConstantPointerNull::get(PointerType::getUnqual(cxt));
275
275
  NodeID nullPtr = pag->addConstantNullPtrValNode(llvmModuleSet()->getSVFValue(constNull),pag->getNullPtr(), nullptr);
276
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
276
+ llvmModuleSet()->addToSVFVar2LLVMValueMap(
277
277
  constNull, pag->getGNode(pag->getNullPtr()));
278
278
  setCurrentLocation(constNull, nullptr);
279
279
  addBlackHoleAddrEdge(pag->getBlkPtr());
@@ -1222,7 +1222,7 @@ void LLVMModuleSet::dumpModulesToFile(const std::string& suffix)
1222
1222
  void LLVMModuleSet::addFunctionMap(const Function* func, CallGraphNode* svfFunc)
1223
1223
  {
1224
1224
  LLVMFunc2CallGraphNode[func] = svfFunc;
1225
- addToLLVMVal2SVFVarMap(func, svfFunc);
1225
+ addToSVFVar2LLVMValueMap(func, svfFunc);
1226
1226
  }
1227
1227
 
1228
1228
  void LLVMModuleSet::setValueAttr(const Value* val, SVFValue* svfvalue)
@@ -1253,7 +1253,7 @@ void LLVMModuleSet::setValueAttr(const Value* val, SVFValue* svfvalue)
1253
1253
  svfvalue->setSourceLoc(LLVMUtil::getSourceLoc(val));
1254
1254
  }
1255
1255
 
1256
- void LLVMModuleSet::addToLLVMVal2SVFVarMap(const Value* val,
1256
+ void LLVMModuleSet::addToSVFVar2LLVMValueMap(const Value* val,
1257
1257
  SVFBaseNode* svfBaseNode)
1258
1258
  {
1259
1259
  SVFBaseNode2LLVMValue[svfBaseNode] = val;
@@ -232,44 +232,33 @@ void SVFIRBuilder::initialiseNodes()
232
232
  iter->second, argval->getArgNo(), icfgNode,
233
233
  llvmModuleSet()->getCallGraphNode(argval->getParent()),
234
234
  LLVMUtil::isArgOfUncalledFunction(argval));
235
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
236
- argval, pag->getGNode(iter->second));
237
235
  }
238
236
  else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
239
237
  {
240
238
  pag->addConstantFPValNode(iter->first, iter->second, LLVMUtil::getDoubleValue(fpValue), icfgNode);
241
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
242
- fpValue, pag->getGNode(iter->second));
243
239
  }
244
240
  else if (auto intValue = SVFUtil::dyn_cast<ConstantInt>(llvmValue))
245
241
  {
246
242
  pag->addConstantIntValNode(iter->first, iter->second, LLVMUtil::getIntegerValue(intValue), icfgNode);
247
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
248
- intValue, pag->getGNode(iter->second));
249
243
  }
250
- else if (auto nullValue = SVFUtil::dyn_cast<ConstantPointerNull>(llvmValue))
244
+ else if (SVFUtil::isa<ConstantPointerNull>(llvmValue))
251
245
  {
252
246
  pag->addConstantNullPtrValNode(iter->first, iter->second, icfgNode);
253
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
254
- nullValue, pag->getGNode(iter->second));
255
247
  }
256
- else if (auto globalValue = SVFUtil::dyn_cast<GlobalValue>(llvmValue))
248
+ else if (SVFUtil::isa<GlobalValue>(llvmValue))
257
249
  {
258
250
  pag->addGlobalValueValNode(iter->first, iter->second, icfgNode);
259
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
260
- globalValue, pag->getGNode(iter->second));
261
251
  }
262
- else if (auto dataValue = SVFUtil::dyn_cast<ConstantData>(llvmValue))
252
+ else if (SVFUtil::isa<ConstantData>(llvmValue))
263
253
  {
264
254
  pag->addConstantDataValNode(iter->first, iter->second, icfgNode);
265
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
266
- dataValue, pag->getGNode(iter->second));
267
255
  }
268
256
  else
269
257
  {
270
258
  // Add value node to PAG
271
259
  pag->addValNode(iter->first, iter->second, icfgNode);
272
260
  }
261
+ llvmModuleSet()->addToSVFVar2LLVMValueMap(llvmValue, pag->getGNode(iter->second));
273
262
  }
274
263
 
275
264
  // Iterate over all object symbols in the symbol table
@@ -287,6 +276,13 @@ void SVFIRBuilder::initialiseNodes()
287
276
  // Get the LLVM value corresponding to the symbol
288
277
  const Value* llvmValue = llvmModuleSet()->getLLVMValue(iter->first);
289
278
 
279
+ const ICFGNode* icfgNode = nullptr;
280
+ if (const Instruction* inst = SVFUtil::dyn_cast<Instruction>(llvmValue))
281
+ {
282
+ if(llvmModuleSet()->hasICFGNode(inst))
283
+ icfgNode = llvmModuleSet()->getICFGNode(inst);
284
+ }
285
+
290
286
  // Check if the value is a function and add a function object node
291
287
  if (const Function* func = SVFUtil::dyn_cast<Function>(llvmValue))
292
288
  {
@@ -300,8 +296,6 @@ void SVFIRBuilder::initialiseNodes()
300
296
  const SVFFunction* f =
301
297
  SVFUtil::cast<SVFInstruction>(iter->first)->getFunction();
302
298
  pag->addHeapObjNode(iter->first, iter->second, symTable->getObjTypeInfo(id), f);
303
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
304
- llvmValue, pag->getGNode(iter->second));
305
299
  }
306
300
  // Check if the value is an alloca instruction and add a stack object node
307
301
  else if (LLVMUtil::isStackObj(llvmValue))
@@ -310,43 +304,31 @@ void SVFIRBuilder::initialiseNodes()
310
304
  const SVFFunction* f =
311
305
  SVFUtil::cast<SVFInstruction>(iter->first)->getFunction();
312
306
  pag->addStackObjNode(iter->first, iter->second, symTable->getObjTypeInfo(id), f);
313
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
314
- llvmValue, pag->getGNode(iter->second));
315
307
  }
316
308
  else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
317
309
  {
318
310
  NodeID id = symTable->getObjSym(iter->first);
319
311
  pag->addConstantFPObjNode(iter->first, iter->second, symTable->getObjTypeInfo(id), LLVMUtil::getDoubleValue(fpValue));
320
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
321
- fpValue, pag->getGNode(iter->second));
322
312
  }
323
313
  else if (auto intValue = SVFUtil::dyn_cast<ConstantInt>(llvmValue))
324
314
  {
325
315
  NodeID id = symTable->getObjSym(iter->first);
326
316
  pag->addConstantIntObjNode(iter->first, iter->second, symTable->getObjTypeInfo(id), LLVMUtil::getIntegerValue(intValue));
327
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
328
- intValue, pag->getGNode(iter->second));
329
317
  }
330
- else if (auto nullValue = SVFUtil::dyn_cast<ConstantPointerNull>(llvmValue))
318
+ else if (SVFUtil::isa<ConstantPointerNull>(llvmValue))
331
319
  {
332
320
  NodeID id = symTable->getObjSym(iter->first);
333
321
  pag->addConstantNullPtrObjNode(iter->first, iter->second, symTable->getObjTypeInfo(id));
334
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
335
- nullValue, pag->getGNode(iter->second));
336
322
  }
337
- else if (auto globalValue = SVFUtil::dyn_cast<GlobalValue>(llvmValue))
323
+ else if (SVFUtil::isa<GlobalValue>(llvmValue))
338
324
  {
339
325
  NodeID id = symTable->getObjSym(iter->first);
340
326
  pag->addGlobalValueObjNode(iter->first, iter->second, symTable->getObjTypeInfo(id));
341
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
342
- globalValue, pag->getGNode(iter->second));
343
327
  }
344
- else if (auto dataValue = SVFUtil::dyn_cast<ConstantData>(llvmValue))
328
+ else if (SVFUtil::isa<ConstantData>(llvmValue))
345
329
  {
346
330
  NodeID id = symTable->getObjSym(iter->first);
347
331
  pag->addConstantDataObjNode(iter->first, iter->second, symTable->getObjTypeInfo(id));
348
- llvmModuleSet()->addToLLVMVal2SVFVarMap(
349
- dataValue, pag->getGNode(iter->second));
350
332
  }
351
333
  // Add a generic object node for other types of values
352
334
  else
@@ -354,25 +336,12 @@ void SVFIRBuilder::initialiseNodes()
354
336
  NodeID id = symTable->getObjSym(iter->first);
355
337
  pag->addObjNode(iter->first, iter->second, symTable->getObjTypeInfo(id));
356
338
  }
357
- }
339
+ llvmModuleSet()->addToSVFVar2LLVMValueMap(llvmValue, pag->getGNode(iter->second));
358
340
 
359
- for (auto& it : SymbolTableInfo::SymbolInfo()->idToObjTypeInfoMap())
360
- {
361
- NodeID id = it.first;
362
- if (BaseObjVar* obj = SVFUtil::dyn_cast<BaseObjVar>(pag->getGNode(id)))
341
+ if (BaseObjVar* baseObjVar =
342
+ SVFUtil::dyn_cast<BaseObjVar>(pag->getGNode(iter->second)))
363
343
  {
364
- if (!obj->hasValue())
365
- continue;
366
-
367
- if (const Instruction* inst = SVFUtil::dyn_cast<Instruction>(llvmModuleSet()->getLLVMValue(obj->getValue())))
368
- {
369
- if(llvmModuleSet()->hasICFGNode(inst))
370
- obj->gNode = llvmModuleSet()->getICFGNode(inst);
371
- }
372
- else if (const Function* func = SVFUtil::dyn_cast<Function>(llvmModuleSet()->getLLVMValue(obj->getValue())))
373
- {
374
- obj->gNode = llvmModuleSet()->getCallGraphNode(func);
375
- }
344
+ baseObjVar->icfgNode = icfgNode;
376
345
  }
377
346
  }
378
347
 
@@ -384,6 +353,7 @@ void SVFIRBuilder::initialiseNodes()
384
353
  pag->addRetNode(iter->second,
385
354
  llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
386
355
  llvmModuleSet()->getLLVMValue(iter->first))));
356
+ llvmModuleSet()->addToSVFVar2LLVMValueMap(llvmModuleSet()->getLLVMValue(iter->first), pag->getGNode(iter->second));
387
357
  }
388
358
 
389
359
  for (SymbolTableInfo::FunToIDMapTy::iterator iter =
@@ -394,6 +364,7 @@ void SVFIRBuilder::initialiseNodes()
394
364
  pag->addVarargNode(iter->second,
395
365
  llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
396
366
  llvmModuleSet()->getLLVMValue(iter->first))));
367
+ llvmModuleSet()->addToSVFVar2LLVMValueMap(llvmModuleSet()->getLLVMValue(iter->first), pag->getGNode(iter->second));
397
368
  }
398
369
 
399
370
  /// add address edges for constant nodes.