34 using namespace SVFUtil;
43 SVFIR* pag = getPAG();
56 for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++)
59 if (isSourceLikeFun(fun))
63 worklist.
push(it->first->getCallICFGNode());
64 while (!worklist.
empty())
69 const SVFGNode* node = getSVFG()->getDefSVFGNode(pagNode);
77 if (isInAWrapper(node, csSet))
79 for (CallSiteSet::iterator it = csSet.begin(), eit =
80 csSet.end(); it != eit; ++it)
92 addSrcToCSID(node, cs);
108 SVFIR* pag = getPAG();
115 getCallgraph()->getCallees(it->first,callees);
116 for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++)
119 if (isSinkLikeFun(fun))
122 assert(!arglist.empty() &&
"no actual parameter at deallocation site?");
124 for (SVFIR::SVFVarList::const_iterator ait = arglist.begin(),
125 aeit = arglist.end(); ait != aeit; ++ait)
130 const SVFGNode *snk = getSVFG()->getActualParmVFGNode(pagNode, it->first);
138 if(SVFUtil::isa<DummyValVar>(ld->getDstNode()))
139 addToSinks(getSVFG()->getStmtVFGNode(ld));
151 if(isAllPathReachable() ==
false && isSomePathReachable() ==
false)
160 else if (isAllPathReachable() ==
false && isSomePathReachable() ==
true)
165 eventStack.push_back(
171 testsValidation(slice);
186 validateSuccessTests(source,fun);
187 validateExpectedFailureTests(source,fun);
196 bool success =
false;
198 if(fun->
getName() ==
"SAFEMALLOC")
200 if(isAllPathReachable() ==
true && isSomePathReachable() ==
true)
203 else if(fun->
getName() ==
"NFRMALLOC")
205 if(isAllPathReachable() ==
false && isSomePathReachable() ==
false)
208 else if(fun->
getName() ==
"PLKMALLOC")
210 if(isAllPathReachable() ==
false && isSomePathReachable() ==
true)
213 else if(fun->
getName() ==
"CLKMALLOC")
215 if(isAllPathReachable() ==
false && isSomePathReachable() ==
false)
218 else if(fun->
getName() ==
"NFRLEAKFP" || fun->
getName() ==
"PLKLEAKFP"
225 writeWrnMsg(
"\t can not validate, check function not found, please put it at the right place!!");
233 outs() <<
sucMsg(
"\t SUCCESS :") << funName <<
" check <src id:" << source->
getId()
234 <<
", cs id:" << (getSrcCSID(source))->valueOnlyToString() <<
"> at ("
240 <<
", cs id:" << (getSrcCSID(source))->valueOnlyToString() <<
"> at ("
242 assert(
false &&
"test case failed!");
251 bool expectedFailure =
false;
253 if(fun->
getName() ==
"NFRLEAKFP")
255 if(isAllPathReachable() ==
false && isSomePathReachable() ==
false)
256 expectedFailure =
true;
258 else if(fun->
getName() ==
"PLKLEAKFP")
260 if(isAllPathReachable() ==
false && isSomePathReachable() ==
true)
261 expectedFailure =
true;
263 else if(fun->
getName() ==
"LEAKFN")
265 if(isAllPathReachable() ==
true && isSomePathReachable() ==
true)
266 expectedFailure =
true;
268 else if(fun->
getName() ==
"SAFEMALLOC" || fun->
getName() ==
"NFRMALLOC"
269 || fun->
getName() ==
"PLKMALLOC" || fun->
getName() ==
"CLKLEAKFN")
275 writeWrnMsg(
"\t can not validate, check function not found, please put it at the right place!!");
283 outs() <<
sucMsg(
"\t EXPECTED-FAILURE :") << funName <<
" check <src id:" << source->
getId()
284 <<
", cs id:" << (getSrcCSID(source))->valueOnlyToString() <<
"> at ("
290 <<
" check <src id:" << source->
getId()
291 <<
", cs id:" << (getSrcCSID(source))->valueOnlyToString() <<
"> at ("
293 assert(
false &&
"test case failed!");
const SVFFunction * getCalledFunction() const
const std::string getSourceLoc() const override
const RetICFGNode * getRetICFGNode() const
Return callsite.
bool push(const Data &data)
std::vector< SVFBugEvent > EventStack
virtual const SVFFunction * getFun() const
Return the function of this ICFGNode.
virtual const SVFBasicBlock * getBB() const
Return the basic block of this ICFGNode.
void validateSuccessTests(const SVFGNode *source, const SVFFunction *fun)
virtual void initSrcs() override
Initialize sources and sinks.
virtual void initSnks() override
virtual void reportBug(ProgSlice *slice) override
Report leaks.
void testsValidation(const ProgSlice *slice)
Validate test cases for regression test purpose.
void validateExpectedFailureTests(const SVFGNode *source, const SVFFunction *fun)
static const Option< bool > ValidateTests
Set< const SVFFunction * > FunctionSet
void evalFinalCond2Event(GenericBug::EventStack &eventStack) const
Add final condition to eventStack.
const SVFGNode * getSource() const
root and sink operations
const CallICFGNode * getCallICFGNode() const
virtual const SVFType * getType() const
NodeID getId() const
Get ID.
const SVFFunction * getParent() const
bool isUncalledFunction() const
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
CSToArgsListMap & getCallSiteArgsMap()
Get callsite argument list.
std::vector< const SVFVar * > SVFVarList
CSToRetMap & getCallSiteRets()
Get callsite return.
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
const std::string & getName() const
virtual bool isPointer() const
Whether it is a pointer.
bool test(unsigned Idx) const
Set< const CallICFGNode * > CallSiteSet
virtual const SVFFunction * getFun() const
Get the function of this SVFGNode.
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
bool isExtCall(const SVFFunction *fun)
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
std::ostream & errs()
Overwrite llvm::errs()
std::ostream & outs()
Overwrite llvm::outs()