Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVF::PAGBase Class Reference

#include <PAGBase.h>

Inheritance diagram for SVF::PAGBase:
SVF::GenericGraph< SVFVar, SVFStmt > SVF::PAG

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 *, NodeID > FunObjVarToIDMapTy
 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

 PAGBase (bool buildFromFile)
virtual ~PAGBase ()
bool isBuiltFromFile ()
 Whether this PAG 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
IDToTypeInfoMapTy & idToObjTypeInfoMap ()
 Get different kinds of syms maps.
const IDToTypeInfoMapTy & idToObjTypeInfoMap () const
FunObjVarToIDMapTy & retFunObjSyms ()
FunObjVarToIDMapTy & varargFunObjSyms ()
ObjTypeInfo * getObjTypeInfo (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 SVFTypeSet & getSVFTypes () const
 Constant reader that won't change the state of the symbol table.
const SVFType * getSVFType (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 StInfo * getTypeInfo (const SVFType *T) const
 Get struct info.
bool hasSVFTypeInfo (const SVFType *T)
ObjTypeInfo * createObjTypeInfo (const SVFType *type)
 Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object).
const ObjTypeInfo * createDummyObjTypeInfo (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 SVFType * getFlatternedElemType (const SVFType *baseType, u32_t flatten_idx)
 Return the type of a flattened element given a flattened index.
const SVFType * getOriginalElemType (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 PAG.
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.
iterator end ()
void addGNode (NodeID id, NodeType *node)
 Add a Node.
NodeType * getGNode (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 isNullOrBlkObj (NodeID id)
 Check a decoded NodeID, not an AE virtual memory address.
static bool isConstantSym (NodeID id)
static bool isBlkObjOrConstantObj (NodeID id)

Public Attributes

const SVFType * maxStruct
 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.
SVFStmt * hasNonlabeledEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
SVFStmt * hasLabeledEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind, const ICFGNode *cs)
SVFStmt * hasEdge (SVFStmt *edge, SVFStmt::PEDGEK kind)
SVFStmt * hasLabeledEdge (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
 PAG edge map containing all PAGEdges.
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
 PAG edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
bool fromFile
 Whether the PAG is built according to user specified data from a txt file.
NodeID nodeNumAfterPAGBuild
 initial node number after building PAG, 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 PAGBuilder
class SymbolTableBuilder
class GraphDBClient

Detailed Description

Definition at line 49 of file PAGBase.h.

Member Typedef Documentation

◆ FunObjVarToIDMapTy

function to sym id map

Definition at line 76 of file PAGBase.h.

◆ IDToTypeInfoMapTy

various maps defined

sym id to obj type info map

Definition at line 73 of file PAGBase.h.

◆ SVFStmtSet

Definition at line 103 of file PAGBase.h.

◆ SVFTypeSet

struct type to struct info map

Definition at line 79 of file PAGBase.h.

Member Enumeration Documentation

◆ SYMTYPE

Symbol types.

Enumerator
NullPtr 
BlkPtr 
BlackHole 
ConstantObj 
ValSymbol 
ObjSymbol 
RetSymbol 
VarargSymbol 

Definition at line 58 of file PAGBase.h.

59 {
60 NullPtr,
61 BlkPtr,
68 };

Constructor & Destructor Documentation

◆ PAGBase()

SVF::PAGBase::PAGBase ( bool buildFromFile)
inline

Definition at line 138 of file PAGBase.h.

139 : totalSymNum(0), fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0), valVarNum(0), objVarNum(0),
140 maxStruct(nullptr), maxStSize(0)
141 {
142 }
u32_t objVarNum
Definition PAGBase.h:112
const SVFType * maxStruct
The struct type with the most fields.
Definition PAGBase.h:362
u32_t maxStSize
The number of fields in max_struct.
Definition PAGBase.h:365
bool fromFile
Whether the PAG is built according to user specified data from a txt file.
Definition PAGBase.h:108
u32_t valVarNum
Definition PAGBase.h:111
NodeID nodeNumAfterPAGBuild
initial node number after building PAG, excluding later added nodes, e.g., gepobj nodes
Definition PAGBase.h:109
u32_t totalPTAPAGEdge
Definition PAGBase.h:110
NodeID totalSymNum
total number of symbols
Definition PAGBase.h:98

◆ ~PAGBase()

PAGBase::~PAGBase ( )
virtual

Definition at line 58 of file IRGraph.cpp.

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

Member Function Documentation

◆ addEdge()

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

Add an edge into the graph.

Add a PAG edge into edge map

Definition at line 270 of file IRGraph.cpp.

271{
272
274 outs() << "add edge from " << src->getId() << " kind :"
275 << src->getNodeKind() << " to " << dst->getId()
276 << " kind :" << dst->getNodeKind() << "\n");
277 src->addOutEdge(edge);
278 dst->addInEdge(edge);
279 return true;
280}
#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:58

◆ addNode()

NodeID SVF::PAGBase::addNode ( SVFVar * node)
inlineprotected

Add a node into the graph.

Definition at line 115 of file PAGBase.h.

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

◆ addStInfo()

void SVF::PAGBase::addStInfo ( StInfo * stInfo)
inline

Definition at line 374 of file PAGBase.h.

375 {
376 stInfo->setStinfoId(stInfos.size());
377 stInfos.insert(stInfo);
378 }
Set< const StInfo * > stInfos
(owned) All StInfo
Definition PAGBase.h:95

◆ addTypeInfo()

void SVF::PAGBase::addTypeInfo ( const SVFType * ty)
inline

Definition at line 367 of file PAGBase.h.

368 {
369 bool inserted = svfTypes.insert(ty).second;
370 if(!inserted)
371 assert(false && "this type info has been added before");
372 }
SVFTypeSet svfTypes
Definition PAGBase.h:92

◆ blackholeSymID()

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

Definition at line 196 of file PAGBase.h.

197 {
198 return BlackHole;
199 }

◆ blkPtrSymID()

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

Definition at line 181 of file PAGBase.h.

182 {
183 return BlkPtr;
184 }

◆ constantSymID()

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

Definition at line 191 of file PAGBase.h.

192 {
193 return ConstantObj;
194 }

◆ createDummyObjTypeInfo()

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

Definition at line 194 of file IRGraph.cpp.

195{
196 if (objTypeInfoMap.find(symId)==objTypeInfoMap.end())
197 {
198 ObjTypeInfo* ti = createObjTypeInfo(type);
199 objTypeInfoMap[symId] = ti;
200 }
201 ObjTypeInfo* ti = objTypeInfoMap[symId];
202 return ti;
203}
newitem type
Definition cJSON.cpp:2739
IDToTypeInfoMapTy objTypeInfoMap
map a memory sym id to its obj
Definition PAGBase.h:85
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:248

◆ createObjTypeInfo()

ObjTypeInfo * PAGBase::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 248 of file IRGraph.cpp.

249{
250
251 ObjTypeInfo* typeInfo = new ObjTypeInfo(type, Options::MaxFieldLimit());
252 if(type && type->isPointerTy())
253 {
255 }
256 return typeInfo;
257}
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 PAGBase::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)
50 delete type;
51 svfTypes.clear();
52
53 for (const StInfo* st : stInfos)
54 delete st;
55 stInfos.clear();
56}

◆ dump()

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

Dump PAG.

Dump this PAGBase

Definition at line 333 of file IRGraph.cpp.

334{
336}
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::PAGBase::dumpSymTable ( )

◆ getBlackHoleNode()

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

Definition at line 250 of file PAGBase.h.

251 {
252 return blackholeSymID();
253 }
NodeID blackholeSymID() const
Definition PAGBase.h:196

◆ getBlkPtr()

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

Definition at line 258 of file PAGBase.h.

259 {
260 return blkPtrSymID();
261 }
NodeID blkPtrSymID() const
Definition PAGBase.h:181

◆ getConstantNode()

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

Definition at line 254 of file PAGBase.h.

255 {
256 return constantSymID();
257 }
NodeID constantSymID() const
Definition PAGBase.h:191

◆ getFlattenedElemIdx()

u32_t PAGBase::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 {
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 }
165 {
167 return 0;
168 }
169 else
170 {
171 // Under LLVM's opaque pointers, the SVFType resolved for a GEP base can fold to
172 // something other than a struct/array SVFType even though the corresponding LLVM
173 // aggregate genuinely is a StructType/ArrayType (seen integrating SVF against an
174 // LLVM 21 -O0 build). Report the concrete type so a future hit of this branch is
175 // diagnosable rather than guessed at, then fall back to element 0 instead of
176 // crashing (the printed type survives into release builds even when the assert
177 // below is compiled out).
178 SVFUtil::errs() << "getFlattenedElemIdx: type is neither struct nor array: "
179 << T->toString() << "\n";
180 assert(false && "getFlattenedElemIdx: type is neither struct nor array (see printed type above)");
181 return 0;
182 }
183 }
184}
static Option< bool > ModelArrays
Definition Options.h:180
const StInfo * getTypeInfo(const SVFType *T) const
Get struct info.
Definition IRGraph.cpp:259
std::string toString() const
Definition SVFType.cpp:10
std::vector< u32_t > & getFlattenedElemIdxVec()
Definition SVFType.h:123
std::vector< u32_t > & getFlattenedFieldIdxVec()
Definition SVFType.h:119
LLVM_NODISCARD bool isa(const Y &Val)
Definition Casting.h:241
std::ostream & errs()
Overwrite llvm::errs().
Definition SVFUtil.h:64

◆ getFlattenFieldTypes()

const std::vector< const SVFType * > & PAGBase::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 * PAGBase::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::PAGBase::getGraphName ( ) const
inline

Return graph name.

Definition at line 346 of file PAGBase.h.

347 {
348 return "PAG";
349 }

◆ getMaxStructSize()

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

Definition at line 207 of file PAGBase.h.

208 {
209 return maxStSize;
210 }

◆ getModulusOffset()

APOffset PAGBase::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 205 of file IRGraph.cpp.

206{
210
211 APOffset offset = apOffset;
212 if(offset < 0)
213 {
214 writeWrnMsg("try to create a gep node with negative offset.");
215 offset = std::abs(offset);
216 }
217 u32_t maxOffset = baseObj->getMaxFieldOffsetLimit();
218
224 if (maxOffset == 0)
225 offset = 0;
226 else if (Options::MaxFieldLimit() < maxOffset)
230 offset = offset % maxOffset;
231 else if ((u32_t)offset > maxOffset - 1)
232 {
237 offset = offset % maxOffset;
238 else
242 offset = maxOffset - 1;
243 }
244
245 return offset;
246}
buffer offset
Definition cJSON.cpp:1113
u32_t getMaxFieldOffsetLimit() const
Get max field offset limit.
static const Option< bool > CyclicFldIdx
Definition Options.h:181
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition SVFUtil.cpp:88
s64_t APOffset
Definition GeneralType.h:80
unsigned u32_t
Definition GeneralType.h:67

◆ getNodeNumAfterPAGBuild()

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

Definition at line 324 of file PAGBase.h.

325 {
327 }

◆ getNullPtr()

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

Definition at line 262 of file PAGBase.h.

263 {
264 return nullPtrSymID();
265 }
NodeID nullPtrSymID() const
Definition PAGBase.h:186

◆ getNumOfFlattenElements()

u32_t PAGBase::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 186 of file IRGraph.cpp.

187{
190 else
192}
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 PAGBase::getObjectNodeNum ( )

Definition at line 360 of file IRGraph.cpp.

361{
362 if (objVarNum != 0) return objVarNum;
363 u32_t num = 0;
364 for (const auto& item: *this)
365 {
366 if (SVFUtil::isa<ObjVar>(item.second))
367 num++;
368 }
369 return objVarNum = num;
370}
cJSON * item
Definition cJSON.h:222

◆ getObjTypeInfo()

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

Definition at line 237 of file PAGBase.h.

238 {
239 IDToTypeInfoMapTy::const_iterator iter = objTypeInfoMap.find(id);
240 assert(iter!=objTypeInfoMap.end() && "obj type info not found");
241 return iter->second;
242 }

◆ getOriginalElemType()

const SVFType * PAGBase::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{
145 return getTypeInfo(baseType)->getOriginalElemType(origId);
146}
const SVFType * getOriginalElemType(u32_t fldIdx) const
Definition SVFValue.cpp:69

◆ getPTAPAGEdgeNum()

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

Definition at line 341 of file PAGBase.h.

342 {
343 return totalPTAPAGEdge;
344 }

◆ getReturnNode()

NodeID PAGBase::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 PAGBase.h:83

◆ getStInfos()

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

Definition at line 286 of file PAGBase.h.

287 {
288 return stInfos;
289 }

◆ getSVFStmtNum()

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

Definition at line 337 of file PAGBase.h.

338 {
339 return edgeNum;
340 }

◆ getSVFType()

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

Definition at line 277 of file PAGBase.h.

278 {
279 for(const SVFType* type : svfTypes)
280 {
281 if(type->getId() == id)
282 return type;
283 }
284 return nullptr;
285 }

◆ getSVFTypes()

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

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

Definition at line 272 of file PAGBase.h.

273 {
274 return svfTypes;
275 }

◆ getSVFVarNum()

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

Definition at line 333 of file PAGBase.h.

334 {
335 return nodeNum;
336 }

◆ getTotalSymNum()

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

Statistics.

Definition at line 203 of file PAGBase.h.

204 {
205 return totalSymNum;
206 }

◆ getTypeInfo()

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

Get struct info.

Get a reference to StructInfo.

Definition at line 259 of file IRGraph.cpp.

260{
261 assert(T);
262 SVFTypeSet::const_iterator it = svfTypes.find(T);
263 assert(it != svfTypes.end() && "type info not found? collect them first during PAG Building");
264 return (*it)->getTypeInfo();
265}

◆ getValueNodeNum()

u32_t PAGBase::getValueNodeNum ( )

Definition at line 347 of file IRGraph.cpp.

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

◆ getVarargNode()

NodeID PAGBase::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 PAGBase.h:84

◆ hasEdge()

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

Definition at line 319 of file IRGraph.cpp.

320{
321 SVFStmt::SVFStmtSetTy::iterator it = KindToSVFStmtSetMap[kind].find(edge);
322 if (it != KindToSVFStmtSetMap[kind].end())
323 {
324 return *it;
325 }
326 return nullptr;
327}
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
PAG edge map containing all PAGEdges.
Definition PAGBase.h:106

◆ hasLabeledEdge() [1/2]

SVFStmt * PAGBase::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 308 of file IRGraph.cpp.

309{
310 SVFStmt edge(src,dst,SVFStmt::makeEdgeFlagWithCallInst(kind,callInst), false);
311 SVFStmt::SVFStmtSetTy::iterator it = KindToSVFStmtSetMap[kind].find(&edge);
312 if (it != KindToSVFStmtSetMap[kind].end())
313 {
314 return *it;
315 }
316 return nullptr;
317}
static GEdgeFlag makeEdgeFlagWithCallInst(GEdgeKind k, const ICFGNode *cs)

◆ hasLabeledEdge() [2/2]

SVFStmt * PAGBase::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 294 of file IRGraph.cpp.

295{
296 SVFStmt edge(src,op1,SVFStmt::makeEdgeFlagWithAddionalOpnd(kind,op2), false);
297 SVFStmt::SVFStmtSetTy::iterator it = KindToSVFStmtSetMap[kind].find(&edge);
298 if (it != KindToSVFStmtSetMap[kind].end())
299 {
300 return *it;
301 }
302 return nullptr;
303}
static GEdgeFlag makeEdgeFlagWithAddionalOpnd(GEdgeKind k, const SVFVar *var)

◆ hasNonlabeledEdge()

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

Return true if it is an intra-procedural edge

Definition at line 285 of file IRGraph.cpp.

286{
287 SVFStmt edge(src,dst,kind, false);
288 return hasEdge(&edge, kind);
289}
SVFStmt * hasEdge(SVFStmt *edge, SVFStmt::PEDGEK kind)
Definition IRGraph.cpp:319

◆ hasSVFTypeInfo()

bool SVF::PAGBase::hasSVFTypeInfo ( const SVFType * T)
inline

Definition at line 297 of file PAGBase.h.

298 {
299 return svfTypes.find(T) != svfTypes.end();
300 }

◆ idToObjTypeInfoMap() [1/2]

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

Get different kinds of syms maps.

Definition at line 215 of file PAGBase.h.

216 {
217 return objTypeInfoMap;
218 }

◆ idToObjTypeInfoMap() [2/2]

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

Definition at line 220 of file PAGBase.h.

221 {
222 return objTypeInfoMap;
223 }

◆ isBlkObj()

bool SVF::PAGBase::isBlkObj ( NodeID id)
inlinestatic

Definition at line 163 of file PAGBase.h.

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

◆ isBlkObjOrConstantObj()

bool SVF::PAGBase::isBlkObjOrConstantObj ( NodeID id)
inlinestatic

Definition at line 176 of file PAGBase.h.

177 {
178 return (isBlkObj(id) || isConstantSym(id));
179 }
static bool isConstantSym(NodeID id)
Definition PAGBase.h:172
static bool isBlkObj(NodeID id)
Definition PAGBase.h:163

◆ isBlkPtr()

bool SVF::PAGBase::isBlkPtr ( NodeID id)
inlinestatic

special value

Definition at line 155 of file PAGBase.h.

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

◆ isBuiltFromFile()

bool SVF::PAGBase::isBuiltFromFile ( )
inline

Whether this PAG built from a txt file.

Definition at line 148 of file PAGBase.h.

149 {
150 return fromFile;
151 }

◆ isConstantSym()

bool SVF::PAGBase::isConstantSym ( NodeID id)
inlinestatic

Definition at line 172 of file PAGBase.h.

173 {
174 return (id == ConstantObj);
175 }

◆ isNullOrBlkObj()

bool SVF::PAGBase::isNullOrBlkObj ( NodeID id)
inlinestatic

Check a decoded NodeID, not an AE virtual memory address.

Definition at line 168 of file PAGBase.h.

169 {
170 return isNullPtr(id) || isBlkObj(id);
171 }
static bool isNullPtr(NodeID id)
Definition PAGBase.h:159

◆ isNullPtr()

bool SVF::PAGBase::isNullPtr ( NodeID id)
inlinestatic

Definition at line 159 of file PAGBase.h.

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

◆ nullPtrSymID()

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

Definition at line 186 of file PAGBase.h.

187 {
188 return NullPtr;
189 }

◆ printFlattenFields()

void PAGBase::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 =
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:186
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
Definition Casting.h:405

◆ retFunObjSyms()

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

Definition at line 225 of file PAGBase.h.

226 {
227 return returnFunObjSymMap;
228 }

◆ setNodeNumAfterPAGBuild()

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

Definition at line 328 of file PAGBase.h.

329 {
331 }

◆ varargFunObjSyms()

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

Definition at line 230 of file PAGBase.h.

231 {
232 return varargFunObjSymMap;
233 }

◆ view()

void PAGBase::view ( )

View graph from the debugger.

View PAGBase

Definition at line 341 of file IRGraph.cpp.

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

◆ GraphDBClient

friend class GraphDBClient
friend

Definition at line 53 of file PAGBase.h.

◆ PAGBuilder

friend class PAGBuilder
friend

Definition at line 51 of file PAGBase.h.

◆ SymbolTableBuilder

friend class SymbolTableBuilder
friend

Definition at line 52 of file PAGBase.h.

Member Data Documentation

◆ fromFile

bool SVF::PAGBase::fromFile
protected

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

Definition at line 108 of file PAGBase.h.

◆ KindToPTASVFStmtSetMap

SVFStmt::KindToSVFStmtMapTy SVF::PAGBase::KindToPTASVFStmtSetMap
protected

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

Definition at line 107 of file PAGBase.h.

◆ KindToSVFStmtSetMap

SVFStmt::KindToSVFStmtMapTy SVF::PAGBase::KindToSVFStmtSetMap
protected

PAG edge map containing all PAGEdges.

Definition at line 106 of file PAGBase.h.

◆ maxStruct

const SVFType* SVF::PAGBase::maxStruct

The struct type with the most fields.

Definition at line 362 of file PAGBase.h.

◆ maxStSize

u32_t SVF::PAGBase::maxStSize

The number of fields in max_struct.

Definition at line 365 of file PAGBase.h.

◆ nodeNumAfterPAGBuild

NodeID SVF::PAGBase::nodeNumAfterPAGBuild
protected

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

Definition at line 109 of file PAGBase.h.

◆ objTypeInfoMap

IDToTypeInfoMapTy SVF::PAGBase::objTypeInfoMap
private

map a memory sym id to its obj

Definition at line 85 of file PAGBase.h.

◆ objVarNum

u32_t SVF::PAGBase::objVarNum
protected

Definition at line 112 of file PAGBase.h.

◆ returnFunObjSymMap

FunObjVarToIDMapTy SVF::PAGBase::returnFunObjSymMap
private

return map

Definition at line 83 of file PAGBase.h.

◆ stInfos

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

(owned) All StInfo

Definition at line 95 of file PAGBase.h.

◆ svfTypes

SVFTypeSet SVF::PAGBase::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 92 of file PAGBase.h.

◆ totalPTAPAGEdge

u32_t SVF::PAGBase::totalPTAPAGEdge
protected

Definition at line 110 of file PAGBase.h.

◆ totalSymNum

NodeID SVF::PAGBase::totalSymNum
private

total number of symbols

Definition at line 98 of file PAGBase.h.

◆ valVarNum

u32_t SVF::PAGBase::valVarNum
protected

Definition at line 111 of file PAGBase.h.

◆ varargFunObjSymMap

FunObjVarToIDMapTy SVF::PAGBase::varargFunObjSymMap
private

vararg map

Definition at line 84 of file PAGBase.h.


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