svf-lib 1.0.1809 → 1.0.1810
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
|
|
@@ -321,6 +321,8 @@ private:
|
|
|
321
321
|
AddrStmt(const AddrStmt&); ///< place holder
|
|
322
322
|
void operator=(const AddrStmt&); ///< place holder
|
|
323
323
|
|
|
324
|
+
std::vector<SVFValue*> arrSize; ///< Array size of the allocated memory
|
|
325
|
+
|
|
324
326
|
public:
|
|
325
327
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
326
328
|
//@{
|
|
@@ -343,6 +345,17 @@ public:
|
|
|
343
345
|
|
|
344
346
|
virtual const std::string toString() const override;
|
|
345
347
|
|
|
348
|
+
inline void addArrSize(SVFValue* size) //TODO:addSizeVar
|
|
349
|
+
{
|
|
350
|
+
arrSize.push_back(size);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
///< get array size of the allocated memory
|
|
354
|
+
inline const std::vector<SVFValue*>& getArrSize() const //TODO:getSizeVars
|
|
355
|
+
{
|
|
356
|
+
return arrSize;
|
|
357
|
+
}
|
|
358
|
+
|
|
346
359
|
};
|
|
347
360
|
|
|
348
361
|
/*!
|
|
@@ -298,6 +298,66 @@ protected:
|
|
|
298
298
|
}
|
|
299
299
|
return nullptr;
|
|
300
300
|
}
|
|
301
|
+
|
|
302
|
+
/// Add Address edge from allocinst with arraysize like "%4 = alloca i8, i64 3"
|
|
303
|
+
inline AddrStmt* addAddrWithStackArraySz(NodeID src, NodeID dst, llvm::AllocaInst& inst)
|
|
304
|
+
{
|
|
305
|
+
AddrStmt* edge = addAddrEdge(src, dst);
|
|
306
|
+
if (inst.getArraySize())
|
|
307
|
+
{
|
|
308
|
+
SVFValue* arrSz = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(inst.getArraySize());
|
|
309
|
+
edge->addArrSize(arrSz);
|
|
310
|
+
}
|
|
311
|
+
return edge;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/// Add Address edge from ext call with args like "%5 = call i8* @malloc(i64 noundef 5)"
|
|
315
|
+
inline AddrStmt* addAddrWithHeapSz(NodeID src, NodeID dst, const CallBase* cs)
|
|
316
|
+
{
|
|
317
|
+
// get name of called function
|
|
318
|
+
AddrStmt* edge = addAddrEdge(src, dst);
|
|
319
|
+
|
|
320
|
+
llvm::Function* calledFunc = cs->getCalledFunction();
|
|
321
|
+
std::string functionName;
|
|
322
|
+
if (calledFunc)
|
|
323
|
+
{
|
|
324
|
+
functionName = calledFunc->getName().str();
|
|
325
|
+
}
|
|
326
|
+
else
|
|
327
|
+
{
|
|
328
|
+
SVFUtil::wrnMsg("not support indirect call to add AddrStmt.\n");
|
|
329
|
+
}
|
|
330
|
+
if (functionName == "malloc")
|
|
331
|
+
{
|
|
332
|
+
if (cs->arg_size() > 0)
|
|
333
|
+
{
|
|
334
|
+
const llvm::Value* val = cs->getArgOperand(0);
|
|
335
|
+
SVFValue* svfval = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val);
|
|
336
|
+
edge->addArrSize(svfval);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
// Check if the function called is 'calloc' and process its arguments.
|
|
340
|
+
// e.g. "%5 = call i8* @calloc(1, 8)", edge should add two SVFValue (1 and 8)
|
|
341
|
+
else if (functionName == "calloc")
|
|
342
|
+
{
|
|
343
|
+
if (cs->arg_size() > 1)
|
|
344
|
+
{
|
|
345
|
+
edge->addArrSize(LLVMModuleSet::getLLVMModuleSet()->getSVFValue(cs->getArgOperand(0)));
|
|
346
|
+
edge->addArrSize(LLVMModuleSet::getLLVMModuleSet()->getSVFValue(cs->getArgOperand(1)));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
else
|
|
350
|
+
{
|
|
351
|
+
if (cs->arg_size() > 0)
|
|
352
|
+
{
|
|
353
|
+
const llvm::Value* val = cs->getArgOperand(0);
|
|
354
|
+
SVFValue* svfval = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(val);
|
|
355
|
+
edge->addArrSize(svfval);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return edge;
|
|
359
|
+
}
|
|
360
|
+
|
|
301
361
|
/// Add Copy edge
|
|
302
362
|
inline CopyStmt* addCopyEdge(NodeID src, NodeID dst)
|
|
303
363
|
{
|