Static Value-Flow Analysis
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
SVF::LeakChecker Class Reference

#include <LeakChecker.h>

Inheritance diagram for SVF::LeakChecker:
SVF::SrcSnkDDA SVF::GraphReachSolver< GraphType, DPIm > SVF::DoubleFreeChecker SVF::FileChecker

Public Types

enum  LEAK_TYPE { NEVER_FREE_LEAK , CONTEXT_LEAK , PATH_LEAK , GLOBAL_LEAK }
 
typedef Map< const SVFGNode *, const CallICFGNode * > SVFGNodeToCSIDMap
 
typedef FIFOWorkList< const CallICFGNode * > CSWorkList
 
typedef ProgSlice::VFWorkList WorkList
 
typedef NodeBS SVFGNodeBS
 
- Public Types inherited from SVF::SrcSnkDDA
typedef ProgSlice::SVFGNodeSet SVFGNodeSet
 
typedef Map< const SVFGNode *, ProgSlice * > SVFGNodeToSliceMap
 
typedef SVFGNodeSet::const_iterator SVFGNodeSetIter
 
typedef CxtDPItem DPIm
 
typedef Set< DPImDPImSet
 dpitem set More...
 
typedef Map< const SVFGNode *, DPImSetSVFGNodeToDPItemsMap
 map a SVFGNode to its visited dpitems More...
 
typedef Set< const CallICFGNode * > CallSiteSet
 
typedef NodeBS SVFGNodeBS
 
typedef ProgSlice::VFWorkList WorkList
 
- Public Types inherited from SVF::GraphReachSolver< GraphType, DPIm >
typedef SVF::GenericGraphTraits< GraphType > GTraits
 Define the GTraits and node iterator. More...
 
typedef GTraits::NodeType GNODE
 
typedef GTraits::EdgeType GEDGE
 
typedef GTraits::nodes_iterator node_iterator
 
typedef GTraits::ChildIteratorType child_iterator
 
typedef SVF::GenericGraphTraits< SVF::Inverse< GNODE * > > InvGTraits
 Define inverse GTraits and note iterator. More...
 
typedef InvGTraits::ChildIteratorType inv_child_iterator
 
typedef FIFOWorkList< DPIm > WorkList
 Define worklist. More...
 

Public Member Functions

 LeakChecker ()
 Constructor. More...
 
virtual ~LeakChecker ()
 Destructor. More...
 
virtual bool runOnModule (SVFIR *pag)
 We start from here. More...
 
virtual void initSrcs () override
 Initialize sources and sinks. More...
 
virtual void initSnks () override
 
virtual bool isSourceLikeFun (const SVFFunction *fun) override
 Whether the function is a heap allocator/reallocator (allocate memory) More...
 
virtual bool isSinkLikeFun (const SVFFunction *fun) override
 Whether the function is a heap deallocator (free/release memory) More...
 
- Public Member Functions inherited from SVF::SrcSnkDDA
 SrcSnkDDA ()
 Bug Reporter. More...
 
 ~SrcSnkDDA () override
 Destructor. More...
 
virtual void analyze (SVFModule *module)
 Start analysis here. More...
 
virtual void initialize (SVFModule *module)
 Initialize analysis. More...
 
virtual void finalize ()
 Finalize analysis. More...
 
SVFIRgetPAG () const
 Get SVFIR. More...
 
const SVFGgetSVFG () const
 Get SVFG. More...
 
PTACallGraphgetCallgraph () const
 Get Callgraph. More...
 
bool isGlobalSVFGNode (const SVFGNode *node) const
 Whether this svfg node may access global variable. More...
 
virtual void setCurSlice (const SVFGNode *src)
 Slice operations. More...
 
ProgSlicegetCurSlice () const
 
void addSinkToCurSlice (const SVFGNode *node)
 
bool isInCurForwardSlice (const SVFGNode *node)
 
bool isInCurBackwardSlice (const SVFGNode *node)
 
void addToCurForwardSlice (const SVFGNode *node)
 
void addToCurBackwardSlice (const SVFGNode *node)
 
bool isInAWrapper (const SVFGNode *src, CallSiteSet &csIdSet)
 Identify allocation wrappers. More...
 
const SVFGNodeSetgetSources () const
 Get sources/sinks. More...
 
SVFGNodeSetIter sourcesBegin () const
 
SVFGNodeSetIter sourcesEnd () const
 
void addToSources (const SVFGNode *node)
 
const SVFGNodeSetgetSinks () const
 
SVFGNodeSetIter sinksBegin () const
 
SVFGNodeSetIter sinksEnd () const
 
void addToSinks (const SVFGNode *node)
 
SaberCondAllocatorgetSaberCondAllocator () const
 Get saber condition allocator. More...
 
const SVFBugReportgetBugReport () const
 
bool isSource (const SVFGNode *node) const
 
bool isSink (const SVFGNode *node) const
 

Protected Member Functions

virtual void reportBug (ProgSlice *slice) override
 Report leaks. More...
 
void testsValidation (const ProgSlice *slice)
 Validate test cases for regression test purpose. More...
 
void validateSuccessTests (const SVFGNode *source, const SVFFunction *fun)
 
void validateExpectedFailureTests (const SVFGNode *source, const SVFFunction *fun)
 
void addSrcToCSID (const SVFGNode *src, const CallICFGNode *cs)
 Record a source to its callsite. More...
 
const CallICFGNodegetSrcCSID (const SVFGNode *src)
 
- Protected Member Functions inherited from SVF::SrcSnkDDA
void FWProcessCurNode (const DPIm &item) override
 Forward traverse. More...
 
void BWProcessCurNode (const DPIm &item) override
 Backward traverse. More...
 
void FWProcessOutgoingEdge (const DPIm &item, SVFGEdge *edge) override
 Propagate information forward by matching context. More...
 
void BWProcessIncomingEdge (const DPIm &item, SVFGEdge *edge) override
 Propagate information backward without matching context, as forward analysis already did it. More...
 
bool forwardVisited (const SVFGNode *node, const DPIm &item)
 Whether has been visited or not, in order to avoid recursion on SVFG. More...
 
void addForwardVisited (const SVFGNode *node, const DPIm &item)
 
bool backwardVisited (const SVFGNode *node)
 
void addBackwardVisited (const SVFGNode *node)
 
void clearVisitedMap ()
 
virtual bool isAllPathReachable ()
 Whether it is all path reachable from a source. More...
 
virtual bool isSomePathReachable ()
 Whether it is some path reachable from a source. More...
 
void dumpSlices ()
 Dump SVFG with annotated slice information. More...
 
void annotateSlice (ProgSlice *slice)
 
void printZ3Stat ()
 
- Protected Member Functions inherited from SVF::GraphReachSolver< GraphType, DPIm >
 GraphReachSolver ()
 Constructor. More...
 
virtual ~GraphReachSolver ()
 Destructor. More...
 
const GraphType graph () const
 Get/Set graph methods. More...
 
void setGraph (GraphType g)
 
GNODEgetNode (NodeID id) const
 
virtual NodeID getNodeIDFromItem (const DPIm &item) const
 
virtual void forwardTraverse (DPIm &it)
 CFL forward traverse solve. More...
 
virtual void backwardTraverse (DPIm &it)
 CFL forward traverse solve. More...
 
virtual void FWProcessCurNode (const DPIm &)
 Process the DP item. More...
 
virtual void BWProcessCurNode (const DPIm &)
 
virtual void FWProcessOutgoingEdge (const DPIm &item, GEDGE *edge)
 Propagation for the solving, to be implemented in the child class. More...
 
virtual void BWProcessIncomingEdge (const DPIm &item, GEDGE *edge)
 
DPIm popFromWorklist ()
 Worklist operations. More...
 
bool pushIntoWorklist (DPIm &item)
 
bool isWorklistEmpty ()
 
bool isInWorklist (DPIm &item)
 

Private Attributes

SVFGNodeToCSIDMap srcToCSIDMap
 

Additional Inherited Members

- Protected Attributes inherited from SVF::SrcSnkDDA
SaberSVFGBuilder memSSA
 
SVFGsvfg
 
PTACallGraphcallgraph
 
SVFBugReport report
 

Detailed Description

Static Memory Leak Detector

Definition at line 42 of file LeakChecker.h.

Member Typedef Documentation

◆ CSWorkList

Definition at line 47 of file LeakChecker.h.

◆ SVFGNodeBS

Definition at line 49 of file LeakChecker.h.

◆ SVFGNodeToCSIDMap

Definition at line 46 of file LeakChecker.h.

◆ WorkList

Definition at line 48 of file LeakChecker.h.

Member Enumeration Documentation

◆ LEAK_TYPE

Enumerator
NEVER_FREE_LEAK 
CONTEXT_LEAK 
PATH_LEAK 
GLOBAL_LEAK 

Definition at line 50 of file LeakChecker.h.

Constructor & Destructor Documentation

◆ LeakChecker()

SVF::LeakChecker::LeakChecker ( )
inline

Constructor.

Definition at line 59 of file LeakChecker.h.

60  {
61  }

◆ ~LeakChecker()

virtual SVF::LeakChecker::~LeakChecker ( )
inlinevirtual

Destructor.

Definition at line 63 of file LeakChecker.h.

64  {
65  }

Member Function Documentation

◆ addSrcToCSID()

void SVF::LeakChecker::addSrcToCSID ( const SVFGNode src,
const CallICFGNode cs 
)
inlineprotected

Record a source to its callsite.

Definition at line 105 of file LeakChecker.h.

106  {
107  srcToCSIDMap[src] = cs;
108  }
SVFGNodeToCSIDMap srcToCSIDMap
Definition: LeakChecker.h:117

◆ getSrcCSID()

const CallICFGNode* SVF::LeakChecker::getSrcCSID ( const SVFGNode src)
inlineprotected

Definition at line 109 of file LeakChecker.h.

110  {
111  SVFGNodeToCSIDMap::iterator it =srcToCSIDMap.find(src);
112  assert(it!=srcToCSIDMap.end() && "source node not at a callsite??");
113  return it->second;
114  }

◆ initSnks()

void LeakChecker::initSnks ( )
overridevirtual

Initialize sinks

we only choose pointer parameters among all the actual parameters

Implements SVF::SrcSnkDDA.

Definition at line 105 of file LeakChecker.cpp.

106 {
107 
108  SVFIR* pag = getPAG();
109 
110  for(SVFIR::CSToArgsListMap::iterator it = pag->getCallSiteArgsMap().begin(),
111  eit = pag->getCallSiteArgsMap().end(); it!=eit; ++it)
112  {
113 
115  getCallgraph()->getCallees(it->first,callees);
116  for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++)
117  {
118  const SVFFunction* fun = *cit;
119  if (isSinkLikeFun(fun))
120  {
121  SVFIR::SVFVarList &arglist = it->second;
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)
126  {
127  const PAGNode *pagNode = *ait;
128  if (pagNode->isPointer())
129  {
130  const SVFGNode *snk = getSVFG()->getActualParmVFGNode(pagNode, it->first);
131  addToSinks(snk);
132 
133  // For any multi-level pointer e.g., XFree(void** pagNode) that passed into a ExtAPI::EFT_FREE_MULTILEVEL function (e.g., XFree),
134  // we will add the DstNode of a load edge, i.e., dummy = *pagNode
135  SVFStmt::SVFStmtSetTy& loads = const_cast<PAGNode*>(pagNode)->getOutgoingEdges(SVFStmt::Load);
136  for(const SVFStmt* ld : loads)
137  {
138  if(SVFUtil::isa<DummyValVar>(ld->getDstNode()))
140  }
141  }
142  }
143  }
144  }
145  }
146 }
virtual bool isSinkLikeFun(const SVFFunction *fun) override
Whether the function is a heap deallocator (free/release memory)
Definition: LeakChecker.h:86
void getCallees(const CallICFGNode *cs, FunctionSet &callees)
Get all callees for a callsite.
Definition: PTACallGraph.h:408
Set< const SVFFunction * > FunctionSet
Definition: PTACallGraph.h:251
CSToArgsListMap & getCallSiteArgsMap()
Get callsite argument list.
Definition: SVFIR.h:287
std::vector< const SVFVar * > SVFVarList
Definition: SVFIR.h:59
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
virtual bool isPointer() const
Whether it is a pointer.
Definition: SVFVariables.h:106
SVFIR * getPAG() const
Get SVFIR.
Definition: SrcSnkDDA.h:120
const SVFG * getSVFG() const
Get SVFG.
Definition: SrcSnkDDA.h:126
void addToSinks(const SVFGNode *node)
Definition: SrcSnkDDA.h:234
PTACallGraph * getCallgraph() const
Get Callgraph.
Definition: SrcSnkDDA.h:132
StmtVFGNode * getStmtVFGNode(const PAGEdge *pagEdge) const
Get an VFGNode.
Definition: VFG.h:199
ActualParmVFGNode * getActualParmVFGNode(const PAGNode *aparm, const CallICFGNode *cs) const
Definition: VFG.h:235

◆ initSrcs()

void LeakChecker::initSrcs ( )
overridevirtual

Initialize sources and sinks.

Initialize sources and sinks

Initialize sources

if this callsite return reside in a dead function then we do not care about its leaks for example instruction int* p = malloc(size) is in a dead function, then program won't allocate this memory for example a customized malloc int p = malloc() returns an integer value, then program treat it as a system malloc

Implements SVF::SrcSnkDDA.

Definition at line 40 of file LeakChecker.cpp.

41 {
42 
43  SVFIR* pag = getPAG();
44  for(SVFIR::CSToRetMap::iterator it = pag->getCallSiteRets().begin(),
45  eit = pag->getCallSiteRets().end(); it!=eit; ++it)
46  {
47  const RetICFGNode* cs = it->first;
51  if(cs->getFun()->isUncalledFunction() || !cs->getType()->isPointerTy())
52  continue;
53 
55  getCallgraph()->getCallees(cs->getCallICFGNode(),callees);
56  for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++)
57  {
58  const SVFFunction* fun = *cit;
59  if (isSourceLikeFun(fun))
60  {
62  SVFGNodeBS visited;
63  worklist.push(it->first->getCallICFGNode());
64  while (!worklist.empty())
65  {
66  const CallICFGNode* cs = worklist.pop();
67  const RetICFGNode* retBlockNode = cs->getRetICFGNode();
68  const PAGNode* pagNode = pag->getCallSiteRet(retBlockNode);
69  const SVFGNode* node = getSVFG()->getDefSVFGNode(pagNode);
70  if (visited.test(node->getId()) == 0)
71  visited.set(node->getId());
72  else
73  continue;
74 
75  CallSiteSet csSet;
76  // if this node is in an allocation wrapper, find all its call nodes
77  if (isInAWrapper(node, csSet))
78  {
79  for (CallSiteSet::iterator it = csSet.begin(), eit =
80  csSet.end(); it != eit; ++it)
81  {
82  worklist.push(*it);
83  }
84  }
85  // otherwise, this is the source we are interested
86  else
87  {
88  // exclude sources in dead functions or sources in functions that have summary
89  if (!cs->getFun()->isUncalledFunction() && !isExtCall(cs->getBB()->getParent()))
90  {
91  addToSources(node);
92  addSrcToCSID(node, cs);
93  }
94  }
95  }
96  }
97  }
98  }
99 
100 }
const RetICFGNode * getRetICFGNode() const
Return callsite.
Definition: ICFGNode.h:457
bool push(const Data &data)
Definition: WorkList.h:165
bool empty() const
Definition: WorkList.h:146
WorkList worklist
Worklist for resolution.
virtual const SVFFunction * getFun() const
Return the function of this ICFGNode.
Definition: ICFGNode.h:76
virtual const SVFBasicBlock * getBB() const
Return the basic block of this ICFGNode.
Definition: ICFGNode.h:82
void addSrcToCSID(const SVFGNode *src, const CallICFGNode *cs)
Record a source to its callsite.
Definition: LeakChecker.h:105
FIFOWorkList< const CallICFGNode * > CSWorkList
Definition: LeakChecker.h:47
virtual bool isSourceLikeFun(const SVFFunction *fun) override
Whether the function is a heap allocator/reallocator (allocate memory)
Definition: LeakChecker.h:81
const CallICFGNode * getCallICFGNode() const
Definition: ICFGNode.h:622
virtual const SVFType * getType() const
Definition: GenericGraph.h:271
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
const SVFFunction * getParent() const
Definition: SVFValue.h:584
bool isUncalledFunction() const
Definition: SVFValue.h:455
const SVFGNode * getDefSVFGNode(const PAGNode *pagNode) const
Given a pagNode, return its definition site.
Definition: SVFG.h:171
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
Definition: SVFIR.h:304
CSToRetMap & getCallSiteRets()
Get callsite return.
Definition: SVFIR.h:299
bool isPointerTy() const
Definition: SVFType.h:249
Set< const CallICFGNode * > CallSiteSet
Definition: SrcSnkDDA.h:64
void addToSources(const SVFGNode *node)
Definition: SrcSnkDDA.h:218
bool isInAWrapper(const SVFGNode *src, CallSiteSet &csIdSet)
Identify allocation wrappers.
Definition: SrcSnkDDA.cpp:118
bool isExtCall(const SVFFunction *fun)
Definition: SVFUtil.h:278

◆ isSinkLikeFun()

virtual bool SVF::LeakChecker::isSinkLikeFun ( const SVFFunction fun)
inlineoverridevirtual

Whether the function is a heap deallocator (free/release memory)

Reimplemented from SVF::SrcSnkDDA.

Reimplemented in SVF::FileChecker.

Definition at line 86 of file LeakChecker.h.

87  {
89  }
bool isMemDealloc(const SVFFunction *fun) const
Return true if this call is a memory deallocation.
static SaberCheckerAPI * getCheckerAPI()
Return a static reference.

◆ isSourceLikeFun()

virtual bool SVF::LeakChecker::isSourceLikeFun ( const SVFFunction fun)
inlineoverridevirtual

Whether the function is a heap allocator/reallocator (allocate memory)

Reimplemented from SVF::SrcSnkDDA.

Reimplemented in SVF::FileChecker.

Definition at line 81 of file LeakChecker.h.

82  {
84  }
bool isMemAlloc(const SVFFunction *fun) const
Return true if this call is a memory allocation.

◆ reportBug()

void LeakChecker::reportBug ( ProgSlice slice)
overrideprotectedvirtual

Report leaks.

Implements SVF::SrcSnkDDA.

Reimplemented in SVF::DoubleFreeChecker, and SVF::FileChecker.

Definition at line 148 of file LeakChecker.cpp.

149 {
150 
151  if(isAllPathReachable() == false && isSomePathReachable() == false)
152  {
153  // full leakage
154  GenericBug::EventStack eventStack =
155  {
157  };
159  }
160  else if (isAllPathReachable() == false && isSomePathReachable() == true)
161  {
162  // partial leakage
163  GenericBug::EventStack eventStack;
164  slice->evalFinalCond2Event(eventStack);
165  eventStack.push_back(
168  }
169 
171  testsValidation(slice);
172 }
std::vector< SVFBugEvent > EventStack
Definition: SVFBugReport.h:83
const CallICFGNode * getSrcCSID(const SVFGNode *src)
Definition: LeakChecker.h:109
void testsValidation(const ProgSlice *slice)
Validate test cases for regression test purpose.
static const Option< bool > ValidateTests
Definition: Options.h:169
void evalFinalCond2Event(GenericBug::EventStack &eventStack) const
Add final condition to eventStack.
Definition: ProgSlice.cpp:196
const SVFGNode * getSource() const
root and sink operations
Definition: ProgSlice.h:123
void addSaberBug(GenericBug::BugType bugType, const GenericBug::EventStack &eventStack)
Definition: SVFBugReport.h:315
virtual bool isSomePathReachable()
Whether it is some path reachable from a source.
Definition: SrcSnkDDA.h:312
virtual bool isAllPathReachable()
Whether it is all path reachable from a source.
Definition: SrcSnkDDA.h:307
SVFBugReport report
Definition: SrcSnkDDA.h:80

◆ runOnModule()

virtual bool SVF::LeakChecker::runOnModule ( SVFIR pag)
inlinevirtual

We start from here.

start analysis

Reimplemented in SVF::DoubleFreeChecker, and SVF::FileChecker.

Definition at line 68 of file LeakChecker.h.

69  {
71  analyze(pag->getModule());
72  return false;
73  }
virtual void analyze(SVFModule *module)
Start analysis here.
Definition: SrcSnkDDA.cpp:61

◆ testsValidation()

void LeakChecker::testsValidation ( const ProgSlice slice)
protected

Validate test cases for regression test purpose.

Validate test cases for regression test purpose

Definition at line 178 of file LeakChecker.cpp.

179 {
180  const SVFGNode* source = slice->getSource();
181  const CallICFGNode* cs = getSrcCSID(source);
182  const SVFFunction* fun = cs->getCalledFunction();
183  if(fun==nullptr)
184  return;
185 
186  validateSuccessTests(source,fun);
187  validateExpectedFailureTests(source,fun);
188 }
const SVFFunction * getCalledFunction() const
Definition: ICFGNode.h:518
void validateSuccessTests(const SVFGNode *source, const SVFFunction *fun)
void validateExpectedFailureTests(const SVFGNode *source, const SVFFunction *fun)

◆ validateExpectedFailureTests()

void LeakChecker::validateExpectedFailureTests ( const SVFGNode source,
const SVFFunction fun 
)
protected

Definition at line 246 of file LeakChecker.cpp.

247 {
248 
249  const CallICFGNode* cs = getSrcCSID(source);
250 
251  bool expectedFailure = false;
252 
253  if(fun->getName() == "NFRLEAKFP")
254  {
255  if(isAllPathReachable() == false && isSomePathReachable() == false)
256  expectedFailure = true;
257  }
258  else if(fun->getName() == "PLKLEAKFP")
259  {
260  if(isAllPathReachable() == false && isSomePathReachable() == true)
261  expectedFailure = true;
262  }
263  else if(fun->getName() == "LEAKFN")
264  {
265  if(isAllPathReachable() == true && isSomePathReachable() == true)
266  expectedFailure = true;
267  }
268  else if(fun->getName() == "SAFEMALLOC" || fun->getName() == "NFRMALLOC"
269  || fun->getName() == "PLKMALLOC" || fun->getName() == "CLKLEAKFN")
270  {
271  return;
272  }
273  else
274  {
275  writeWrnMsg("\t can not validate, check function not found, please put it at the right place!!");
276  return;
277  }
278 
279  std::string funName = source->getFun()->getName();
280 
281  if (expectedFailure)
282  {
283  outs() << sucMsg("\t EXPECTED-FAILURE :") << funName << " check <src id:" << source->getId()
284  << ", cs id:" << (getSrcCSID(source))->valueOnlyToString() << "> at ("
285  << cs->getSourceLoc() << ")\n";
286  }
287  else
288  {
289  SVFUtil::errs() << errMsg("\t UNEXPECTED FAILURE :") << funName
290  << " check <src id:" << source->getId()
291  << ", cs id:" << (getSrcCSID(source))->valueOnlyToString() << "> at ("
292  << cs->getSourceLoc() << ")\n";
293  assert(false && "test case failed!");
294  }
295 }
const char *const string
Definition: cJSON.h:172
const std::string getSourceLoc() const override
Definition: ICFGNode.h:588
const std::string & getName() const
Definition: SVFValue.h:243
virtual const SVFFunction * getFun() const
Get the function of this SVFGNode.
Definition: VFGNode.h:79
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
Definition: SVFUtil.cpp:53
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
Definition: SVFUtil.cpp:76
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition: SVFUtil.cpp:66
std::ostream & errs()
Overwrite llvm::errs()
Definition: SVFUtil.h:56
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ validateSuccessTests()

void LeakChecker::validateSuccessTests ( const SVFGNode source,
const SVFFunction fun 
)
protected

Definition at line 191 of file LeakChecker.cpp.

192 {
193 
194  const CallICFGNode* cs = getSrcCSID(source);
195 
196  bool success = false;
197 
198  if(fun->getName() == "SAFEMALLOC")
199  {
200  if(isAllPathReachable() == true && isSomePathReachable() == true)
201  success = true;
202  }
203  else if(fun->getName() == "NFRMALLOC")
204  {
205  if(isAllPathReachable() == false && isSomePathReachable() == false)
206  success = true;
207  }
208  else if(fun->getName() == "PLKMALLOC")
209  {
210  if(isAllPathReachable() == false && isSomePathReachable() == true)
211  success = true;
212  }
213  else if(fun->getName() == "CLKMALLOC")
214  {
215  if(isAllPathReachable() == false && isSomePathReachable() == false)
216  success = true;
217  }
218  else if(fun->getName() == "NFRLEAKFP" || fun->getName() == "PLKLEAKFP"
219  || fun->getName() == "LEAKFN")
220  {
221  return;
222  }
223  else
224  {
225  writeWrnMsg("\t can not validate, check function not found, please put it at the right place!!");
226  return;
227  }
228 
229  std::string funName = source->getFun()->getName();
230 
231  if (success)
232  {
233  outs() << sucMsg("\t SUCCESS :") << funName << " check <src id:" << source->getId()
234  << ", cs id:" << (getSrcCSID(source))->valueOnlyToString() << "> at ("
235  << cs->getSourceLoc() << ")\n";
236  }
237  else
238  {
239  SVFUtil::errs() << errMsg("\t FAILURE :") << funName << " check <src id:" << source->getId()
240  << ", cs id:" << (getSrcCSID(source))->valueOnlyToString() << "> at ("
241  << cs->getSourceLoc() << ")\n";
242  assert(false && "test case failed!");
243  }
244 }

Member Data Documentation

◆ srcToCSIDMap

SVFGNodeToCSIDMap SVF::LeakChecker::srcToCSIDMap
private

Definition at line 117 of file LeakChecker.h.


The documentation for this class was generated from the following files: