svf-tools 1.0.985 → 1.0.987

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.
@@ -509,7 +509,7 @@ void PointerAnalysis::validateSuccessTests(std::string fun)
509
509
 
510
510
  for(const CallICFGNode* callNode : pag->getCallSiteSet())
511
511
  {
512
- if (SVFUtil::getCallee(callNode) == checkFun)
512
+ if (callNode->getCalledFunction() == checkFun)
513
513
  {
514
514
  assert(callNode->getNumArgOperands() == 2
515
515
  && "arguments should be two pointers!!");
@@ -574,7 +574,7 @@ void PointerAnalysis::validateExpectedFailureTests(std::string fun)
574
574
 
575
575
  for(const CallICFGNode* callNode : pag->getCallSiteSet())
576
576
  {
577
- if (SVFUtil::getCallee(callNode) == checkFun)
577
+ if (callNode->getCalledFunction() == checkFun)
578
578
  {
579
579
  assert(callNode->arg_size() == 2
580
580
  && "arguments should be two pointers!!");
@@ -55,7 +55,7 @@ void DoubleFreeChecker::testsValidation(ProgSlice *slice)
55
55
  {
56
56
  const SVFGNode* source = slice->getSource();
57
57
  const CallICFGNode* cs = getSrcCSID(source);
58
- const SVFFunction* fun = getCallee(cs->getCallSite());
58
+ const SVFFunction* fun = cs->getCalledFunction();
59
59
  if(fun==nullptr)
60
60
  return;
61
61
  validateSuccessTests(slice,fun);
@@ -180,7 +180,7 @@ void LeakChecker::testsValidation(const ProgSlice* slice)
180
180
  {
181
181
  const SVFGNode* source = slice->getSource();
182
182
  const CallICFGNode* cs = getSrcCSID(source);
183
- const SVFFunction* fun = getCallee(cs->getCallSite());
183
+ const SVFFunction* fun = cs->getCalledFunction();
184
184
  if(fun==nullptr)
185
185
  return;
186
186
 
@@ -52,9 +52,9 @@ CallGraph* CallGraphBuilder::buildCallGraph(SVFModule* svfModule)
52
52
  {
53
53
  if (SVFUtil::isNonInstricCallSite(inst))
54
54
  {
55
- if(const SVFFunction* callee = getCallee(inst))
55
+ const CallICFGNode* callBlockNode = cast<CallICFGNode>(inst);
56
+ if(const SVFFunction* callee = callBlockNode->getCalledFunction())
56
57
  {
57
- const CallICFGNode* callBlockNode = cast<CallICFGNode>(inst);
58
58
  callgraph->addDirectCallGraphEdge(callBlockNode,*F,callee);
59
59
  }
60
60
  }
@@ -80,7 +80,7 @@ CallGraph* ThreadCallGraphBuilder::buildThreadCallGraph(SVFModule* svfModule)
80
80
  {
81
81
  for (const ICFGNode* inst : svfbb->getICFGNodeList())
82
82
  {
83
- if (tdAPI->isTDFork(inst))
83
+ if (SVFUtil::isa<CallICFGNode>(inst) && tdAPI->isTDFork(SVFUtil::cast<CallICFGNode>(inst)))
84
84
  {
85
85
  const CallICFGNode* cs = cast<CallICFGNode>(inst);
86
86
  cg->addForksite(cs);
@@ -105,7 +105,7 @@ CallGraph* ThreadCallGraphBuilder::buildThreadCallGraph(SVFModule* svfModule)
105
105
  {
106
106
  for (const ICFGNode* node : svfbb->getICFGNodeList())
107
107
  {
108
- if (tdAPI->isTDJoin(node))
108
+ if (SVFUtil::isa<CallICFGNode>(node) && tdAPI->isTDJoin(SVFUtil::cast<CallICFGNode>(node)))
109
109
  {
110
110
  const CallICFGNode* cs = SVFUtil::cast<CallICFGNode>(node);
111
111
  cg->addJoinsite(cs);
@@ -303,7 +303,8 @@ const std::string SVFBugEvent::getEventDescription() const
303
303
  case SVFBugEvent::CallSite:
304
304
  {
305
305
  std::string description("calls ");
306
- const SVFFunction *callee = SVFUtil::getCallee(eventInst);
306
+ assert(SVFUtil::isa<CallICFGNode>(eventInst) && "not a call ICFGNode?");
307
+ const SVFFunction *callee = SVFUtil::cast<CallICFGNode>(eventInst)->getCalledFunction();
307
308
  if(callee == nullptr)
308
309
  {
309
310
  description += "<unknown>";
@@ -343,24 +343,34 @@ bool SVFUtil::isIntrinsicInst(const ICFGNode* inst)
343
343
  return false;
344
344
  }
345
345
 
346
- const SVFFunction* SVFUtil::getCallee(const ICFGNode *inst)
346
+ bool SVFUtil::isExtCall(const CallICFGNode* cs)
347
347
  {
348
- if (!isCallSite(inst))
349
- return nullptr;
350
- const CallICFGNode* call = SVFUtil::cast<CallICFGNode>(inst);
351
- return call->getCalledFunction();
348
+ return isExtCall(cs->getCalledFunction());
352
349
  }
353
350
 
354
- const SVFFunction* SVFUtil::getCallee(const CallICFGNode *inst)
351
+ bool SVFUtil::isHeapAllocExtCallViaArg(const CallICFGNode* cs)
355
352
  {
356
- return inst->getCalledFunction();
353
+ return isHeapAllocExtFunViaArg(cs->getCalledFunction());
354
+ }
355
+
356
+ bool SVFUtil::isHeapAllocExtCallViaArg(const SVFInstruction *inst)
357
+ {
358
+ if(const SVFCallInst* call = SVFUtil::dyn_cast<SVFCallInst>(inst))
359
+ return isHeapAllocExtFunViaArg(call->getCalledFunction());
360
+ else
361
+ return false;
362
+ }
363
+
364
+ u32_t SVFUtil::getHeapAllocHoldingArgPosition(const CallICFGNode* cs)
365
+ {
366
+ return getHeapAllocHoldingArgPosition(cs->getCalledFunction());
357
367
  }
358
368
 
359
369
 
360
370
  bool SVFUtil::isExtCall(const ICFGNode* node)
361
371
  {
362
372
  if(!isCallSite(node)) return false;
363
- return isExtCall(getCallee(node));
373
+ return isExtCall(cast<CallICFGNode>(node)->getCalledFunction());
364
374
  }
365
375
 
366
376
  bool SVFUtil::isHeapAllocExtCall(const ICFGNode* cs)
@@ -372,13 +382,13 @@ bool SVFUtil::isHeapAllocExtCall(const ICFGNode* cs)
372
382
  bool SVFUtil::isHeapAllocExtCallViaRet(const CallICFGNode* cs)
373
383
  {
374
384
  bool isPtrTy = cs->getCallSite()->getType()->isPointerTy();
375
- return isPtrTy && isHeapAllocExtFunViaRet(getCallee(cs));
385
+ return isPtrTy && isHeapAllocExtFunViaRet(cs->getCalledFunction());
376
386
  }
377
387
 
378
388
  bool SVFUtil::isReallocExtCall(const CallICFGNode* cs)
379
389
  {
380
390
  bool isPtrTy = cs->getCallSite()->getType()->isPointerTy();
381
- return isPtrTy && isReallocExtFun(getCallee(cs));
391
+ return isPtrTy && isReallocExtFun(cs->getCalledFunction());
382
392
  }
383
393
 
384
394
  bool SVFUtil::isHeapAllocExtCallViaRet(const SVFInstruction *inst)
@@ -396,4 +406,9 @@ bool SVFUtil::isRetInstNode(const ICFGNode* node)
396
406
  return intraNode->getInst()->isRetInst();
397
407
  else
398
408
  return false;
409
+ }
410
+
411
+ bool SVFUtil::isProgExitCall(const CallICFGNode* cs)
412
+ {
413
+ return isProgExitFunction(cs->getCalledFunction());
399
414
  }
@@ -129,6 +129,37 @@ void ThreadAPI::init()
129
129
  }
130
130
  }
131
131
 
132
+ bool ThreadAPI::isTDFork(const CallICFGNode *inst) const
133
+ {
134
+ return getType(inst->getCalledFunction()) == TD_FORK;
135
+ }
136
+
137
+ bool ThreadAPI::isTDJoin(const CallICFGNode *inst) const
138
+ {
139
+ return getType(inst->getCalledFunction()) == TD_JOIN;
140
+ }
141
+
142
+ bool ThreadAPI::isTDExit(const CallICFGNode *inst) const
143
+ {
144
+ return getType(inst->getCalledFunction()) == TD_EXIT;
145
+ }
146
+
147
+ bool ThreadAPI::isTDAcquire(const CallICFGNode* inst) const
148
+ {
149
+ return getType(inst->getCalledFunction()) == TD_ACQUIRE;
150
+ }
151
+
152
+ bool ThreadAPI::isTDRelease(const CallICFGNode *inst) const
153
+ {
154
+ return getType(inst->getCalledFunction()) == TD_RELEASE;
155
+ }
156
+
157
+ bool ThreadAPI::isTDBarWait(const CallICFGNode *inst) const
158
+ {
159
+ return getType(inst->getCalledFunction()) == TD_BAR_WAIT;
160
+ }
161
+
162
+
132
163
  const SVFValue* ThreadAPI::getForkedThread(const CallICFGNode *inst) const
133
164
  {
134
165
  assert(isTDFork(inst) && "not a thread fork function!");
@@ -155,17 +186,6 @@ const SVFValue* ThreadAPI::getRetParmAtJoinedSite(const CallICFGNode *inst) cons
155
186
  return inst->getArgument(1);
156
187
  }
157
188
 
158
- /*!
159
- *
160
- */
161
- const SVFFunction* ThreadAPI::getCallee(const ICFGNode *inst) const
162
- {
163
- if(const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst))
164
- return SVFUtil::getCallee(call->getCallSite());
165
- else
166
- return nullptr;
167
- }
168
-
169
189
  const SVFValue* ThreadAPI::getLockVal(const ICFGNode *cs) const
170
190
  {
171
191
  const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(cs);
@@ -251,7 +271,7 @@ void ThreadAPI::performAPIStat(SVFModule* module)
251
271
  if (!SVFUtil::isCallSite(svfInst))
252
272
  continue;
253
273
 
254
- const SVFFunction* fun = SVFUtil::getCallee(svfInst);
274
+ const SVFFunction* fun = SVFUtil::cast<CallICFGNode>(svfInst)->getCalledFunction();
255
275
  TD_TYPE type = getType(fun);
256
276
  switch (type)
257
277
  {
@@ -679,7 +679,7 @@ bool Andersen::updateCallGraph(const CallSiteToFunPtrMap& callsites)
679
679
 
680
680
  void Andersen::heapAllocatorViaIndCall(const CallICFGNode* cs, NodePairSet &cpySrcNodes)
681
681
  {
682
- assert(SVFUtil::getCallee(cs) == nullptr && "not an indirect callsite?");
682
+ assert(cs->getCalledFunction() == nullptr && "not an indirect callsite?");
683
683
  const RetICFGNode* retBlockNode = cs->getRetICFGNode();
684
684
  const PAGNode* cs_return = pag->getCallSiteRet(retBlockNode);
685
685
  NodeID srcret;
@@ -157,7 +157,7 @@ bool Steensgaard::updateCallGraph(const CallSiteToFunPtrMap& callsites)
157
157
 
158
158
  void Steensgaard::heapAllocatorViaIndCall(const CallICFGNode* cs, NodePairSet& cpySrcNodes)
159
159
  {
160
- assert(SVFUtil::getCallee(cs) == nullptr && "not an indirect callsite?");
160
+ assert(cs->getCalledFunction() == nullptr && "not an indirect callsite?");
161
161
  const RetICFGNode* retBlockNode = cs->getRetICFGNode();
162
162
  const PAGNode* cs_return = pag->getCallSiteRet(retBlockNode);
163
163
  NodeID srcret;
@@ -233,7 +233,7 @@ InterICFGNode* ICFGBuilder::addInterBlockICFGNode(const SVFInstruction* inst)
233
233
  assert(SVFUtil::isNonInstricCallSite(inst) && "associating an intrinsic debug instruction with an ICFGNode!");
234
234
  CallICFGNode* callICFGNode = icfg->addCallICFGNode(inst);
235
235
  (void) icfg->addRetICFGNode(inst);
236
- addICFGInterEdges(inst, getCallee(inst)); //creating interprocedural edges
236
+ addICFGInterEdges(inst, callICFGNode->getCalledFunction()); //creating interprocedural edges
237
237
  return callICFGNode;
238
238
  }
239
239
 
@@ -608,7 +608,7 @@ const Type* SymbolTableBuilder::inferTypeOfHeapObjOrStaticObj(const Instruction
608
608
  else if(SVFUtil::isHeapAllocExtCallViaArg(svfinst))
609
609
  {
610
610
  const CallBase* cs = LLVMUtil::getLLVMCallSite(inst);
611
- int arg_pos = SVFUtil::getHeapAllocHoldingArgPosition(getCallee(svfinst));
611
+ u32_t arg_pos = SVFUtil::getHeapAllocHoldingArgPosition(SVFUtil::cast<SVFCallInst>(svfinst)->getCalledFunction());
612
612
  const Value* arg = cs->getArgOperand(arg_pos);
613
613
  originalPType = SVFUtil::dyn_cast<PointerType>(arg->getType());
614
614
  inferedType = inferObjType(startValue = arg);