Static Value-Flow Analysis
Loading...
Searching...
No Matches
LeakChecker.h
Go to the documentation of this file.
1//===- LeakChecker.h -- Detecting memory leaks--------------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22
23/*
24 * LeakChecker.h
25 *
26 * Created on: Apr 1, 2014
27 * Author: rockysui
28 */
29
30#ifndef LEAKCHECKER_H_
31#define LEAKCHECKER_H_
32
33#include "SABER/SrcSnkDDA.h"
35
36namespace SVF
37{
38
42class LeakChecker : public SrcSnkDDA
43{
44
45public:
57
60 {
61 }
63 virtual ~LeakChecker()
64 {
65 }
66
68 virtual bool runOnModule(SVFIR* pag)
69 {
71 analyze(pag->getModule());
72 return false;
73 }
74
76
77
78 virtual void initSrcs() override;
79 virtual void initSnks() override;
81 virtual inline bool isSourceLikeFun(const SVFFunction* fun) override
82 {
84 }
86 virtual inline bool isSinkLikeFun(const SVFFunction* fun) override
87 {
89 }
91
92protected:
94
95 virtual void reportBug(ProgSlice* slice) override;
97
99 void testsValidation(const ProgSlice* slice);
100 void validateSuccessTests(const SVFGNode* source, const SVFFunction* fun);
102
104
105 inline void addSrcToCSID(const SVFGNode* src, const CallICFGNode* cs)
106 {
107 srcToCSIDMap[src] = cs;
108 }
109 inline const CallICFGNode* getSrcCSID(const SVFGNode* src)
110 {
111 SVFGNodeToCSIDMap::iterator it =srcToCSIDMap.find(src);
112 assert(it!=srcToCSIDMap.end() && "source node not at a callsite??");
113 return it->second;
114 }
116private:
118};
119
120} // End namespace SVF
121
122#endif /* LEAKCHECKER_H_ */
void validateSuccessTests(const SVFGNode *source, const SVFFunction *fun)
void addSrcToCSID(const SVFGNode *src, const CallICFGNode *cs)
Record a source to its callsite.
virtual bool runOnModule(SVFIR *pag)
We start from here.
Definition LeakChecker.h:68
virtual ~LeakChecker()
Destructor.
Definition LeakChecker.h:63
virtual void initSrcs() override
Initialize sources and sinks.
virtual void initSnks() override
SVFGNodeToCSIDMap srcToCSIDMap
Map< const SVFGNode *, const CallICFGNode * > SVFGNodeToCSIDMap
Definition LeakChecker.h:46
FIFOWorkList< const CallICFGNode * > CSWorkList
Definition LeakChecker.h:47
virtual bool isSinkLikeFun(const SVFFunction *fun) override
Whether the function is a heap deallocator (free/release memory)
Definition LeakChecker.h:86
virtual void reportBug(ProgSlice *slice) override
Report leaks.
void testsValidation(const ProgSlice *slice)
Validate test cases for regression test purpose.
const CallICFGNode * getSrcCSID(const SVFGNode *src)
void validateExpectedFailureTests(const SVFGNode *source, const SVFFunction *fun)
LeakChecker()
Constructor.
Definition LeakChecker.h:59
ProgSlice::VFWorkList WorkList
Definition LeakChecker.h:48
virtual bool isSourceLikeFun(const SVFFunction *fun) override
Whether the function is a heap allocator/reallocator (allocate memory)
Definition LeakChecker.h:81
FIFOWorkList< const SVFGNode * > VFWorkList
worklist for value-flow guard computation
Definition ProgSlice.h:58
SVFModule * getModule()
Definition SVFIR.h:162
bool isMemAlloc(const SVFFunction *fun) const
Return true if this call is a memory allocation.
bool isMemDealloc(const SVFFunction *fun) const
Return true if this call is a memory deallocation.
static SaberCheckerAPI * getCheckerAPI()
Return a static reference.
virtual void analyze(SVFModule *module)
Start analysis here.
Definition SrcSnkDDA.cpp:61
for isBitcode
Definition BasicTypes.h:68
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74