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 | Friends | List of all members
SVF::IRGraph Class Reference

#include <IRGraph.h>

Inheritance diagram for SVF::IRGraph:
SVF::GenericGraph< SVFVar, SVFStmt > SVF::SVFIR

Public Types

enum  SYMTYPE {
  NullPtr , BlkPtr , BlackHole , ConstantObj ,
  ValSymbol , ObjSymbol , RetSymbol , VarargSymbol
}
 Symbol types. More...
 
typedef OrderedMap< NodeID, ObjTypeInfo * > IDToTypeInfoMapTy
 various maps defined
 
typedef OrderedMap< const FunObjVar *, NodeIDFunObjVarToIDMapTy
 function to sym id map
 
typedef Set< const SVFType * > SVFTypeSet
 struct type to struct info map
 
typedef Set< const SVFStmt * > SVFStmtSet
 
- Public Types inherited from SVF::GenericGraph< SVFVar, SVFStmt >
typedef SVFVar NodeType
 
typedef SVFStmt EdgeType
 
typedef OrderedMap< NodeID, NodeType * > IDToNodeMapTy
 NodeID to GenericNode map.
 
typedef IDToNodeMapTy::iterator iterator
 Node Iterators.
 
typedef IDToNodeMapTy::const_iterator const_iterator
 

Public Member Functions

 IRGraph (bool buildFromFile)
 
virtual ~IRGraph ()
 
bool isBuiltFromFile ()
 Whether this SVFIR built from a txt file.
 
NodeID blkPtrSymID () const
 
NodeID nullPtrSymID () const
 
NodeID constantSymID () const
 
NodeID blackholeSymID () const
 
u32_t getTotalSymNum () const
 Statistics.
 
u32_t getMaxStructSize () const
 
IDToTypeInfoMapTyidToObjTypeInfoMap ()
 Get different kinds of syms maps.
 
const IDToTypeInfoMapTyidToObjTypeInfoMap () const
 
FunObjVarToIDMapTyretFunObjSyms ()
 
FunObjVarToIDMapTyvarargFunObjSyms ()
 
ObjTypeInfogetObjTypeInfo (NodeID id) const
 
NodeID getReturnNode (const FunObjVar *func) const
 GetReturnNode - Return the unique node representing the return value of a function.
 
NodeID getVarargNode (const FunObjVar *func) const
 getVarargNode - Return the unique node representing the variadic argument of a variadic function.
 
NodeID getBlackHoleNode () const
 
NodeID getConstantNode () const
 
NodeID getBlkPtr () const
 
NodeID getNullPtr () const
 
u32_t getValueNodeNum ()
 
u32_t getObjectNodeNum ()
 
const SVFTypeSetgetSVFTypes () const
 Constant reader that won't change the state of the symbol table.
 
const SVFTypegetSVFType (u32_t id) const
 
const Set< const StInfo * > & getStInfos () const
 
virtual APOffset getModulusOffset (const BaseObjVar *baseObj, const APOffset &apOffset)
 Given an offset from a Gep Instruction, return it modulus offset by considering memory layout.
 
const StInfogetTypeInfo (const SVFType *T) const
 Get struct info.
 
bool hasSVFTypeInfo (const SVFType *T)
 
ObjTypeInfocreateObjTypeInfo (const SVFType *type)
 Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
 
const ObjTypeInfocreateDummyObjTypeInfo (NodeID symId, const SVFType *type)
 
u32_t getNumOfFlattenElements (const SVFType *T)
 
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.
 
u32_t getNodeNumAfterPAGBuild () const
 
void setNodeNumAfterPAGBuild (u32_t num)
 
u32_t getSVFVarNum () const
 
u32_t getSVFStmtNum () const
 
u32_t getPTAPAGEdgeNum () const
 
std::string getGraphName () const
 Return graph name.
 
void dumpSymTable ()
 
void dump (std::string name)
 Dump SVFIR.
 
void view ()
 View graph from the debugger.
 
void addTypeInfo (const SVFType *ty)
 
void addStInfo (StInfo *stInfo)
 
- Public Member Functions inherited from SVF::GenericGraph< SVFVar, SVFStmt >
 GenericGraph ()
 Constructor.
 
virtual ~GenericGraph ()
 Destructor.
 
void destroy ()
 Release memory.
 
iterator begin ()
 Iterators.
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node.
 
NodeTypegetGNode (NodeID id) const
 Get a node.
 
bool hasGNode (NodeID id) const
 Has a node.
 
void removeGNode (NodeType *node)
 Delete a node.
 
u32_t getTotalNodeNum () const
 Get total number of node/edge.
 
u32_t getTotalEdgeNum () const
 
void incNodeNum ()
 Increase number of node/edge.
 
void incEdgeNum ()
 

Static Public Member Functions

static bool isBlkPtr (NodeID id)
 special value
 
static bool isNullPtr (NodeID id)
 
static bool isBlkObj (NodeID id)
 
static bool isConstantSym (NodeID id)
 
static bool isBlkObjOrConstantObj (NodeID id)
 

Public Attributes

const SVFTypemaxStruct
 The struct type with the most fields.
 
u32_t maxStSize
 The number of fields in max_struct.
 
- Public Attributes inherited from SVF::GenericGraph< SVFVar, SVFStmt >
u32_t edgeNum
 total num of node
 
u32_t nodeNum
 total num of edge
 

Protected Member Functions

NodeID addNode (SVFVar *node)
 Add a node into the graph.
 
bool addEdge (SVFVar *src, SVFVar *dst, SVFStmt *edge)
 Add an edge into the graph.
 
SVFStmthasNonlabeledEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
 
SVFStmthasLabeledEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind, const ICFGNode *cs)
 
SVFStmthasEdge (SVFStmt *edge, SVFStmt::PEDGEK kind)
 
SVFStmthasLabeledEdge (SVFVar *src, SVFVar *op1, SVFStmt::PEDGEK kind, const SVFVar *op2)
 
const std::vector< const SVFType * > & getFlattenFieldTypes (const SVFStructType *T)
 Return the flattened field type for struct type only.
 

Protected Attributes

SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
 SVFIR edge map containing all PAGEdges.
 
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
 SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
 
bool fromFile
 Whether the SVFIR is built according to user specified data from a txt file.
 
NodeID nodeNumAfterPAGBuild
 initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
 
u32_t totalPTAPAGEdge
 
u32_t valVarNum
 
u32_t objVarNum
 
- Protected Attributes inherited from SVF::GenericGraph< SVFVar, SVFStmt >
IDToNodeMapTy IDToNodeMap
 node map
 

Private Member Functions

void destorySymTable ()
 

Private Attributes

FunObjVarToIDMapTy returnFunObjSymMap
 return map
 
FunObjVarToIDMapTy varargFunObjSymMap
 vararg map
 
IDToTypeInfoMapTy objTypeInfoMap
 map a memory sym id to its obj
 
SVFTypeSet svfTypes
 
Set< const StInfo * > stInfos
 (owned) All StInfo
 
NodeID totalSymNum
 total number of symbols
 

Friends

class SVFIRBuilder
 
class SymbolTableBuilder
 
class GraphDBClient
 

Detailed Description

Definition at line 50 of file IRGraph.h.

Member Typedef Documentation

◆ FunObjVarToIDMapTy

function to sym id map

Definition at line 77 of file IRGraph.h.

◆ IDToTypeInfoMapTy

various maps defined

sym id to obj type info map

Definition at line 74 of file IRGraph.h.

◆ SVFStmtSet

Definition at line 104 of file IRGraph.h.

◆ SVFTypeSet

struct type to struct info map

Definition at line 80 of file IRGraph.h.

Member Enumeration Documentation

◆ SYMTYPE

Symbol types.

Enumerator
NullPtr 
BlkPtr 
BlackHole 
ConstantObj 
ValSymbol 
ObjSymbol 
RetSymbol 
VarargSymbol 

Definition at line 59 of file IRGraph.h.

60 {
61 NullPtr,
62 BlkPtr,
69 };

Constructor & Destructor Documentation

◆ IRGraph()

SVF::IRGraph::IRGraph ( bool  buildFromFile)
inline

Definition at line 139 of file IRGraph.h.

141 maxStruct(nullptr), maxStSize(0)
142 {
143 }
const SVFType * maxStruct
The struct type with the most fields.
Definition IRGraph.h:358
u32_t valVarNum
Definition IRGraph.h:112
bool fromFile
Whether the SVFIR is built according to user specified data from a txt file.
Definition IRGraph.h:109
NodeID nodeNumAfterPAGBuild
initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
Definition IRGraph.h:110
NodeID totalSymNum
total number of symbols
Definition IRGraph.h:99
u32_t objVarNum
Definition IRGraph.h:113
u32_t totalPTAPAGEdge
Definition IRGraph.h:111
u32_t maxStSize
The number of fields in max_struct.
Definition IRGraph.h:361
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~IRGraph()

IRGraph::~IRGraph ( )
virtual

Definition at line 58 of file IRGraph.cpp.

59{
61}
void destorySymTable()
Definition IRGraph.cpp:40

Member Function Documentation

◆ addEdge()

bool IRGraph::addEdge ( SVFVar src,
SVFVar dst,
SVFStmt edge 
)
protected

Add an edge into the graph.

Add a SVFIR edge into edge map

Definition at line 257 of file IRGraph.cpp.

258{
259
261 outs() << "add edge from " << src->getId() << " kind :"
262 << src->getNodeKind() << " to " << dst->getId()
263 << " kind :" << dst->getNodeKind() << "\n");
264 src->addOutEdge(edge);
265 dst->addInEdge(edge);
266 return true;
267}
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:576
#define DPAGBuild
Definition SVFType.h:584
NodeID getId() const
Get ID.
Definition SVFValue.h:158
GNodeK getNodeKind() const
Get node kind.
Definition SVFValue.h:164
void addOutEdge(SVFStmt *outEdge)
void addInEdge(SVFStmt *inEdge)
Edge management methods.
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52

◆ addNode()

NodeID SVF::IRGraph::addNode ( SVFVar node)
inlineprotected

Add a node into the graph.

Definition at line 116 of file IRGraph.h.

117 {
118 assert(node && "cannot add a null node");
119 addGNode(node->getId(),node);
120 return node->getId();
121 }
void addGNode(NodeID id, NodeType *node)
Add a Node.

◆ addStInfo()

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

Definition at line 370 of file IRGraph.h.

371 {
372 stInfo->setStinfoId(stInfos.size());
373 stInfos.insert(stInfo);
374 }
Set< const StInfo * > stInfos
(owned) All StInfo
Definition IRGraph.h:96

◆ addTypeInfo()

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

Definition at line 363 of file IRGraph.h.

364 {
365 bool inserted = svfTypes.insert(ty).second;
366 if(!inserted)
367 assert(false && "this type info has been added before");
368 }
SVFTypeSet svfTypes
Definition IRGraph.h:93

◆ blackholeSymID()

NodeID SVF::IRGraph::blackholeSymID ( ) const
inline

Definition at line 192 of file IRGraph.h.

193 {
194 return BlackHole;
195 }

◆ blkPtrSymID()

NodeID SVF::IRGraph::blkPtrSymID ( ) const
inline

Definition at line 177 of file IRGraph.h.

178 {
179 return BlkPtr;
180 }

◆ constantSymID()

NodeID SVF::IRGraph::constantSymID ( ) const
inline

Definition at line 187 of file IRGraph.h.

188 {
189 return ConstantObj;
190 }

◆ createDummyObjTypeInfo()

const ObjTypeInfo * IRGraph::createDummyObjTypeInfo ( NodeID  symId,
const SVFType type 
)

Definition at line 181 of file IRGraph.cpp.

182{
183 if (objTypeInfoMap.find(symId)==objTypeInfoMap.end())
184 {
187 }
189 return ti;
190}
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 ...
Definition IRGraph.cpp:235
IDToTypeInfoMapTy objTypeInfoMap
map a memory sym id to its obj
Definition IRGraph.h:86

◆ createObjTypeInfo()

ObjTypeInfo * IRGraph::createObjTypeInfo ( const SVFType type)

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

Definition at line 235 of file IRGraph.cpp.

236{
237
239 if(type && type->isPointerTy())
240 {
242 }
243 return typeInfo;
244}
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:34

◆ destorySymTable()

void IRGraph::destorySymTable ( )
private

Definition at line 40 of file IRGraph.cpp.

41{
42
43 for (auto &pair: objTypeInfoMap)
44 {
45 if (ObjTypeInfo* ti = pair.second)
46 delete ti;
47 }
48
49 for (const SVFType* type : svfTypes)
51 svfTypes.clear();
52
53 for (const StInfo* st : stInfos)
54 delete st;
55 stInfos.clear();
56}

◆ dump()

void IRGraph::dump ( std::string  name)

Dump SVFIR.

Dump this IRGraph

Definition at line 320 of file IRGraph.cpp.

321{
323}
const char *const name
Definition cJSON.h:264
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType &GT, bool simple=false)

◆ dumpSymTable()

void SVF::IRGraph::dumpSymTable ( )

◆ getBlackHoleNode()

NodeID SVF::IRGraph::getBlackHoleNode ( ) const
inline

Definition at line 246 of file IRGraph.h.

247 {
248 return blackholeSymID();
249 }
NodeID blackholeSymID() const
Definition IRGraph.h:192

◆ getBlkPtr()

NodeID SVF::IRGraph::getBlkPtr ( ) const
inline

Definition at line 254 of file IRGraph.h.

255 {
256 return blkPtrSymID();
257 }
NodeID blkPtrSymID() const
Definition IRGraph.h:177

◆ getConstantNode()

NodeID SVF::IRGraph::getConstantNode ( ) const
inline

Definition at line 250 of file IRGraph.h.

251 {
252 return constantSymID();
253 }
NodeID constantSymID() const
Definition IRGraph.h:187

◆ getFlattenedElemIdx()

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

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

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

Definition at line 148 of file IRGraph.cpp.

149{
151 {
152 const std::vector<u32_t>& so = getTypeInfo(T)->getFlattenedElemIdxVec();
153 assert ((unsigned)origId < so.size() && !so.empty() && "element index out of bounds, can't get flattened index!");
154 return so[origId];
155 }
156 else
157 {
158 if(SVFUtil::isa<SVFStructType>(T))
159 {
160 const std::vector<u32_t>& so = getTypeInfo(T)->getFlattenedFieldIdxVec();
161 assert ((unsigned)origId < so.size() && !so.empty() && "Struct index out of bounds, can't get flattened index!");
162 return so[origId];
163 }
164 else
165 {
167 assert(SVFUtil::isa<SVFArrayType>(T) && "Only accept struct or array type if Options::ModelArrays is disabled!");
168 return 0;
169 }
170 }
171}
const StInfo * getTypeInfo(const SVFType *T) const
Get struct info.
Definition IRGraph.cpp:246
static Option< bool > ModelArrays
Definition Options.h:178
std::vector< u32_t > & getFlattenedElemIdxVec()
Definition SVFType.h:123
std::vector< u32_t > & getFlattenedFieldIdxVec()
Definition SVFType.h:119

◆ getFlattenFieldTypes()

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

Return the flattened field type for struct type only.

Definition at line 122 of file IRGraph.cpp.

123{
125}
std::vector< const SVFType * > & getFlattenFieldTypes()
Definition SVFType.h:131

◆ getFlatternedElemType()

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

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

Definition at line 127 of file IRGraph.cpp.

128{
130 {
131 const std::vector<const SVFType*>& so = getTypeInfo(baseType)->getFlattenElementTypes();
132 assert (flatten_idx < so.size() && !so.empty() && "element index out of bounds or struct opaque type, can't get element type!");
133 return so[flatten_idx];
134 }
135 else
136 {
137 const std::vector<const SVFType*>& so = getTypeInfo(baseType)->getFlattenFieldTypes();
138 assert (flatten_idx < so.size() && !so.empty() && "element index out of bounds or struct opaque type, can't get element type!");
139 return so[flatten_idx];
140 }
141}
std::vector< const SVFType * > & getFlattenElementTypes()
Definition SVFType.h:127

◆ getGraphName()

std::string SVF::IRGraph::getGraphName ( ) const
inline

Return graph name.

Definition at line 342 of file IRGraph.h.

343 {
344 return "SVFIR";
345 }

◆ getMaxStructSize()

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

Definition at line 203 of file IRGraph.h.

204 {
205 return maxStSize;
206 }

◆ getModulusOffset()

APOffset IRGraph::getModulusOffset ( const BaseObjVar baseObj,
const APOffset apOffset 
)
virtual

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

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 192 of file IRGraph.cpp.

193{
197
198 APOffset offset = apOffset;
199 if(offset < 0)
200 {
201 writeWrnMsg("try to create a gep node with negative offset.");
202 offset = std::abs(offset);
203 }
204 u32_t maxOffset = baseObj->getMaxFieldOffsetLimit();
205
211 if (maxOffset == 0)
212 offset = 0;
218 else if ((u32_t)offset > maxOffset - 1)
219 {
225 else
229 offset = maxOffset - 1;
230 }
231
232 return offset;
233}
unsigned u32_t
Definition CommandLine.h:18
buffer offset
Definition cJSON.cpp:1113
static const Option< bool > CyclicFldIdx
Definition Options.h:179
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition SVFUtil.cpp:72
s64_t APOffset
Definition GeneralType.h:80

◆ getNodeNumAfterPAGBuild()

u32_t SVF::IRGraph::getNodeNumAfterPAGBuild ( ) const
inline

Definition at line 320 of file IRGraph.h.

321 {
323 }

◆ getNullPtr()

NodeID SVF::IRGraph::getNullPtr ( ) const
inline

Definition at line 258 of file IRGraph.h.

259 {
260 return nullPtrSymID();
261 }
NodeID nullPtrSymID() const
Definition IRGraph.h:182

◆ getNumOfFlattenElements()

u32_t IRGraph::getNumOfFlattenElements ( const SVFType T)

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

Definition at line 173 of file IRGraph.cpp.

174{
177 else
179}
u32_t getNumOfFlattenElements() const
Return number of elements after flattening (including array elements)
Definition SVFType.h:164
u32_t getNumOfFlattenFields() const
Return the number of fields after flattening (ignoring array elements)
Definition SVFType.h:170

◆ getObjectNodeNum()

u32_t IRGraph::getObjectNodeNum ( )

Definition at line 347 of file IRGraph.cpp.

348{
349 if (objVarNum != 0) return objVarNum;
350 u32_t num = 0;
351 for (const auto& item: *this)
352 {
353 if (SVFUtil::isa<ObjVar>(item.second))
354 num++;
355 }
356 return objVarNum = num;
357}
cJSON * item
Definition cJSON.h:222

◆ getObjTypeInfo()

ObjTypeInfo * SVF::IRGraph::getObjTypeInfo ( NodeID  id) const
inline

Definition at line 233 of file IRGraph.h.

234 {
235 IDToTypeInfoMapTy::const_iterator iter = objTypeInfoMap.find(id);
236 assert(iter!=objTypeInfoMap.end() && "obj type info not found");
237 return iter->second;
238 }

◆ getOriginalElemType()

const SVFType * IRGraph::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 143 of file IRGraph.cpp.

144{
146}
const SVFType * getOriginalElemType(u32_t fldIdx) const
Definition SVFValue.cpp:69

◆ getPTAPAGEdgeNum()

u32_t SVF::IRGraph::getPTAPAGEdgeNum ( ) const
inline

Definition at line 337 of file IRGraph.h.

338 {
339 return totalPTAPAGEdge;
340 }

◆ getReturnNode()

NodeID IRGraph::getReturnNode ( const FunObjVar func) const

GetReturnNode - Return the unique node representing the return value of a function.

Definition at line 64 of file IRGraph.cpp.

65{
66 FunObjVarToIDMapTy::const_iterator iter = returnFunObjSymMap.find(func);
67 assert(iter!=returnFunObjSymMap.end() && "ret sym not found");
68 return iter->second;
69}
FunObjVarToIDMapTy returnFunObjSymMap
return map
Definition IRGraph.h:84

◆ getStInfos()

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

Definition at line 282 of file IRGraph.h.

283 {
284 return stInfos;
285 }

◆ getSVFStmtNum()

u32_t SVF::IRGraph::getSVFStmtNum ( ) const
inline

Definition at line 333 of file IRGraph.h.

334 {
335 return edgeNum;
336 }

◆ getSVFType()

const SVFType * SVF::IRGraph::getSVFType ( u32_t  id) const
inline

Definition at line 273 of file IRGraph.h.

274 {
275 for(const SVFType* type : svfTypes)
276 {
277 if(type->getId() == id)
278 return type;
279 }
280 return nullptr;
281 }

◆ getSVFTypes()

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

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

Definition at line 268 of file IRGraph.h.

269 {
270 return svfTypes;
271 }

◆ getSVFVarNum()

u32_t SVF::IRGraph::getSVFVarNum ( ) const
inline

Definition at line 329 of file IRGraph.h.

330 {
331 return nodeNum;
332 }

◆ getTotalSymNum()

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

Statistics.

Definition at line 199 of file IRGraph.h.

200 {
201 return totalSymNum;
202 }

◆ getTypeInfo()

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

Get struct info.

Get a reference to StructInfo.

Definition at line 246 of file IRGraph.cpp.

247{
248 assert(T);
249 SVFTypeSet::const_iterator it = svfTypes.find(T);
250 assert(it != svfTypes.end() && "type info not found? collect them first during SVFIR Building");
251 return (*it)->getTypeInfo();
252}

◆ getValueNodeNum()

u32_t IRGraph::getValueNodeNum ( )

Definition at line 334 of file IRGraph.cpp.

335{
336 if (valVarNum != 0) return valVarNum;
337 u32_t num = 0;
338 for (const auto& item: *this)
339 {
340 if (SVFUtil::isa<ValVar>(item.second))
341 num++;
342 }
343 return valVarNum = num;
344}

◆ getVarargNode()

NodeID IRGraph::getVarargNode ( const FunObjVar func) const

getVarargNode - Return the unique node representing the variadic argument of a variadic function.

Definition at line 71 of file IRGraph.cpp.

72{
73 FunObjVarToIDMapTy::const_iterator iter = varargFunObjSymMap.find(func);
74 assert(iter!=varargFunObjSymMap.end() && "vararg sym not found");
75 return iter->second;
76}
FunObjVarToIDMapTy varargFunObjSymMap
vararg map
Definition IRGraph.h:85

◆ hasEdge()

SVFStmt * IRGraph::hasEdge ( SVFStmt edge,
SVFStmt::PEDGEK  kind 
)
protected

Definition at line 306 of file IRGraph.cpp.

307{
308 SVFStmt::SVFStmtSetTy::iterator it = KindToSVFStmtSetMap[kind].find(edge);
309 if (it != KindToSVFStmtSetMap[kind].end())
310 {
311 return *it;
312 }
313 return nullptr;
314}
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
SVFIR edge map containing all PAGEdges.
Definition IRGraph.h:107

◆ hasLabeledEdge() [1/2]

SVFStmt * IRGraph::hasLabeledEdge ( SVFVar src,
SVFVar dst,
SVFStmt::PEDGEK  kind,
const ICFGNode callInst 
)
protected

Return true if this labeled edge exits, including store, call and load two store edge can have same dst and src but located in different basic blocks, thus flags are needed to distinguish them

Return an inter-procedural edge if found

Definition at line 295 of file IRGraph.cpp.

296{
297 SVFStmt edge(src,dst,SVFStmt::makeEdgeFlagWithCallInst(kind,callInst), false);
298 SVFStmt::SVFStmtSetTy::iterator it = KindToSVFStmtSetMap[kind].find(&edge);
299 if (it != KindToSVFStmtSetMap[kind].end())
300 {
301 return *it;
302 }
303 return nullptr;
304}
static GEdgeFlag makeEdgeFlagWithCallInst(GEdgeKind k, const ICFGNode *cs)

◆ hasLabeledEdge() [2/2]

SVFStmt * IRGraph::hasLabeledEdge ( SVFVar src,
SVFVar op1,
SVFStmt::PEDGEK  kind,
const SVFVar op2 
)
protected

Return MultiOpndStmt since it has more than one operands (we use operand 2 here to make the flag)

Return an MultiOpndStmt if found

Definition at line 281 of file IRGraph.cpp.

282{
284 SVFStmt::SVFStmtSetTy::iterator it = KindToSVFStmtSetMap[kind].find(&edge);
285 if (it != KindToSVFStmtSetMap[kind].end())
286 {
287 return *it;
288 }
289 return nullptr;
290}
static GEdgeFlag makeEdgeFlagWithAddionalOpnd(GEdgeKind k, const SVFVar *var)

◆ hasNonlabeledEdge()

SVFStmt * IRGraph::hasNonlabeledEdge ( SVFVar src,
SVFVar dst,
SVFStmt::PEDGEK  kind 
)
protected

Return true if it is an intra-procedural edge

Definition at line 272 of file IRGraph.cpp.

273{
274 SVFStmt edge(src,dst,kind, false);
275 return hasEdge(&edge, kind);
276}
SVFStmt * hasEdge(SVFStmt *edge, SVFStmt::PEDGEK kind)
Definition IRGraph.cpp:306

◆ hasSVFTypeInfo()

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

Definition at line 293 of file IRGraph.h.

294 {
295 return svfTypes.find(T) != svfTypes.end();
296 }

◆ idToObjTypeInfoMap() [1/2]

IDToTypeInfoMapTy & SVF::IRGraph::idToObjTypeInfoMap ( )
inline

Get different kinds of syms maps.

Definition at line 211 of file IRGraph.h.

212 {
213 return objTypeInfoMap;
214 }

◆ idToObjTypeInfoMap() [2/2]

const IDToTypeInfoMapTy & SVF::IRGraph::idToObjTypeInfoMap ( ) const
inline

Definition at line 216 of file IRGraph.h.

217 {
218 return objTypeInfoMap;
219 }

◆ isBlkObj()

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

Definition at line 164 of file IRGraph.h.

165 {
166 return (id == BlackHole);
167 }

◆ isBlkObjOrConstantObj()

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

Definition at line 172 of file IRGraph.h.

173 {
174 return (isBlkObj(id) || isConstantSym(id));
175 }
static bool isBlkObj(NodeID id)
Definition IRGraph.h:164
static bool isConstantSym(NodeID id)
Definition IRGraph.h:168

◆ isBlkPtr()

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

special value

Definition at line 156 of file IRGraph.h.

157 {
158 return (id == BlkPtr);
159 }

◆ isBuiltFromFile()

bool SVF::IRGraph::isBuiltFromFile ( )
inline

Whether this SVFIR built from a txt file.

Definition at line 149 of file IRGraph.h.

150 {
151 return fromFile;
152 }

◆ isConstantSym()

static bool SVF::IRGraph::isConstantSym ( NodeID  id)
inlinestatic

Definition at line 168 of file IRGraph.h.

169 {
170 return (id == ConstantObj);
171 }

◆ isNullPtr()

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

Definition at line 160 of file IRGraph.h.

161 {
162 return (id == NullPtr);
163 }

◆ nullPtrSymID()

NodeID SVF::IRGraph::nullPtrSymID ( ) const
inline

Definition at line 182 of file IRGraph.h.

183 {
184 return NullPtr;
185 }

◆ printFlattenFields()

void IRGraph::printFlattenFields ( const SVFType type)

Debug method.

All rest types are scalar type?

Definition at line 77 of file IRGraph.cpp.

78{
79 if (const SVFArrayType* at = SVFUtil::dyn_cast<SVFArrayType>(type))
80 {
81 outs() << " {Type: " << *at << "}\n"
82 << "\tarray type "
83 << "\t [element size = " << getNumOfFlattenElements(at) << "]\n"
84 << "\n";
85 }
86 else if (const SVFStructType *st = SVFUtil::dyn_cast<SVFStructType>(type))
87 {
88 outs() <<" {Type: " << *st << "}\n";
89 const std::vector<const SVFType*>& finfo = getTypeInfo(st)->getFlattenFieldTypes();
90 int field_idx = 0;
91 for(const SVFType* type : finfo)
92 {
93 outs() << " \tField_idx = " << ++field_idx
94 << ", field type: " << *type << "\n";
95 }
96 outs() << "\n";
97 }
98 else if (const SVFPointerType* pt= SVFUtil::dyn_cast<SVFPointerType>(type))
99 {
100 outs() << *pt << "\n";
101 }
102 else if (const SVFFunctionType* fu =
103 SVFUtil::dyn_cast<SVFFunctionType>(type))
104 {
105 outs() << " {Type: " << *fu << "}\n\n";
106 }
107 else if (const SVFOtherType* ot = SVFUtil::dyn_cast<SVFOtherType>(type))
108 {
109 outs() << " {Type: "<< *ot << "(SVFOtherType)}\n\n";
110 }
111 else
112 {
113 assert(type->isSingleValueType() && "not a single value type, then what else!!");
116 outs() << " {Type: " << *type << "}\n"
117 << "\t [object size = " << eSize << "]\n"
118 << "\n";
119 }
120}
u32_t getNumOfFlattenElements(const SVFType *T)
Definition IRGraph.cpp:173

◆ retFunObjSyms()

FunObjVarToIDMapTy & SVF::IRGraph::retFunObjSyms ( )
inline

Definition at line 221 of file IRGraph.h.

222 {
223 return returnFunObjSymMap;
224 }

◆ setNodeNumAfterPAGBuild()

void SVF::IRGraph::setNodeNumAfterPAGBuild ( u32_t  num)
inline

Definition at line 324 of file IRGraph.h.

325 {
327 }

◆ varargFunObjSyms()

FunObjVarToIDMapTy & SVF::IRGraph::varargFunObjSyms ( )
inline

Definition at line 226 of file IRGraph.h.

227 {
228 return varargFunObjSymMap;
229 }

◆ view()

void IRGraph::view ( )

View graph from the debugger.

View IRGraph

Definition at line 328 of file IRGraph.cpp.

329{
330 SVF::ViewGraph(this, "ProgramAssignmentGraph");
331}
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)

Friends And Related Symbol Documentation

◆ GraphDBClient

friend class GraphDBClient
friend

Definition at line 54 of file IRGraph.h.

◆ SVFIRBuilder

Definition at line 52 of file IRGraph.h.

◆ SymbolTableBuilder

Definition at line 53 of file IRGraph.h.

Member Data Documentation

◆ fromFile

bool SVF::IRGraph::fromFile
protected

Whether the SVFIR is built according to user specified data from a txt file.

Definition at line 109 of file IRGraph.h.

◆ KindToPTASVFStmtSetMap

SVFStmt::KindToSVFStmtMapTy SVF::IRGraph::KindToPTASVFStmtSetMap
protected

SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.

Definition at line 108 of file IRGraph.h.

◆ KindToSVFStmtSetMap

SVFStmt::KindToSVFStmtMapTy SVF::IRGraph::KindToSVFStmtSetMap
protected

SVFIR edge map containing all PAGEdges.

Definition at line 107 of file IRGraph.h.

◆ maxStruct

const SVFType* SVF::IRGraph::maxStruct

The struct type with the most fields.

Definition at line 358 of file IRGraph.h.

◆ maxStSize

u32_t SVF::IRGraph::maxStSize

The number of fields in max_struct.

Definition at line 361 of file IRGraph.h.

◆ nodeNumAfterPAGBuild

NodeID SVF::IRGraph::nodeNumAfterPAGBuild
protected

initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes

Definition at line 110 of file IRGraph.h.

◆ objTypeInfoMap

IDToTypeInfoMapTy SVF::IRGraph::objTypeInfoMap
private

map a memory sym id to its obj

Definition at line 86 of file IRGraph.h.

◆ objVarNum

u32_t SVF::IRGraph::objVarNum
protected

Definition at line 113 of file IRGraph.h.

◆ returnFunObjSymMap

FunObjVarToIDMapTy SVF::IRGraph::returnFunObjSymMap
private

return map

Definition at line 84 of file IRGraph.h.

◆ stInfos

Set<const StInfo*> SVF::IRGraph::stInfos
private

(owned) All StInfo

Definition at line 96 of file IRGraph.h.

◆ svfTypes

SVFTypeSet SVF::IRGraph::svfTypes
private

(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 93 of file IRGraph.h.

◆ totalPTAPAGEdge

u32_t SVF::IRGraph::totalPTAPAGEdge
protected

Definition at line 111 of file IRGraph.h.

◆ totalSymNum

NodeID SVF::IRGraph::totalSymNum
private

total number of symbols

Definition at line 99 of file IRGraph.h.

◆ valVarNum

u32_t SVF::IRGraph::valVarNum
protected

Definition at line 112 of file IRGraph.h.

◆ varargFunObjSymMap

FunObjVarToIDMapTy SVF::IRGraph::varargFunObjSymMap
private

vararg map

Definition at line 85 of file IRGraph.h.


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