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

#include <SaberCheckerAPI.h>

Public Types

enum  CHECKER_TYPE {
  CK_DUMMY = 0 , CK_ALLOC , CK_FREE , CK_FOPEN ,
  CK_FCLOSE
}
 
typedef Map< std::string, CHECKER_TYPETDAPIMap
 

Public Member Functions

bool isMemAlloc (const SVFFunction *fun) const
 Return true if this call is a memory allocation.
 
bool isMemAlloc (const CallICFGNode *cs) const
 
bool isMemDealloc (const SVFFunction *fun) const
 Return true if this call is a memory deallocation.
 
bool isMemDealloc (const CallICFGNode *cs) const
 
bool isFOpen (const SVFFunction *fun) const
 Return true if this call is a file open.
 
bool isFOpen (const CallICFGNode *cs) const
 
bool isFClose (const SVFFunction *fun) const
 Return true if this call is a file close.
 
bool isFClose (const CallICFGNode *cs) const
 

Static Public Member Functions

static SaberCheckerAPIgetCheckerAPI ()
 Return a static reference.
 

Private Member Functions

 SaberCheckerAPI ()
 Constructor.
 
void init ()
 Initialize the map.
 
CHECKER_TYPE getType (const SVFFunction *F) const
 Get the function type of a function.
 

Private Attributes

TDAPIMap tdAPIMap
 API map, from a string to threadAPI type.
 

Static Private Attributes

static SaberCheckerAPIckAPI = nullptr
 Static reference.
 

Detailed Description

Definition at line 44 of file SaberCheckerAPI.h.

Member Typedef Documentation

◆ TDAPIMap

Definition at line 57 of file SaberCheckerAPI.h.

Member Enumeration Documentation

◆ CHECKER_TYPE

Enumerator
CK_DUMMY 
CK_ALLOC 

dummy type

CK_FREE 

memory allocation

CK_FOPEN 

memory deallocation

CK_FCLOSE 

File open.

File close

Definition at line 48 of file SaberCheckerAPI.h.

49 {
50 CK_DUMMY = 0,
51 CK_ALLOC,
52 CK_FREE,
53 CK_FOPEN,
55 };
@ CK_FREE
memory allocation
@ CK_FOPEN
memory deallocation

Constructor & Destructor Documentation

◆ SaberCheckerAPI()

SVF::SaberCheckerAPI::SaberCheckerAPI ( )
inlineprivate

Constructor.

Definition at line 64 of file SaberCheckerAPI.h.

65 {
66 init();
67 }
void init()
Initialize the map.

Member Function Documentation

◆ getCheckerAPI()

static SaberCheckerAPI * SVF::SaberCheckerAPI::getCheckerAPI ( )
inlinestatic

Return a static reference.

Definition at line 89 of file SaberCheckerAPI.h.

90 {
91 if(ckAPI == nullptr)
92 {
93 ckAPI = new SaberCheckerAPI();
94 }
95 return ckAPI;
96 }
static SaberCheckerAPI * ckAPI
Static reference.
SaberCheckerAPI()
Constructor.

◆ getType()

CHECKER_TYPE SVF::SaberCheckerAPI::getType ( const SVFFunction F) const
inlineprivate

Get the function type of a function.

Definition at line 76 of file SaberCheckerAPI.h.

77 {
78 if(F)
79 {
80 TDAPIMap::const_iterator it= tdAPIMap.find(F->getName());
81 if(it != tdAPIMap.end())
82 return it->second;
83 }
84 return CK_DUMMY;
85 }
#define F(f)
TDAPIMap tdAPIMap
API map, from a string to threadAPI type.
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ init()

void SaberCheckerAPI::init ( )
private

Initialize the map.

initialize the map

Definition at line 144 of file SaberCheckerAPI.cpp.

145{
148 t_seen.insert(CK_DUMMY);
149 for(const ei_pair *p= ei_pairs; p->n; ++p)
150 {
151 if(p->t != prev_t)
152 {
153 //This will detect if you move an entry to another block
154 // but forget to change the type.
155 if(t_seen.count(p->t))
156 {
157 fputs(p->n, stderr);
158 putc('\n', stderr);
159 assert(!"ei_pairs not grouped by type");
160 }
161 t_seen.insert(p->t);
162 prev_t= p->t;
163 }
164 if(tdAPIMap.count(p->n))
165 {
166 fputs(p->n, stderr);
167 putc('\n', stderr);
168 assert(!"duplicate name in ei_pairs");
169 }
170 tdAPIMap[p->n]= p->t;
171 }
172}
static const ei_pair ei_pairs[]
cJSON * p
Definition cJSON.cpp:2559

◆ isFClose() [1/2]

bool SVF::SaberCheckerAPI::isFClose ( const CallICFGNode cs) const
inline

Definition at line 140 of file SaberCheckerAPI.h.

141 {
142 return isFClose(cs->getCalledFunction());
143 }
bool isFClose(const SVFFunction *fun) const
Return true if this call is a file close.

◆ isFClose() [2/2]

bool SVF::SaberCheckerAPI::isFClose ( const SVFFunction fun) const
inline

Return true if this call is a file close.

Definition at line 136 of file SaberCheckerAPI.h.

137 {
138 return getType(fun) == CK_FCLOSE;
139 }
CHECKER_TYPE getType(const SVFFunction *F) const
Get the function type of a function.

◆ isFOpen() [1/2]

bool SVF::SaberCheckerAPI::isFOpen ( const CallICFGNode cs) const
inline

Definition at line 128 of file SaberCheckerAPI.h.

129 {
130 return isFOpen(cs->getCalledFunction());
131 }
bool isFOpen(const SVFFunction *fun) const
Return true if this call is a file open.

◆ isFOpen() [2/2]

bool SVF::SaberCheckerAPI::isFOpen ( const SVFFunction fun) const
inline

Return true if this call is a file open.

Definition at line 124 of file SaberCheckerAPI.h.

125 {
126 return getType(fun) == CK_FOPEN;
127 }

◆ isMemAlloc() [1/2]

bool SVF::SaberCheckerAPI::isMemAlloc ( const CallICFGNode cs) const
inline

Definition at line 104 of file SaberCheckerAPI.h.

105 {
106 return isMemAlloc(cs->getCalledFunction());
107 }
bool isMemAlloc(const SVFFunction *fun) const
Return true if this call is a memory allocation.

◆ isMemAlloc() [2/2]

bool SVF::SaberCheckerAPI::isMemAlloc ( const SVFFunction fun) const
inline

Return true if this call is a memory allocation.

Definition at line 100 of file SaberCheckerAPI.h.

101 {
102 return getType(fun) == CK_ALLOC;
103 }

◆ isMemDealloc() [1/2]

bool SVF::SaberCheckerAPI::isMemDealloc ( const CallICFGNode cs) const
inline

Definition at line 116 of file SaberCheckerAPI.h.

117 {
118 return isMemDealloc(cs->getCalledFunction());
119 }
bool isMemDealloc(const SVFFunction *fun) const
Return true if this call is a memory deallocation.

◆ isMemDealloc() [2/2]

bool SVF::SaberCheckerAPI::isMemDealloc ( const SVFFunction fun) const
inline

Return true if this call is a memory deallocation.

Definition at line 112 of file SaberCheckerAPI.h.

113 {
114 return getType(fun) == CK_FREE;
115 }

Member Data Documentation

◆ ckAPI

SaberCheckerAPI * SaberCheckerAPI::ckAPI = nullptr
staticprivate

Static reference.

Definition at line 73 of file SaberCheckerAPI.h.

◆ tdAPIMap

TDAPIMap SVF::SaberCheckerAPI::tdAPIMap
private

API map, from a string to threadAPI type.

Definition at line 61 of file SaberCheckerAPI.h.


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