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 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 getPAGNodeNum () const
 
u32_t getPAGEdgeNum () 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)
 
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
 

Detailed Description

Definition at line 51 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 138 of file IRGraph.h.

140 maxStruct(nullptr), maxStSize(0)
141 {
142 }
const SVFType * maxStruct
The struct type with the most fields.
Definition IRGraph.h:349
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:352
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~IRGraph()

IRGraph::~IRGraph ( )
virtual

Definition at line 54 of file IRGraph.cpp.

55{
57}
void destorySymTable()
Definition IRGraph.cpp:36

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

254{
255
257 outs() << "add edge from " << src->getId() << " kind :"
258 << src->getNodeKind() << " to " << dst->getId()
259 << " kind :" << dst->getNodeKind() << "\n");
260 src->addOutEdge(edge);
261 dst->addInEdge(edge);
262 return true;
263}
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:497
#define DPAGBuild
Definition SVFType.h:505
NodeID getId() const
Get ID.
Definition SVFValue.h:160
GNodeK getNodeKind() const
Get node kind.
Definition SVFValue.h:166
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 361 of file IRGraph.h.

362 {
363 stInfos.insert(stInfo);
364 }
Set< const StInfo * > stInfos
(owned) All StInfo
Definition IRGraph.h:96

◆ addTypeInfo()

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

Definition at line 354 of file IRGraph.h.

355 {
356 bool inserted = svfTypes.insert(ty).second;
357 if(!inserted)
358 assert(false && "this type info has been added before");
359 }
SVFTypeSet svfTypes
Definition IRGraph.h:93

◆ blackholeSymID()

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

Definition at line 191 of file IRGraph.h.

192 {
193 return BlackHole;
194 }

◆ blkPtrSymID()

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

Definition at line 176 of file IRGraph.h.

177 {
178 return BlkPtr;
179 }

◆ constantSymID()

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

Definition at line 186 of file IRGraph.h.

187 {
188 return ConstantObj;
189 }

◆ createDummyObjTypeInfo()

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

Definition at line 177 of file IRGraph.cpp.

178{
179 if (objTypeInfoMap.find(symId)==objTypeInfoMap.end())
180 {
183 }
185 return ti;
186}
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:231
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 231 of file IRGraph.cpp.

232{
233
235 if(type && type->isPointerTy())
236 {
238 }
239 return typeInfo;
240}
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:35

◆ destorySymTable()

void IRGraph::destorySymTable ( )
private

Definition at line 36 of file IRGraph.cpp.

37{
38
39 for (auto &pair: objTypeInfoMap)
40 {
41 if (ObjTypeInfo* ti = pair.second)
42 delete ti;
43 }
44
45 for (const SVFType* type : svfTypes)
47 svfTypes.clear();
48
49 for (const StInfo* st : stInfos)
50 delete st;
51 stInfos.clear();
52}

◆ dump()

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

Dump SVFIR.

Dump this IRGraph

Definition at line 310 of file IRGraph.cpp.

311{
313}
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 245 of file IRGraph.h.

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

◆ getBlkPtr()

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

Definition at line 253 of file IRGraph.h.

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

◆ getConstantNode()

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

Definition at line 249 of file IRGraph.h.

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

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

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

◆ getFlattenFieldTypes()

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

Return the flattened field type for struct type only.

Definition at line 118 of file IRGraph.cpp.

119{
121}
std::vector< const SVFType * > & getFlattenFieldTypes()
Definition SVFType.h:104

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

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

◆ getGraphName()

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

Return graph name.

Definition at line 333 of file IRGraph.h.

334 {
335 return "SVFIR";
336 }

◆ getMaxStructSize()

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

Definition at line 202 of file IRGraph.h.

203 {
204 return maxStSize;
205 }

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

189{
193
194 APOffset offset = apOffset;
195 if(offset < 0)
196 {
197 writeWrnMsg("try to create a gep node with negative offset.");
198 offset = std::abs(offset);
199 }
200 u32_t maxOffset = baseObj->getMaxFieldOffsetLimit();
201
207 if (maxOffset == 0)
208 offset = 0;
214 else if ((u32_t)offset > maxOffset - 1)
215 {
221 else
225 offset = maxOffset - 1;
226 }
227
228 return offset;
229}
unsigned u32_t
Definition CommandLine.h:18
buffer offset
Definition cJSON.cpp:1113
static const Option< bool > CyclicFldIdx
Definition Options.h:186
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition SVFUtil.cpp:68
s64_t APOffset
Definition GeneralType.h:60

◆ getNodeNumAfterPAGBuild()

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

Definition at line 311 of file IRGraph.h.

312 {
314 }

◆ getNullPtr()

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

Definition at line 257 of file IRGraph.h.

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

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

170{
173 else
175}
u32_t getNumOfFlattenElements() const
Return number of elements after flattening (including array elements)
Definition SVFType.h:137
u32_t getNumOfFlattenFields() const
Return the number of fields after flattening (ignoring array elements)
Definition SVFType.h:143

◆ getObjectNodeNum()

u32_t IRGraph::getObjectNodeNum ( )

Definition at line 337 of file IRGraph.cpp.

338{
339 if (objVarNum != 0) return objVarNum;
340 u32_t num = 0;
341 for (const auto& item: *this)
342 {
343 if (SVFUtil::isa<ObjVar>(item.second))
344 num++;
345 }
346 return objVarNum = num;
347}
cJSON * item
Definition cJSON.h:222

◆ getObjTypeInfo()

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

Definition at line 232 of file IRGraph.h.

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

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

140{
142}
const SVFType * getOriginalElemType(u32_t fldIdx) const
Definition SVFValue.cpp:62

◆ getPAGEdgeNum()

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

Definition at line 324 of file IRGraph.h.

325 {
326 return edgeNum;
327 }

◆ getPAGNodeNum()

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

Definition at line 320 of file IRGraph.h.

321 {
322 return nodeNum;
323 }

◆ getPTAPAGEdgeNum()

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

Definition at line 328 of file IRGraph.h.

329 {
330 return totalPTAPAGEdge;
331 }

◆ getReturnNode()

NodeID IRGraph::getReturnNode ( const FunObjVar func) const

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

Definition at line 60 of file IRGraph.cpp.

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

◆ getStInfos()

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

Definition at line 273 of file IRGraph.h.

274 {
275 return stInfos;
276 }

◆ 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 }

◆ getTotalSymNum()

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

Statistics.

Definition at line 198 of file IRGraph.h.

199 {
200 return totalSymNum;
201 }

◆ getTypeInfo()

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

Get struct info.

Get a reference to StructInfo.

Definition at line 242 of file IRGraph.cpp.

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

◆ getValueNodeNum()

u32_t IRGraph::getValueNodeNum ( )

Definition at line 324 of file IRGraph.cpp.

325{
326 if (valVarNum != 0) return valVarNum;
327 u32_t num = 0;
328 for (const auto& item: *this)
329 {
330 if (SVFUtil::isa<ValVar>(item.second))
331 num++;
332 }
333 return valVarNum = num;
334}

◆ getVarargNode()

NodeID IRGraph::getVarargNode ( const FunObjVar func) const

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

Definition at line 67 of file IRGraph.cpp.

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

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

297{
298 SVFStmt edge(src,dst,SVFStmt::makeEdgeFlagWithCallInst(kind,callInst), false);
299 SVFStmt::SVFStmtSetTy::iterator it = KindToSVFStmtSetMap[kind].find(&edge);
300 if (it != KindToSVFStmtSetMap[kind].end())
301 {
302 return *it;
303 }
304 return nullptr;
305}
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
SVFIR edge map containing all PAGEdges.
Definition IRGraph.h:107
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 282 of file IRGraph.cpp.

283{
285 SVFStmt::SVFStmtSetTy::iterator it = KindToSVFStmtSetMap[kind].find(&edge);
286 if (it != KindToSVFStmtSetMap[kind].end())
287 {
288 return *it;
289 }
290 return nullptr;
291}
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 268 of file IRGraph.cpp.

269{
270 SVFStmt edge(src,dst,kind, false);
271 SVFStmt::SVFStmtSetTy::iterator it = KindToSVFStmtSetMap[kind].find(&edge);
272 if (it != KindToSVFStmtSetMap[kind].end())
273 {
274 return *it;
275 }
276 return nullptr;
277}

◆ hasSVFTypeInfo()

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

Definition at line 284 of file IRGraph.h.

285 {
286 return svfTypes.find(T) != svfTypes.end();
287 }

◆ idToObjTypeInfoMap() [1/2]

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

Get different kinds of syms maps.

Definition at line 210 of file IRGraph.h.

211 {
212 return objTypeInfoMap;
213 }

◆ idToObjTypeInfoMap() [2/2]

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

Definition at line 215 of file IRGraph.h.

216 {
217 return objTypeInfoMap;
218 }

◆ isBlkObj()

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

Definition at line 163 of file IRGraph.h.

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

◆ isBlkObjOrConstantObj()

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

Definition at line 171 of file IRGraph.h.

172 {
173 return (isBlkObj(id) || isConstantSym(id));
174 }
static bool isBlkObj(NodeID id)
Definition IRGraph.h:163
static bool isConstantSym(NodeID id)
Definition IRGraph.h:167

◆ isBlkPtr()

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

special value

Definition at line 155 of file IRGraph.h.

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

◆ isBuiltFromFile()

bool SVF::IRGraph::isBuiltFromFile ( )
inline

Whether this SVFIR built from a txt file.

Definition at line 148 of file IRGraph.h.

149 {
150 return fromFile;
151 }

◆ isConstantSym()

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

Definition at line 167 of file IRGraph.h.

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

◆ isNullPtr()

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

Definition at line 159 of file IRGraph.h.

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

◆ nullPtrSymID()

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

Definition at line 181 of file IRGraph.h.

182 {
183 return NullPtr;
184 }

◆ printFlattenFields()

void IRGraph::printFlattenFields ( const SVFType type)

Debug method.

All rest types are scalar type?

Definition at line 73 of file IRGraph.cpp.

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

◆ retFunObjSyms()

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

Definition at line 220 of file IRGraph.h.

221 {
222 return returnFunObjSymMap;
223 }

◆ setNodeNumAfterPAGBuild()

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

Definition at line 315 of file IRGraph.h.

316 {
318 }

◆ varargFunObjSyms()

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

Definition at line 225 of file IRGraph.h.

226 {
227 return varargFunObjSymMap;
228 }

◆ view()

void IRGraph::view ( )

View graph from the debugger.

View IRGraph

Definition at line 318 of file IRGraph.cpp.

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

Friends And Related Symbol Documentation

◆ SVFIRBuilder

Definition at line 53 of file IRGraph.h.

◆ SymbolTableBuilder

Definition at line 54 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 349 of file IRGraph.h.

◆ maxStSize

u32_t SVF::IRGraph::maxStSize

The number of fields in max_struct.

Definition at line 352 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: