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

#include <SymbolTableInfo.h>

Public Types

enum  SYMTYPE {
  NullPtr , BlkPtr , BlackHole , ConstantObj ,
  ValSymbol , ObjSymbol , RetSymbol , VarargSymbol
}
 Symbol types. More...
 
typedef OrderedMap< const SVFValue *, SymIDValueToIDMapTy
 various maps defined
 
typedef OrderedMap< SymID, MemObj * > IDToMemMapTy
 sym id to memory object map
 
typedef OrderedMap< const SVFFunction *, SymIDFunToIDMapTy
 function to sym id map
 
typedef Set< const SVFType * > SVFTypeSet
 struct type to struct info map
 

Public Member Functions

virtual ~SymbolTableInfo ()
 
void setModelConstants (bool _modelConstants)
 Set / Get modelConstants.
 
bool getModelConstants () const
 
SVFModulegetModule ()
 Module.
 
void setModule (SVFModule *m)
 Module.
 
MemObjgetBlkObj () const
 
MemObjgetConstantObj () const
 
SymID blkPtrSymID () const
 
SymID nullPtrSymID () const
 
SymID constantSymID () const
 
SymID blackholeSymID () const
 
const MemObjcreateDummyObj (SymID symId, const SVFType *type)
 Can only be invoked by SVFIR::addDummyNode() when creating SVFIR from file.
 
SymID getValSym (const SVFValue *val)
 Get different kinds of syms.
 
bool hasValSym (const SVFValue *val)
 
SymID getObjSym (const SVFValue *val) const
 
MemObjgetObj (SymID id) const
 
SymID getRetSym (const SVFFunction *val) const
 
SymID getVarargSym (const SVFFunction *val) const
 
u32_t getTotalSymNum () const
 Statistics.
 
u32_t getMaxStructSize () const
 
ValueToIDMapTyvalSyms ()
 Get different kinds of syms maps.
 
ValueToIDMapTyobjSyms ()
 
IDToMemMapTyidToObjMap ()
 
const IDToMemMapTyidToObjMap () const
 
FunToIDMapTyretSyms ()
 
FunToIDMapTyvarargSyms ()
 
const SVFTypeSetgetSVFTypes () const
 Constant reader that won't change the state of the symbol table.
 
const Set< const StInfo * > & getStInfos () const
 
const StInfogetTypeInfo (const SVFType *T) const
 Get struct info.
 
bool hasSVFTypeInfo (const SVFType *T)
 
u32_t getNumOfFlattenElements (const SVFType *T)
 Number of flattened elements of an array or struct.
 
u32_t getFlattenedElemIdx (const SVFType *T, u32_t origId)
 Flattened element idx of an array or struct by considering stride.
 
const SVFTypegetFlatternedElemType (const SVFType *baseType, u32_t flatten_idx)
 Return the type of a flattened element given a flattened index.
 
const SVFTypegetOriginalElemType (const SVFType *baseType, u32_t origId) const
 
void printFlattenFields (const SVFType *type)
 Debug method.
 
virtual void dump ()
 Another debug method.
 
virtual APOffset getModulusOffset (const MemObj *obj, const APOffset &apOffset)
 Given an offset from a Gep Instruction, return it modulus offset by considering memory layout.
 
void addTypeInfo (const SVFType *ty)
 
void addStInfo (StInfo *stInfo)
 

Static Public Member Functions

static SymbolTableInfoSymbolInfo ()
 Singleton design here to make sure we only have one instance during any analysis.
 
static void releaseSymbolInfo ()
 
static bool isBlkPtr (NodeID id)
 special value
 
static bool isNullPtr (NodeID id)
 
static bool isBlkObj (NodeID id)
 
static bool isConstantObj (NodeID id)
 
static bool isBlkObjOrConstantObj (NodeID id)
 
static std::string toString (SYMTYPE symtype)
 

Public Attributes

const SVFTypemaxStruct
 The struct type with the most fields.
 
u32_t maxStSize
 The number of fields in max_struct.
 

Protected Member Functions

 SymbolTableInfo (void)
 Constructor.
 
const std::vector< const SVFType * > & getFlattenFieldTypes (const SVFStructType *T)
 Return the flattened field type for struct type only.
 
ObjTypeInfocreateObjTypeInfo (const SVFType *type)
 Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
 

Protected Attributes

SVFTypeSet svfTypes
 
Set< const StInfo * > stInfos
 (owned) All StInfo
 

Private Member Functions

void destroy ()
 Clean up memory.
 

Private Attributes

ValueToIDMapTy valSymMap
 map a value to its sym id
 
ValueToIDMapTy objSymMap
 map a obj reference to its sym id
 
FunToIDMapTy returnSymMap
 return map
 
FunToIDMapTy varargSymMap
 vararg map
 
IDToMemMapTy objMap
 map a memory sym id to its obj
 
SVFModulemod
 Module.
 
bool modelConstants
 Whether to model constants.
 
SymID totalSymNum
 total number of symbols
 

Static Private Attributes

static SymbolTableInfosymInfo = nullptr
 

Friends

class SymbolTableBuilder
 
class SVFIRWriter
 
class SVFIRReader
 

Detailed Description

Symbol table of the memory model for analysis

Definition at line 47 of file SymbolTableInfo.h.

Member Typedef Documentation

◆ FunToIDMapTy

function to sym id map

Definition at line 76 of file SymbolTableInfo.h.

◆ IDToMemMapTy

sym id to memory object map

Definition at line 74 of file SymbolTableInfo.h.

◆ SVFTypeSet

struct type to struct info map

Definition at line 78 of file SymbolTableInfo.h.

◆ ValueToIDMapTy

various maps defined

llvm value to sym id map local (%) and global (@) identifiers are pointer types which have a value node id.

Definition at line 72 of file SymbolTableInfo.h.

Member Enumeration Documentation

◆ SYMTYPE

Symbol types.

Enumerator
NullPtr 
BlkPtr 
BlackHole 
ConstantObj 
ValSymbol 
ObjSymbol 
RetSymbol 
VarargSymbol 

Definition at line 56 of file SymbolTableInfo.h.

Constructor & Destructor Documentation

◆ SymbolTableInfo()

SVF::SymbolTableInfo::SymbolTableInfo ( void  )
inlineprotected

Constructor.

Definition at line 105 of file SymbolTableInfo.h.

106 : mod(nullptr), modelConstants(false), totalSymNum(0),
107 maxStruct(nullptr), maxStSize(0)
108 {
109 }
const SVFType * maxStruct
The struct type with the most fields.
SymID totalSymNum
total number of symbols
u32_t maxStSize
The number of fields in max_struct.
bool modelConstants
Whether to model constants.
SVFModule * mod
Module.

◆ ~SymbolTableInfo()

virtual SVF::SymbolTableInfo::~SymbolTableInfo ( )
inlinevirtual

Definition at line 122 of file SymbolTableInfo.h.

123 {
124 destroy();
125 }
void destroy()
Clean up memory.

Member Function Documentation

◆ addStInfo()

void SVF::SymbolTableInfo::addStInfo ( StInfo stInfo)
inline

Definition at line 352 of file SymbolTableInfo.h.

353 {
354 stInfos.insert(stInfo);
355 }
Set< const StInfo * > stInfos
(owned) All StInfo
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ addTypeInfo()

void SVF::SymbolTableInfo::addTypeInfo ( const SVFType ty)
inline

Definition at line 345 of file SymbolTableInfo.h.

346 {
347 bool inserted = svfTypes.insert(ty).second;
348 if(!inserted)
349 assert(false && "this type info has been added before");
350 }

◆ blackholeSymID()

SymID SVF::SymbolTableInfo::blackholeSymID ( ) const
inline

Definition at line 198 of file SymbolTableInfo.h.

199 {
200 return BlackHole;
201 }

◆ blkPtrSymID()

SymID SVF::SymbolTableInfo::blkPtrSymID ( ) const
inline

Definition at line 183 of file SymbolTableInfo.h.

184 {
185 return BlkPtr;
186 }

◆ constantSymID()

SymID SVF::SymbolTableInfo::constantSymID ( ) const
inline

Definition at line 193 of file SymbolTableInfo.h.

194 {
195 return ConstantObj;
196 }

◆ createDummyObj()

const MemObj * SymbolTableInfo::createDummyObj ( SymID  symId,
const SVFType type 
)

Can only be invoked by SVFIR::addDummyNode() when creating SVFIR from file.

Definition at line 163 of file SymbolTableInfo.cpp.

164{
165 assert(objMap.find(symId)==objMap.end() && "this dummy obj has been created before");
166 MemObj* memObj = new MemObj(symId, createObjTypeInfo(type));
167 objMap[symId] = memObj;
168 return memObj;
169}
newitem type
Definition cJSON.cpp:2739
ObjTypeInfo * createObjTypeInfo(const SVFType *type)
Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy ...
IDToMemMapTy objMap
map a memory sym id to its obj

◆ createObjTypeInfo()

ObjTypeInfo * SymbolTableInfo::createObjTypeInfo ( const SVFType type)
protected

Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)

Definition at line 68 of file SymbolTableInfo.cpp.

69{
71 if(type && type->isPointerTy())
72 {
74 }
75 return typeInfo;
76}
void setFlag(MEMTYPE mask)
Flag for this object type.
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
Definition Options.h:38

◆ destroy()

void SymbolTableInfo::destroy ( )
private

Clean up memory.

Destroy the memory for this symbol table after use

Definition at line 143 of file SymbolTableInfo.cpp.

144{
145
146 for (auto &pair: objMap)
147 {
148 if (MemObj* memObj = pair.second)
149 delete memObj;
150 }
151
152 for (const SVFType* type : svfTypes)
153 delete type;
154 svfTypes.clear();
155
156 for (const StInfo* st : stInfos)
157 delete st;
158 stInfos.clear();
159
160 mod = nullptr;
161}

◆ dump()

void SymbolTableInfo::dump ( )
virtual

Another debug method.

Definition at line 326 of file SymbolTableInfo.cpp.

327{
329 for (ValueToIDMapTy::iterator iter = valSymMap.begin(); iter != valSymMap.end();
330 ++iter)
331 {
332 const SymID i = iter->second;
333 SVFValue* val = (SVFValue*) iter->first;
334 idmap[i] = val;
335 }
336 for (ValueToIDMapTy::iterator iter = objSymMap.begin(); iter != objSymMap.end();
337 ++iter)
338 {
339 const SymID i = iter->second;
340 SVFValue* val = (SVFValue*) iter->first;
341 idmap[i] = val;
342 }
343 for (FunToIDMapTy::iterator iter = returnSymMap.begin(); iter != returnSymMap.end();
344 ++iter)
345 {
346 const SymID i = iter->second;
347 SVFValue* val = (SVFValue*) iter->first;
348 idmap[i] = val;
349 }
350 for (FunToIDMapTy::iterator iter = varargSymMap.begin(); iter != varargSymMap.end();
351 ++iter)
352 {
353 const SymID i = iter->second;
354 SVFValue* val = (SVFValue*) iter->first;
355 idmap[i] = val;
356 }
357 outs() << "{SymbolTableInfo \n";
358 for (auto iter : idmap)
359 {
360 outs() << iter.first << " " << iter.second->toString() << "\n";
361 }
362 outs() << "}\n";
363}
ValueToIDMapTy valSymMap
map a value to its sym id
ValueToIDMapTy objSymMap
map a obj reference to its sym id
FunToIDMapTy varargSymMap
vararg map
FunToIDMapTy returnSymMap
return map
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50
unsigned SymID
Definition GeneralType.h:57

◆ getBlkObj()

MemObj * SVF::SymbolTableInfo::getBlkObj ( ) const
inline

Definition at line 174 of file SymbolTableInfo.h.

175 {
176 return getObj(blackholeSymID());
177 }
SymID blackholeSymID() const
MemObj * getObj(SymID id) const

◆ getConstantObj()

MemObj * SVF::SymbolTableInfo::getConstantObj ( ) const
inline

Definition at line 178 of file SymbolTableInfo.h.

179 {
180 return getObj(constantSymID());
181 }
SymID constantSymID() const

◆ getFlattenedElemIdx()

u32_t SymbolTableInfo::getFlattenedElemIdx ( const SVFType T,
u32_t  origId 
)

Flattened element idx of an array or struct by considering stride.

Flattened offset information of a struct or an array including its array fields.

When Options::ModelArrays is disabled, any element index Array is modeled as the base

Definition at line 181 of file SymbolTableInfo.cpp.

182{
184 {
185 const std::vector<u32_t>& so = getTypeInfo(T)->getFlattenedElemIdxVec();
186 assert ((unsigned)origId < so.size() && !so.empty() && "element index out of bounds, can't get flattened index!");
187 return so[origId];
188 }
189 else
190 {
191 if(SVFUtil::isa<SVFStructType>(T))
192 {
193 const std::vector<u32_t>& so = getTypeInfo(T)->getFlattenedFieldIdxVec();
194 assert ((unsigned)origId < so.size() && !so.empty() && "Struct index out of bounds, can't get flattened index!");
195 return so[origId];
196 }
197 else
198 {
200 assert(SVFUtil::isa<SVFArrayType>(T) && "Only accept struct or array type if Options::ModelArrays is disabled!");
201 return 0;
202 }
203 }
204}
static const Option< bool > ModelArrays
Definition Options.h:188
std::vector< u32_t > & getFlattenedElemIdxVec()
Definition SVFType.h:98
std::vector< u32_t > & getFlattenedFieldIdxVec()
Definition SVFType.h:94
const StInfo * getTypeInfo(const SVFType *T) const
Get struct info.

◆ getFlattenFieldTypes()

const std::vector< const SVFType * > & SymbolTableInfo::getFlattenFieldTypes ( const SVFStructType T)
protected

Return the flattened field type for struct type only.

Definition at line 229 of file SymbolTableInfo.cpp.

230{
232}
std::vector< const SVFType * > & getFlattenFieldTypes()
Definition SVFType.h:106

◆ getFlatternedElemType()

const SVFType * SymbolTableInfo::getFlatternedElemType ( const SVFType baseType,
u32_t  flatten_idx 
)

Return the type of a flattened element given a flattened index.

Definition at line 212 of file SymbolTableInfo.cpp.

213{
215 {
216 const std::vector<const SVFType*>& so = getTypeInfo(baseType)->getFlattenElementTypes();
217 assert (flatten_idx < so.size() && !so.empty() && "element index out of bounds or struct opaque type, can't get element type!");
218 return so[flatten_idx];
219 }
220 else
221 {
222 const std::vector<const SVFType*>& so = getTypeInfo(baseType)->getFlattenFieldTypes();
223 assert (flatten_idx < so.size() && !so.empty() && "element index out of bounds or struct opaque type, can't get element type!");
224 return so[flatten_idx];
225 }
226}
std::vector< const SVFType * > & getFlattenElementTypes()
Definition SVFType.h:102

◆ getMaxStructSize()

u32_t SVF::SymbolTableInfo::getMaxStructSize ( ) const
inline

Definition at line 252 of file SymbolTableInfo.h.

253 {
254 return maxStSize;
255 }

◆ getModelConstants()

bool SVF::SymbolTableInfo::getModelConstants ( ) const
inline

Definition at line 134 of file SymbolTableInfo.h.

135 {
136 return modelConstants;
137 }

◆ getModule()

SVFModule * SVF::SymbolTableInfo::getModule ( )
inline

Module.

Definition at line 141 of file SymbolTableInfo.h.

142 {
143 return mod;
144 }

◆ getModulusOffset()

APOffset SymbolTableInfo::getModulusOffset ( const MemObj obj,
const APOffset apOffset 
)
virtual

Given an offset from a Gep Instruction, return it modulus offset by considering memory layout.

Get modulus offset given the type information

if the offset is negative, it's possible that we're looking for an obj node out of range of current struct. Make the offset positive so we can still get a node within current struct to represent this obj.

@offset: the index allocated to the newly generated field node; @Options::MaxFieldLimit(): preset upper bound of field number; @maxOffset: the max field number of the base object;

E.g., offset == 260, maxOffset == 270, Options::MaxFieldLimit() == 256 ==> offset = 4

E.g., offset == 100, maxOffset == 98, Options::MaxFieldLimit() == 256 ==> offset = 2

E.g., offset == 100, maxOffset == 98, Options::MaxFieldLimit() == 256 ==> offset = 97

Definition at line 94 of file SymbolTableInfo.cpp.

95{
96
100
101 APOffset offset = apOffset;
102 if(offset < 0)
103 {
104 writeWrnMsg("try to create a gep node with negative offset.");
105 offset = abs(offset);
106 }
107 u32_t maxOffset = obj->getMaxFieldOffsetLimit();
108
114 if (maxOffset == 0)
115 offset = 0;
121 else if ((u32_t)offset > maxOffset - 1)
122 {
128 else
132 offset = maxOffset - 1;
133 }
134
135 return offset;
136}
unsigned u32_t
Definition CommandLine.h:18
buffer offset
Definition cJSON.cpp:1113
static const Option< bool > CyclicFldIdx
Definition Options.h:189
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition SVFUtil.cpp:67
s64_t APOffset
Definition GeneralType.h:60

◆ getNumOfFlattenElements()

u32_t SymbolTableInfo::getNumOfFlattenElements ( const SVFType T)

Number of flattened elements of an array or struct.

Get a reference to the components of struct_info. Number of flattened elements of an array or struct

Definition at line 172 of file SymbolTableInfo.cpp.

173{
176 else
178}
u32_t getNumOfFlattenElements() const
Return number of elements after flattening (including array elements)
Definition SVFType.h:139
u32_t getNumOfFlattenFields() const
Return the number of fields after flattening (ignoring array elements)
Definition SVFType.h:145

◆ getObj()

MemObj * SVF::SymbolTableInfo::getObj ( SymID  id) const
inline

Definition at line 223 of file SymbolTableInfo.h.

224 {
225 IDToMemMapTy::const_iterator iter = objMap.find(id);
226 assert(iter!=objMap.end() && "obj not found");
227 return iter->second;
228 }

◆ getObjSym()

SymID SVF::SymbolTableInfo::getObjSym ( const SVFValue val) const
inline

Definition at line 213 of file SymbolTableInfo.h.

214 {
215 const SVFValue* svfVal = val;
216 if(const SVFGlobalValue* g = SVFUtil::dyn_cast<SVFGlobalValue>(val))
217 svfVal = g->getDefGlobalForMultipleModule();
218 ValueToIDMapTy::const_iterator iter = objSymMap.find(svfVal);
219 assert(iter!=objSymMap.end() && "obj sym not found");
220 return iter->second;
221 }

◆ getOriginalElemType()

const SVFType * SymbolTableInfo::getOriginalElemType ( const SVFType baseType,
u32_t  origId 
) const

struct A { int id; int salary; }; struct B { char name[20]; struct A a;} B b; OriginalElemType of b with field_idx 1 : Struct A FlatternedElemType of b with field_idx 1 : int

Definition at line 206 of file SymbolTableInfo.cpp.

207{
209}
const SVFType * getOriginalElemType(u32_t fldIdx) const
Definition SVFValue.cpp:20

◆ getRetSym()

SymID SVF::SymbolTableInfo::getRetSym ( const SVFFunction val) const
inline

Definition at line 230 of file SymbolTableInfo.h.

231 {
232 FunToIDMapTy::const_iterator iter = returnSymMap.find(val);
233 assert(iter!=returnSymMap.end() && "ret sym not found");
234 return iter->second;
235 }

◆ getStInfos()

const Set< const StInfo * > & SVF::SymbolTableInfo::getStInfos ( ) const
inline

Definition at line 299 of file SymbolTableInfo.h.

300 {
301 return stInfos;
302 }

◆ getSVFTypes()

const SVFTypeSet & SVF::SymbolTableInfo::getSVFTypes ( ) const
inline

Constant reader that won't change the state of the symbol table.

Definition at line 294 of file SymbolTableInfo.h.

295 {
296 return svfTypes;
297 }

◆ getTotalSymNum()

u32_t SVF::SymbolTableInfo::getTotalSymNum ( ) const
inline

Statistics.

Definition at line 248 of file SymbolTableInfo.h.

249 {
250 return totalSymNum;
251 }

◆ getTypeInfo()

const StInfo * SymbolTableInfo::getTypeInfo ( const SVFType T) const

Get struct info.

Get a reference to StructInfo.

Definition at line 57 of file SymbolTableInfo.cpp.

58{
59 assert(T);
60 SVFTypeSet::const_iterator it = svfTypes.find(T);
61 assert(it != svfTypes.end() && "type info not found? collect them first during SVFIR Building");
62 return (*it)->getTypeInfo();
63}

◆ getValSym()

SymID SymbolTableInfo::getValSym ( const SVFValue val)

Get different kinds of syms.

Definition at line 523 of file SymbolTableInfo.cpp.

524{
525
526 if(val->isNullPtr())
527 return nullPtrSymID();
528 else if (val->isblackHole())
529 return blkPtrSymID();
530 else
531 {
532 ValueToIDMapTy::const_iterator iter = valSymMap.find(val);
533 assert(iter!=valSymMap.end() &&"value sym not found");
534 return iter->second;
535 }
536}
SymID blkPtrSymID() const
SymID nullPtrSymID() const

◆ getVarargSym()

SymID SVF::SymbolTableInfo::getVarargSym ( const SVFFunction val) const
inline

Definition at line 237 of file SymbolTableInfo.h.

238 {
239 FunToIDMapTy::const_iterator iter = varargSymMap.find(val);
240 assert(iter!=varargSymMap.end() && "vararg sym not found");
241 return iter->second;
242 }

◆ hasSVFTypeInfo()

bool SVF::SymbolTableInfo::hasSVFTypeInfo ( const SVFType T)
inline

Definition at line 309 of file SymbolTableInfo.h.

310 {
311 return svfTypes.find(T) != svfTypes.end();
312 }

◆ hasValSym()

bool SymbolTableInfo::hasValSym ( const SVFValue val)

Definition at line 538 of file SymbolTableInfo.cpp.

539{
540 if (val->isNullPtr() || val->isblackHole())
541 return true;
542 else
543 return (valSymMap.find(val) != valSymMap.end());
544}

◆ idToObjMap() [1/2]

IDToMemMapTy & SVF::SymbolTableInfo::idToObjMap ( )
inline

Definition at line 270 of file SymbolTableInfo.h.

271 {
272 return objMap;
273 }

◆ idToObjMap() [2/2]

const IDToMemMapTy & SVF::SymbolTableInfo::idToObjMap ( ) const
inline

Definition at line 275 of file SymbolTableInfo.h.

276 {
277 return objMap;
278 }

◆ isBlkObj()

static bool SVF::SymbolTableInfo::isBlkObj ( NodeID  id)
inlinestatic

Definition at line 161 of file SymbolTableInfo.h.

162 {
163 return (id == BlackHole);
164 }

◆ isBlkObjOrConstantObj()

static bool SVF::SymbolTableInfo::isBlkObjOrConstantObj ( NodeID  id)
inlinestatic

Definition at line 169 of file SymbolTableInfo.h.

170 {
171 return (isBlkObj(id) || isConstantObj(id));
172 }
static bool isConstantObj(NodeID id)
static bool isBlkObj(NodeID id)

◆ isBlkPtr()

static bool SVF::SymbolTableInfo::isBlkPtr ( NodeID  id)
inlinestatic

special value

Definition at line 153 of file SymbolTableInfo.h.

154 {
155 return (id == BlkPtr);
156 }

◆ isConstantObj()

static bool SVF::SymbolTableInfo::isConstantObj ( NodeID  id)
inlinestatic

Definition at line 165 of file SymbolTableInfo.h.

166 {
167 return (id == ConstantObj);
168 }

◆ isNullPtr()

static bool SVF::SymbolTableInfo::isNullPtr ( NodeID  id)
inlinestatic

Definition at line 157 of file SymbolTableInfo.h.

158 {
159 return (id == NullPtr);
160 }

◆ nullPtrSymID()

SymID SVF::SymbolTableInfo::nullPtrSymID ( ) const
inline

Definition at line 188 of file SymbolTableInfo.h.

189 {
190 return NullPtr;
191 }

◆ objSyms()

ValueToIDMapTy & SVF::SymbolTableInfo::objSyms ( )
inline

Definition at line 265 of file SymbolTableInfo.h.

266 {
267 return objSymMap;
268 }

◆ printFlattenFields()

void SymbolTableInfo::printFlattenFields ( const SVFType type)

Debug method.

All rest types are scalar type?

Definition at line 237 of file SymbolTableInfo.cpp.

238{
239
240 if (const SVFArrayType* at = SVFUtil::dyn_cast<SVFArrayType>(type))
241 {
242 outs() << " {Type: " << *at << "}\n"
243 << "\tarray type "
244 << "\t [element size = " << getNumOfFlattenElements(at) << "]\n"
245 << "\n";
246 }
247 else if (const SVFStructType *st = SVFUtil::dyn_cast<SVFStructType>(type))
248 {
249 outs() <<" {Type: " << *st << "}\n";
250 const std::vector<const SVFType*>& finfo = getTypeInfo(st)->getFlattenFieldTypes();
251 int field_idx = 0;
252 for(const SVFType* type : finfo)
253 {
254 outs() << " \tField_idx = " << ++field_idx
255 << ", field type: " << *type << "\n";
256 }
257 outs() << "\n";
258 }
259 else if (const SVFPointerType* pt= SVFUtil::dyn_cast<SVFPointerType>(type))
260 {
261 outs() << *pt << "\n";
262 }
263 else if (const SVFFunctionType* fu =
264 SVFUtil::dyn_cast<SVFFunctionType>(type))
265 {
266 outs() << " {Type: " << *fu << "}\n\n";
267 }
268 else if (const SVFOtherType* ot = SVFUtil::dyn_cast<SVFOtherType>(type))
269 {
270 outs() << " {Type: "<< *ot << "(SVFOtherType)}\n\n";
271 }
272 else
273 {
274 assert(type->isSingleValueType() && "not a single value type, then what else!!");
277 outs() << " {Type: " << *type << "}\n"
278 << "\t [object size = " << eSize << "]\n"
279 << "\n";
280 }
281}
u32_t getNumOfFlattenElements(const SVFType *T)
Number of flattened elements of an array or struct.

◆ releaseSymbolInfo()

static void SVF::SymbolTableInfo::releaseSymbolInfo ( )
inlinestatic

Definition at line 117 of file SymbolTableInfo.h.

118 {
119 delete symInfo;
120 symInfo = nullptr;
121 }
static SymbolTableInfo * symInfo

◆ retSyms()

FunToIDMapTy & SVF::SymbolTableInfo::retSyms ( )
inline

Definition at line 280 of file SymbolTableInfo.h.

281 {
282 return returnSymMap;
283 }

◆ setModelConstants()

void SVF::SymbolTableInfo::setModelConstants ( bool  _modelConstants)
inline

Set / Get modelConstants.

Definition at line 130 of file SymbolTableInfo.h.

131 {
133 }

◆ setModule()

void SVF::SymbolTableInfo::setModule ( SVFModule m)
inline

Module.

Definition at line 146 of file SymbolTableInfo.h.

147 {
148 mod = m;
149 }

◆ SymbolInfo()

SymbolTableInfo * SymbolTableInfo::SymbolInfo ( )
static

Singleton design here to make sure we only have one instance during any analysis.

Get the symbol table instance

Definition at line 81 of file SymbolTableInfo.cpp.

82{
83 if (symInfo == nullptr)
84 {
87 }
88 return symInfo;
89}
static const Option< bool > ModelConsts
Definition Options.h:187
void setModelConstants(bool _modelConstants)
Set / Get modelConstants.
SymbolTableInfo(void)
Constructor.

◆ toString()

std::string SymbolTableInfo::toString ( SYMTYPE  symtype)
static

Definition at line 283 of file SymbolTableInfo.cpp.

284{
285 switch (symtype)
286 {
288 {
289 return "BlackHole";
290 }
292 {
293 return "ConstantObj";
294 }
295 case SYMTYPE::BlkPtr:
296 {
297 return "BlkPtr";
298 }
299 case SYMTYPE::NullPtr:
300 {
301 return "NullPtr";
302 }
304 {
305 return "ValSym";
306 }
308 {
309 return "ObjSym";
310 }
312 {
313 return "RetSym";
314 }
316 {
317 return "VarargSym";
318 }
319 default:
320 {
321 return "Invalid SYMTYPE";
322 }
323 }
324}

◆ valSyms()

ValueToIDMapTy & SVF::SymbolTableInfo::valSyms ( )
inline

Get different kinds of syms maps.

Definition at line 260 of file SymbolTableInfo.h.

261 {
262 return valSymMap;
263 }

◆ varargSyms()

FunToIDMapTy & SVF::SymbolTableInfo::varargSyms ( )
inline

Definition at line 285 of file SymbolTableInfo.h.

286 {
287 return varargSymMap;
288 }

Friends And Related Symbol Documentation

◆ SVFIRReader

Definition at line 51 of file SymbolTableInfo.h.

◆ SVFIRWriter

Definition at line 50 of file SymbolTableInfo.h.

◆ SymbolTableBuilder

Definition at line 49 of file SymbolTableInfo.h.

Member Data Documentation

◆ maxStruct

const SVFType* SVF::SymbolTableInfo::maxStruct

The struct type with the most fields.

Definition at line 340 of file SymbolTableInfo.h.

◆ maxStSize

u32_t SVF::SymbolTableInfo::maxStSize

The number of fields in max_struct.

Definition at line 343 of file SymbolTableInfo.h.

◆ mod

SVFModule* SVF::SymbolTableInfo::mod
private

Module.

Definition at line 92 of file SymbolTableInfo.h.

◆ modelConstants

bool SVF::SymbolTableInfo::modelConstants
private

Whether to model constants.

Definition at line 98 of file SymbolTableInfo.h.

◆ objMap

IDToMemMapTy SVF::SymbolTableInfo::objMap
private

map a memory sym id to its obj

Definition at line 86 of file SymbolTableInfo.h.

◆ objSymMap

ValueToIDMapTy SVF::SymbolTableInfo::objSymMap
private

map a obj reference to its sym id

Definition at line 83 of file SymbolTableInfo.h.

◆ returnSymMap

FunToIDMapTy SVF::SymbolTableInfo::returnSymMap
private

return map

Definition at line 84 of file SymbolTableInfo.h.

◆ stInfos

Set<const StInfo*> SVF::SymbolTableInfo::stInfos
protected

(owned) All StInfo

Definition at line 373 of file SymbolTableInfo.h.

◆ svfTypes

SVFTypeSet SVF::SymbolTableInfo::svfTypes
protected

(owned) All SVF Types Every type T is mapped to StInfo which contains size (fsize) , offset(foffset) fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1. fsize[0] is always the size of the expanded struct.

Definition at line 370 of file SymbolTableInfo.h.

◆ symInfo

SymbolTableInfo * SymbolTableInfo::symInfo = nullptr
staticprivate

Definition at line 89 of file SymbolTableInfo.h.

◆ totalSymNum

SymID SVF::SymbolTableInfo::totalSymNum
private

total number of symbols

Definition at line 101 of file SymbolTableInfo.h.

◆ valSymMap

ValueToIDMapTy SVF::SymbolTableInfo::valSymMap
private

map a value to its sym id

Definition at line 82 of file SymbolTableInfo.h.

◆ varargSymMap

FunToIDMapTy SVF::SymbolTableInfo::varargSymMap
private

vararg map

Definition at line 85 of file SymbolTableInfo.h.


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