Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SVF::FileChecker Class Reference

#include <FileChecker.h>

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

Public Member Functions

 FileChecker ()
 Constructor.
 
virtual ~FileChecker ()
 Destructor.
 
virtual bool runOnModule (SVFIR *pag)
 We start from here.
 
bool isSourceLikeFun (const SVFFunction *fun)
 Whether the function is a heap allocator/reallocator (allocate memory)
 
bool isSinkLikeFun (const SVFFunction *fun)
 Whether the function is a heap deallocator (free/release memory)
 
void reportBug (ProgSlice *slice)
 Report file/close bugs.
 
- Public Member Functions inherited from SVF::LeakChecker
 LeakChecker ()
 Constructor.
 
virtual ~LeakChecker ()
 Destructor.
 
virtual void initSrcs () override
 Initialize sources and sinks.
 
virtual void initSnks () override
 
- Public Member Functions inherited from SVF::SrcSnkDDA
 SrcSnkDDA ()
 Bug Reporter.
 
 ~SrcSnkDDA () override
 Destructor.
 
virtual void analyze (SVFModule *module)
 Start analysis here.
 
virtual void initialize (SVFModule *module)
 Initialize analysis.
 
virtual void finalize ()
 Finalize analysis.
 
SVFIRgetPAG () const
 Get SVFIR.
 
const SVFGgetSVFG () const
 Get SVFG.
 
PTACallGraphgetCallgraph () const
 Get Callgraph.
 
bool isGlobalSVFGNode (const SVFGNode *node) const
 Whether this svfg node may access global variable.
 
virtual void setCurSlice (const SVFGNode *src)
 Slice operations.
 
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.
 
const SVFGNodeSetgetSources () const
 Get sources/sinks.
 
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.
 
const SVFBugReportgetBugReport () const
 
bool isSource (const SVFGNode *node) const
 
bool isSink (const SVFGNode *node) const
 

Additional Inherited Members

- Public Types inherited from SVF::LeakChecker
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
 
typedef Map< const SVFGNode *, DPImSetSVFGNodeToDPItemsMap
 map a SVFGNode to its visited dpitems
 
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.
 
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.
 
typedef InvGTraits::ChildIteratorType inv_child_iterator
 
typedef FIFOWorkList< DPIm > WorkList
 Define worklist.
 
- Protected Member Functions inherited from SVF::LeakChecker
void testsValidation (const ProgSlice *slice)
 Validate test cases for regression test purpose.
 
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.
 
const CallICFGNodegetSrcCSID (const SVFGNode *src)
 
- Protected Member Functions inherited from SVF::SrcSnkDDA
void FWProcessCurNode (const DPIm &item) override
 Forward traverse.
 
void BWProcessCurNode (const DPIm &item) override
 Backward traverse.
 
void FWProcessOutgoingEdge (const DPIm &item, SVFGEdge *edge) override
 Propagate information forward by matching context.
 
void BWProcessIncomingEdge (const DPIm &item, SVFGEdge *edge) override
 Propagate information backward without matching context, as forward analysis already did it.
 
bool forwardVisited (const SVFGNode *node, const DPIm &item)
 Whether has been visited or not, in order to avoid recursion on SVFG.
 
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.
 
virtual bool isSomePathReachable ()
 Whether it is some path reachable from a source.
 
void dumpSlices ()
 Dump SVFG with annotated slice information.
 
void annotateSlice (ProgSlice *slice)
 
void printZ3Stat ()
 
- Protected Member Functions inherited from SVF::GraphReachSolver< GraphType, DPIm >
 GraphReachSolver ()
 Constructor.
 
virtual ~GraphReachSolver ()
 Destructor.
 
const GraphType graph () const
 Get/Set graph methods.
 
void setGraph (GraphType g)
 
GNODEgetNode (NodeID id) const
 
virtual NodeID getNodeIDFromItem (const DPIm &item) const
 
virtual void forwardTraverse (DPIm &it)
 CFL forward traverse solve.
 
virtual void backwardTraverse (DPIm &it)
 CFL forward traverse solve.
 
virtual void FWProcessCurNode (const DPIm &)
 Process the DP item.
 
virtual void BWProcessCurNode (const DPIm &)
 
virtual void FWProcessOutgoingEdge (const DPIm &item, GEDGE *edge)
 Propagation for the solving, to be implemented in the child class.
 
virtual void BWProcessIncomingEdge (const DPIm &item, GEDGE *edge)
 
DPIm popFromWorklist ()
 Worklist operations.
 
bool pushIntoWorklist (DPIm &item)
 
bool isWorklistEmpty ()
 
bool isInWorklist (DPIm &item)
 
- Protected Attributes inherited from SVF::SrcSnkDDA
SaberSVFGBuilder memSSA
 
SVFGsvfg
 
PTACallGraphcallgraph
 
SVFBugReport report
 

Detailed Description

File open/close checker to check consistency of file operations

Definition at line 42 of file FileChecker.h.

Constructor & Destructor Documentation

◆ FileChecker()

SVF::FileChecker::FileChecker ( )
inline

Constructor.

Definition at line 48 of file FileChecker.h.

48 : LeakChecker()
49 {
50 }
LeakChecker()
Constructor.
Definition LeakChecker.h:59

◆ ~FileChecker()

virtual SVF::FileChecker::~FileChecker ( )
inlinevirtual

Destructor.

Definition at line 53 of file FileChecker.h.

54 {
55 }

Member Function Documentation

◆ isSinkLikeFun()

bool SVF::FileChecker::isSinkLikeFun ( const SVFFunction fun)
inlinevirtual

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

Reimplemented from SVF::LeakChecker.

Definition at line 70 of file FileChecker.h.

71 {
73 }
bool isFClose(const SVFFunction *fun) const
Return true if this call is a file close.
static SaberCheckerAPI * getCheckerAPI()
Return a static reference.

◆ isSourceLikeFun()

bool SVF::FileChecker::isSourceLikeFun ( const SVFFunction fun)
inlinevirtual

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

Reimplemented from SVF::LeakChecker.

Definition at line 65 of file FileChecker.h.

66 {
68 }
bool isFOpen(const SVFFunction *fun) const
Return true if this call is a file open.

◆ reportBug()

void FileChecker::reportBug ( ProgSlice slice)
virtual

Report file/close bugs.

Reimplemented from SVF::LeakChecker.

Definition at line 36 of file FileChecker.cpp.

37{
38
39 if(isAllPathReachable() == false && isSomePathReachable() == false)
40 {
41 // full leakage
44 }
45 else if (isAllPathReachable() == false && isSomePathReachable() == true)
46 {
48 slice->evalFinalCond2Event(eventStack);
49 eventStack.push_back(
52 }
53}
std::vector< SVFBugEvent > EventStack
const CallICFGNode * getSrcCSID(const SVFGNode *src)
void addSaberBug(GenericBug::BugType bugType, const GenericBug::EventStack &eventStack)
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
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ runOnModule()

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

We start from here.

start analysis

Reimplemented from SVF::LeakChecker.

Definition at line 58 of file FileChecker.h.

59 {
61 analyze(pag->getModule());
62 return false;
63 }
virtual void analyze(SVFModule *module)
Start analysis here.
Definition SrcSnkDDA.cpp:61

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