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

#include <PAG.h>

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

Public Types

typedef Set< const CallICFGNode * > CallSiteSet
typedef OrderedMap< const CallICFGNode *, NodeID > CallSiteToFunPtrMap
typedef Map< NodeID, CallSiteSet > FunPtrToCallSitesMap
typedef Map< NodeID, NodeBS > MemObjToFieldsMap
typedef std::vector< const SVFStmt * > SVFStmtList
typedef std::vector< const ValVar * > ValVarList
typedef Map< const SVFVar *, PhiStmt * > PHINodeMap
typedef Map< const SVFVar *, CallPE * > FParmToCallPEMap
typedef Map< const FunObjVar *, ValVarList > FunToArgsListMap
typedef Map< const CallICFGNode *, ValVarList > CSToArgsListMap
typedef Map< const RetICFGNode *, const ValVar * > CSToRetMap
typedef Map< const FunObjVar *, const ValVar * > FunToRetMap
typedef Map< const FunObjVar *, SVFStmtSet > FunToPAGEdgeSetMap
typedef Map< const ICFGNode *, SVFStmtList > ICFGNode2SVFStmtsMap
typedef Map< NodeID, NodeID > NodeToNodeMap
typedef std::pair< NodeID, APOffset > GepOffset
typedef std::pair< NodeID, AccessPath > NodeAccessPath
typedef Map< GepOffset, NodeID > OffsetToGepVarMap
typedef Map< NodeAccessPath, NodeID > NodeAccessPathMap
typedef Map< NodeID, NodeAccessPathMap > GepValueVarMap
typedef std::pair< const SVFType *, std::vector< AccessPath > > SVFTypeLocSetsPair
typedef Map< NodeID, SVFTypeLocSetsPair > TypeLocSetsMap
typedef Map< NodePair, NodeID > NodePairSetMap
Public Types inherited from SVF::PAGBase
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

const SVFVar * getSVFVar (NodeID id) const
 ObjVar/GepObjVar/BaseObjVar.
const ValVar * getValVar (NodeID id) const
const ObjVar * getObjVar (NodeID id) const
const BaseObjVar * getBaseObjVar (NodeID id) const
const GepObjVar * getGepObjVar (NodeID id) const
bool isObjVar (NodeID id) const
bool isBaseObjVar (NodeID id) const
bool isGepObjVar (NodeID id) const
const IDToNodeMapTy & getSVFVarMap () const
 Return the entire SVFID to SVFVar map.
MemObjToFieldsMap & getMemToFieldsMap ()
 Return memToFieldsMap.
OffsetToGepVarMap & getGepObjNodeMap ()
 Return GepObjVarMap.
OrderedNodeSet & getAllValidPtrs ()
 Return valid pointers.
void initialiseCandidatePointers ()
 Initialize candidate pointers.
virtual ~PAG ()
 Destructor.
void setICFG (ICFG *i)
 Set/Get ICFG.
ICFG * getICFG () const
void setCHG (CommonCHGraph *c)
 Set/Get CHG.
CommonCHGraph * getCHG ()
const CallGraph * getCallGraph ()
 Get CG.
void setCallGraph (CallGraph *cg)
const FunObjVar * getFunObjVar (const std::string &name)
const std::string & getModuleIdentifier () const
void setModuleIdentifier (const std::string &moduleIdentifier)
SVFStmt::SVFStmtSetTy & getSVFStmtSet (SVFStmt::PEDGEK kind)
 Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
SVFStmt::SVFStmtSetTy & getPTASVFStmtSet (SVFStmt::PEDGEK kind)
 Get PTA edges set according to its kind.
bool hasSVFStmtList (const ICFGNode *inst) const
 Whether this instruction has PAG Edge.
bool hasPTASVFStmtList (const ICFGNode *inst) const
SVFStmtList & getSVFStmtList (const ICFGNode *inst)
 Given an instruction, get all its PAGEdges.
SVFStmtList & getPTASVFStmtList (const ICFGNode *inst)
 Given an instruction, get all its PTA PAGEdges.
void addToSVFStmtList (ICFGNode *inst, SVFStmt *edge)
 Add a SVFStmt into instruction map.
void addToTypeLocSetsMap (NodeID argId, SVFTypeLocSetsPair &locSets)
 Add a base SVFType* and all its field location sets to an arg NodeId.
SVFTypeLocSetsPair & getTypeLocSetsMap (NodeID argId)
 Given an arg NodeId, get its base SVFType* and all its field location sets.
SVFStmtSet & getGlobalSVFStmtSet ()
 Get global PAGEdges (not in a procedure).
const CallSiteSet & getCallSiteSet () const
 Get all callsites.
bool isPhiNode (const SVFVar *node) const
 Whether this SVFVar is a result operand a of phi node.
CallPE * getCallPEForFormalParm (const SVFVar *param) const
 Get the CallPE for a formal parameter (phi-like, nullptr if not found).
bool hasFunArgsList (const FunObjVar *func) const
 Function has arguments list.
FunToArgsListMap & getFunArgsMap ()
 Get function arguments list.
const ValVarList & getFunArgsList (const FunObjVar *func) const
 Get function arguments list.
bool hasCallSiteArgsMap (const CallICFGNode *cs) const
 Callsite has argument list.
CSToArgsListMap & getCallSiteArgsMap ()
 Get callsite argument list.
const ValVarList & getCallSiteArgsList (const CallICFGNode *cs) const
 Get callsite argument list.
CSToRetMap & getCallSiteRets ()
 Get callsite return.
const ValVar * getCallSiteRet (const RetICFGNode *cs) const
 Get callsite return.
bool callsiteHasRet (const RetICFGNode *cs) const
FunToRetMap & getFunRets ()
 Get function return list.
const ValVar * getFunRet (const FunObjVar *func) const
 Get function return list.
bool funHasRet (const FunObjVar *func) const
u32_t getFieldValNodeNum () const
 Node and edge statistics.
u32_t getFieldObjNodeNum () const
NodeID getGepValVar (NodeID curInst, NodeID base, const AccessPath &ap) const
 Due to constraint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar.
const CallSiteToFunPtrMap & getIndirectCallsites () const
 Add/get indirect callsites.
NodeID getFunPtr (const CallICFGNode *cs) const
const CallSiteSet & getIndCallSites (NodeID funPtr) const
bool isIndirectCallSites (const CallICFGNode *cs) const
bool isFunPtr (NodeID id) const
SVFStmt * getIntraPAGEdge (NodeID src, NodeID dst, SVFStmt::PEDGEK kind)
 Get an edge according to src, dst and kind.
SVFStmt * getIntraPAGEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
const BaseObjVar * getBaseObject (NodeID id) const
const ValVar * getBaseValVar (NodeID id) const
NodeID getGepObjVar (const BaseObjVar *baseObj, const APOffset &ap)
 Get a field PAG Object node according to base mem obj and offset.
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 Get a field obj PAG node according to a mem obj and a given offset.
NodeID getFIObjVar (const BaseObjVar *obj) const
 Get a field-insensitive obj PAG node according to a mem obj.
NodeID getFIObjVar (NodeID id) const
bool isBlkObjOrConstantObj (NodeID id) const
 Get black hole and constant id.
bool isConstantObj (NodeID id) const
NodeID getBaseObjVarID (NodeID id) const
 Base and Offset methods for Value and Object node.
NodeBS & getAllFieldsObjVars (const BaseObjVar *obj)
 Get all fields of an object.
NodeBS & getAllFieldsObjVars (NodeID id)
NodeBS getFieldsAfterCollapse (NodeID id)
NodeID addDummyValNode ()
NodeID addDummyObjNode (const SVFType *type)
bool isValidPointer (NodeID nodeId) const
 Whether a node is a valid pointer.
bool isValidTopLevelPtr (const SVFVar *node)
void print ()
 Print PAG.
Public Member Functions inherited from SVF::PAGBase
 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 PAG * getPAG (bool buildFromFile=false)
 Singleton design here to make sure we only have one instance during any analysis.
static void releasePAG ()
static void handleBlackHole (bool b)
 PAG build configurations.
static std::string pagFileName ()
static bool pagReadFromTXT ()
static void setPagFromTXT (const std::string &txt)
Static Public Member Functions inherited from SVF::PAGBase
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)

Protected Member Functions

NodeID addBaseObjNode (BaseObjVar *node)
NodeID addDummyObjNode (DummyObjVar *node)
NodeID addGepObjNode (GepObjVar *gepObj, NodeID base, const APOffset &apOffset)
void addGepValObjFromDB (NodeID curInstID, const GepValVar *gepValvar)
Protected Member Functions inherited from SVF::PAGBase
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.

Private Member Functions

 PAG (bool buildFromFile)
 Constructor.
void destroy ()
 Clean up memory.
void addToStmt2TypeMap (SVFStmt *edge)
 Map a SVFStatement type to a set of corresponding SVF statements.
void addFunArgs (const FunObjVar *fun, const ValVar *arg)
 Get/set method for function/callsite arguments and returns.
void addFunArgs (FunEntryICFGNode *funEntryBlockNode, const FunObjVar *fun, const ValVar *arg)
void addFunRet (const FunObjVar *fun, const ValVar *ret)
 Add function returns.
void addFunRet (FunExitICFGNode *funExitBlockNode, const FunObjVar *fun, const ValVar *ret)
void addCallSiteArgs (CallICFGNode *callBlockNode, const ValVar *arg)
 Add callsite arguments.
void addCallSiteRets (RetICFGNode *retBlockNode, const ValVar *arg)
 Add callsite returns.
void addIndirectCallsites (const CallICFGNode *cs, NodeID funPtr)
 Add indirect callsites.
NodeID addValNode (NodeID i, const SVFType *type, const ICFGNode *icfgNode)
 add node into PAG
NodeID addFunValNode (NodeID i, const ICFGNode *icfgNode, const FunObjVar *funObjVar, const SVFType *type)
NodeID addArgValNode (NodeID i, u32_t argNo, const ICFGNode *icfgNode, const FunObjVar *callGraphNode, const SVFType *type)
NodeID addConstantFPValNode (const NodeID i, double dval, const ICFGNode *icfgNode, const SVFType *type)
NodeID addConstantIntValNode (NodeID i, const std::pair< s64_t, u64_t > &intValue, const ICFGNode *icfgNode, const SVFType *type)
NodeID addConstantNullPtrValNode (const NodeID i, const ICFGNode *icfgNode, const SVFType *type)
NodeID addGlobalValNode (const NodeID i, const ICFGNode *icfgNode, const SVFType *svfType)
NodeID addConstantDataValNode (const NodeID i, const ICFGNode *icfgNode, const SVFType *type)
NodeID addObjNode (NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
 Add a memory obj node.
NodeID addHeapObjNode (NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
NodeID addStackObjNode (NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
NodeID addFunObjNode (NodeID id, ObjTypeInfo *ti, const ICFGNode *node)
NodeID addConstantFPObjNode (NodeID i, ObjTypeInfo *ti, double dval, const ICFGNode *node)
NodeID addConstantIntObjNode (NodeID i, ObjTypeInfo *ti, const std::pair< s64_t, u64_t > &intValue, const ICFGNode *node)
NodeID addConstantNullPtrObjNode (const NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
NodeID addGlobalObjNode (const NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
NodeID addConstantDataObjNode (const NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
NodeID addRetNode (NodeID i, const FunObjVar *callGraphNode, const SVFType *type, const ICFGNode *icn)
 Add a unique return node for a procedure.
NodeID addVarargNode (NodeID i, const FunObjVar *val, const SVFType *type, const ICFGNode *n)
 Add a unique vararg node for a procedure.
NodeID addGepValNode (NodeID curInst, const ValVar *base, const AccessPath &ap, NodeID i, const SVFType *type, const ICFGNode *node)
 Add a temp field value node, this method can only invoked by getGepValVar.
NodeID addGepObjNode (const BaseObjVar *baseObj, const APOffset &apOffset, const NodeID gepId)
 Add a field obj node, this method can only invoked by getGepObjVar.
NodeID addFIObjNode (NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
 Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
NodeID addDummyValNode (NodeID i, const ICFGNode *node)
 Add a dummy value/object node according to node ID (llvm value is null).
NodeID addDummyObjNode (NodeID i, const SVFType *type)
NodeID addBlackholeObjNode ()
NodeID addConstantObjNode ()
NodeID addBlackholePtrNode ()
NodeID addIntrinsicValNode (NodeID i, const SVFType *type)
NodeID addAsmPCValNode (NodeID i, const SVFType *type)
NodeID addValNode (ValVar *node)
 Add a value (pointer) node.
NodeID addObjNode (ObjVar *node)
 Add a memory obj node.
NodeID addRetNode (const FunObjVar *, SVFVar *node)
 Add a unique return node for a procedure.
NodeID addVarargNode (const FunObjVar *, SVFVar *node)
 Add a unique vararg node for a procedure.
void addGlobalPAGEdge (const SVFStmt *edge)
 Add global PAGEdges (not in a procedure).
void addCallSite (const CallICFGNode *call)
 Add callsites.
AddrStmt * addAddrStmt (NodeID src, NodeID dst)
 Add an edge into PAG.
void addAddrStmt (AddrStmt *edge)
CopyStmt * addCopyStmt (NodeID src, NodeID dst, CopyStmt::CopyKind type)
 Add Copy edge.
void addCopyStmt (CopyStmt *edge)
PhiStmt * addPhiStmt (NodeID res, NodeID opnd, const ICFGNode *pred)
 Add phi node information.
void addPhiStmt (PhiStmt *edge, SVFVar *src, SVFVar *dst)
SelectStmt * addSelectStmt (NodeID res, NodeID op1, NodeID op2, NodeID cond)
 Add SelectStmt.
void addSelectStmt (SelectStmt *edge, SVFVar *src, SVFVar *dst)
CmpStmt * addCmpStmt (NodeID op1, NodeID op2, NodeID dst, u32_t predict)
 Add Copy edge.
void addCmpStmt (CmpStmt *edge, SVFVar *src, SVFVar *dst)
BinaryOPStmt * addBinaryOPStmt (NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
 Add Copy edge.
void addBinaryOPStmt (BinaryOPStmt *edge, SVFVar *src, SVFVar *dst)
UnaryOPStmt * addUnaryOPStmt (NodeID src, NodeID dst, u32_t opcode)
 Add Unary edge.
void addUnaryOPStmt (UnaryOPStmt *edge, SVFVar *src, SVFVar *dst)
BranchStmt * addBranchStmt (NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
 Add BranchStmt.
void addBranchStmt (BranchStmt *edge, SVFVar *src, SVFVar *dst)
LoadStmt * addLoadStmt (NodeID src, NodeID dst)
 Add Load edge.
void addLoadStmt (LoadStmt *edge)
StoreStmt * addStoreStmt (NodeID src, NodeID dst, const ICFGNode *val)
 Add Store edge.
void addStoreStmt (StoreStmt *edge, SVFVar *src, SVFVar *dst)
CallPE * addCallPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
 Add Call edge (phi-like: merges actual params from all call sites into formal param).
void addCallPE (CallPE *edge, SVFVar *src, SVFVar *dst)
RetPE * addRetPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
 Add Return edge.
void addRetPE (RetPE *edge, SVFVar *src, SVFVar *dst)
GepStmt * addGepStmt (NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
 Add Gep edge.
void addGepStmt (GepStmt *edge)
GepStmt * addNormalGepStmt (NodeID src, NodeID dst, const AccessPath &ap)
 Add Offset(Gep) edge.
GepStmt * addVariantGepStmt (NodeID src, NodeID dst, const AccessPath &ap)
 Add Variant(Gep) edge.
TDForkPE * addThreadForkPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
 Add Thread fork edge for parameter passing.
TDJoinPE * addThreadJoinPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
 Add Thread join edge for parameter passing.
SVFStmt * addBlackHoleAddrStmt (NodeID node)
 Set a pointer points-to black hole (e.g. int2ptr).

Private Attributes

ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap
 Map an ICFGNode to its SVFStmts.
ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap
 Map an ICFGNode to its PointerAnalysis related SVFStmts.
GepValueVarMap GepValObjMap
 Map a pair<base,off> to a gep value node id.
TypeLocSetsMap typeLocSetsMap
 Map an arg to its base SVFType* and all its field location sets.
OffsetToGepVarMap GepObjVarMap
 Map a pair<base,off> to a gep obj node id.
MemObjToFieldsMap memToFieldsMap
 Map a mem object id to all its fields.
NodeSet constantObjs
 Constant objects and their fields, recorded when each object node is added.
SVFStmtSet globSVFStmtSet
 Global PAGEdges without control flow information.
PHINodeMap phiNodeMap
 A set of phi copy edges.
FParmToCallPEMap fParmToCallPEMap
 Map a formal param to its CallPE.
FunToArgsListMap funArgsListMap
 Map a function to a list of all its formal parameters.
CSToArgsListMap callSiteArgsListMap
 Map a callsite to a list of all its actual parameters.
CSToRetMap callSiteRetMap
 Map a callsite to its callsite returns PAGNodes.
FunToRetMap funRetMap
 Map a function to its unique function return PAGNodes.
CallSiteToFunPtrMap indCallSiteToFunPtrMap
 Map an indirect callsite to its function pointer.
FunPtrToCallSitesMap funPtrToCallSitesMap
OrderedNodeSet candidatePointers
ICFG * icfg
CommonCHGraph * chgraph
CallSiteSet callSiteSet
CallGraph * callGraph
 all the callsites of a program
std::string moduleIdentifier

Static Private Attributes

static std::unique_ptr< PAG > pag
 Callgraph with direct calls only; no change allowed after init and use callgraph in PointerAnalysis for indirect calls).
static std::string pagReadFromTxt = ""

Friends

class PAGBuilder
class ExternalPAG
class PAGBuilderFromFile
class BVDataPTAImpl
class GraphDBClient
class GraphDBSVFIRBuilder

Additional Inherited Members

Public Attributes inherited from SVF::PAGBase
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 Attributes inherited from SVF::PAGBase
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

Detailed Description

SVF Intermediate representation, representing variables and statements as a Program Assignment Graph (PAG) Variables as nodes and statements as edges.

Definition at line 45 of file PAG.h.

Member Typedef Documentation

◆ CallSiteSet

Definition at line 55 of file PAG.h.

◆ CallSiteToFunPtrMap

Definition at line 56 of file PAG.h.

◆ CSToArgsListMap

Definition at line 64 of file PAG.h.

◆ CSToRetMap

typedef Map<const RetICFGNode*,const ValVar*> SVF::PAG::CSToRetMap

Definition at line 65 of file PAG.h.

◆ FParmToCallPEMap

Definition at line 62 of file PAG.h.

◆ FunPtrToCallSitesMap

Definition at line 57 of file PAG.h.

◆ FunToArgsListMap

Definition at line 63 of file PAG.h.

◆ FunToPAGEdgeSetMap

Definition at line 67 of file PAG.h.

◆ FunToRetMap

typedef Map<const FunObjVar*,const ValVar*> SVF::PAG::FunToRetMap

Definition at line 66 of file PAG.h.

◆ GepOffset

typedef std::pair<NodeID, APOffset> SVF::PAG::GepOffset

Definition at line 70 of file PAG.h.

◆ GepValueVarMap

Definition at line 74 of file PAG.h.

◆ ICFGNode2SVFStmtsMap

Definition at line 68 of file PAG.h.

◆ MemObjToFieldsMap

Definition at line 58 of file PAG.h.

◆ NodeAccessPath

Definition at line 71 of file PAG.h.

◆ NodeAccessPathMap

Definition at line 73 of file PAG.h.

◆ NodePairSetMap

Definition at line 77 of file PAG.h.

◆ NodeToNodeMap

Definition at line 69 of file PAG.h.

◆ OffsetToGepVarMap

Definition at line 72 of file PAG.h.

◆ PHINodeMap

Definition at line 61 of file PAG.h.

◆ SVFStmtList

typedef std::vector<const SVFStmt*> SVF::PAG::SVFStmtList

Definition at line 59 of file PAG.h.

◆ SVFTypeLocSetsPair

typedef std::pair<const SVFType*, std::vector<AccessPath> > SVF::PAG::SVFTypeLocSetsPair

Definition at line 75 of file PAG.h.

◆ TypeLocSetsMap

Definition at line 76 of file PAG.h.

◆ ValVarList

typedef std::vector<const ValVar*> SVF::PAG::ValVarList

Definition at line 60 of file PAG.h.

Constructor & Destructor Documentation

◆ PAG()

PAG::PAG ( bool buildFromFile)
private

Constructor.

Definition at line 43 of file PAG.cpp.

43 : PAGBase(buildFromFile), icfg(nullptr), chgraph(nullptr)
44{
45}
PAGBase(bool buildFromFile)
Definition PAGBase.h:138
ICFG * icfg
Definition PAG.h:101
CommonCHGraph * chgraph
Definition PAG.h:102

◆ ~PAG()

virtual SVF::PAG::~PAG ( )
inlinevirtual

Destructor.

Definition at line 217 of file PAG.h.

218 {
219 destroy();
220 }
void destroy()
Clean up memory.
Definition PAG.cpp:636

Member Function Documentation

◆ addAddrStmt() [1/2]

void PAG::addAddrStmt ( AddrStmt * edge)
private

Definition at line 77 of file PAG.cpp.

78{
80 addEdge(getGNode(edge->getRHSVarID()),getGNode(edge->getLHSVarID()), edge);
81}
NodeID getRHSVarID() const
NodeID getLHSVarID() const
NodeType * getGNode(NodeID id) const
bool addEdge(SVFVar *src, SVFVar *dst, SVFStmt *edge)
Add an edge into the graph.
Definition IRGraph.cpp:270
void addToStmt2TypeMap(SVFStmt *edge)
Map a SVFStatement type to a set of corresponding SVF statements.
Definition PAG.h:603

◆ addAddrStmt() [2/2]

AddrStmt * PAG::addAddrStmt ( NodeID src,
NodeID dst )
private

Add an edge into PAG.

Add Address edge

Definition at line 64 of file PAG.cpp.

65{
66 SVFVar* srcNode = getGNode(src);
67 SVFVar* dstNode = getGNode(dst);
68 if(hasNonlabeledEdge(srcNode,dstNode, SVFStmt::Addr))
69 return nullptr;
70 else
71 {
72 AddrStmt* addrPE = new AddrStmt(srcNode, dstNode);
73 addAddrStmt(addrPE);
74 return addrPE;
75 }
76}
SVFStmt * hasNonlabeledEdge(SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
Definition IRGraph.cpp:285
AddrStmt * addAddrStmt(NodeID src, NodeID dst)
Add an edge into PAG.
Definition PAG.cpp:64

◆ addArgValNode()

NodeID SVF::PAG::addArgValNode ( NodeID i,
u32_t argNo,
const ICFGNode * icfgNode,
const FunObjVar * callGraphNode,
const SVFType * type )
inlineprivate

Definition at line 677 of file PAG.h.

678 {
679 ArgValVar* node =
680 new ArgValVar(i, argNo, icfgNode, callGraphNode, type);
681 return addValNode(node);
682 }
newitem type
Definition cJSON.cpp:2739
NodeID addValNode(NodeID i, const SVFType *type, const ICFGNode *icfgNode)
add node into PAG
Definition PAG.h:665

◆ addAsmPCValNode()

NodeID SVF::PAG::addAsmPCValNode ( NodeID i,
const SVFType * type )
inlineprivate

Definition at line 843 of file PAG.h.

844 {
845 return addValNode(new AsmPCValVar(i, type));
846 }

◆ addBaseObjNode()

NodeID SVF::PAG::addBaseObjNode ( BaseObjVar * node)
inlineprotected

Definition at line 585 of file PAG.h.

586 {
587 memToFieldsMap[node->getId()].set(node->getId());
588 return addObjNode(node);
589 }
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition PAG.h:87
NodeID addObjNode(NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
Add a memory obj node.
Definition PAG.h:718

◆ addBinaryOPStmt() [1/2]

void PAG::addBinaryOPStmt ( BinaryOPStmt * edge,
SVFVar * src,
SVFVar * dst )
private

Definition at line 210 of file PAG.cpp.

211{
212 addToStmt2TypeMap(edge);
213 addEdge(src, dst, edge);
214}

◆ addBinaryOPStmt() [2/2]

BinaryOPStmt * PAG::addBinaryOPStmt ( NodeID op1,
NodeID op2,
NodeID dst,
u32_t opcode )
private

Add Copy edge.

Add Compare edge

Definition at line 194 of file PAG.cpp.

195{
196 ValVar* op1Node = const_cast<ValVar*>(getValVar(op1));
197 ValVar* op2Node = const_cast<ValVar*>(getValVar(op2));
198 ValVar* dstNode = const_cast<ValVar*>(getValVar(dst));
199 if(hasLabeledEdge(op1Node, dstNode, SVFStmt::BinaryOp, op2Node))
200 return nullptr;
201 else
202 {
203 std::vector<ValVar*> opnds = {op1Node, op2Node};
204 BinaryOPStmt* binaryOP = new BinaryOPStmt(dstNode, opnds, opcode);
205 addBinaryOPStmt(binaryOP,op1Node,dstNode);
206 return binaryOP;
207 }
208}
SVFStmt * hasLabeledEdge(SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind, const ICFGNode *cs)
Definition IRGraph.cpp:308
BinaryOPStmt * addBinaryOPStmt(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
Add Copy edge.
Definition PAG.cpp:194
const ValVar * getValVar(NodeID id) const
Definition PAG.h:140

◆ addBlackHoleAddrStmt()

SVFStmt * PAG::addBlackHoleAddrStmt ( NodeID node)
private

Set a pointer points-to black hole (e.g. int2ptr).

Add blackhole/constant edge

Definition at line 364 of file PAG.cpp.

365{
367 return pag->addAddrStmt(pag->getBlackHoleNode(), node);
368 else
369 return pag->addCopyStmt(pag->getNullPtr(), node, CopyStmt::COPYVAL);
370}
static Option< bool > HandBlackHole
Definition Options.h:98
static std::unique_ptr< PAG > pag
Callgraph with direct calls only; no change allowed after init and use callgraph in PointerAnalysis f...
Definition PAG.h:106

◆ addBlackholeObjNode()

NodeID SVF::PAG::addBlackholeObjNode ( )
inlineprivate

Definition at line 827 of file PAG.h.

828 {
829 return addObjNode(new DummyObjVar(getBlackHoleNode(), getObjTypeInfo(getBlackHoleNode()), nullptr));
830 }
NodeID getBlackHoleNode() const
Definition PAGBase.h:250
ObjTypeInfo * getObjTypeInfo(NodeID id) const
Definition PAGBase.h:237

◆ addBlackholePtrNode()

NodeID SVF::PAG::addBlackholePtrNode ( )
inlineprivate

Definition at line 835 of file PAG.h.

836 {
837 return addDummyValNode(getBlkPtr(), nullptr);
838 }
NodeID getBlkPtr() const
Definition PAGBase.h:258
NodeID addDummyValNode()
Definition PAG.h:566

◆ addBranchStmt() [1/2]

void PAG::addBranchStmt ( BranchStmt * edge,
SVFVar * src,
SVFVar * dst )
private

Definition at line 255 of file PAG.cpp.

256{
257 addToStmt2TypeMap(edge);
258 addEdge(src, dst, edge);
259}

◆ addBranchStmt() [2/2]

BranchStmt * PAG::addBranchStmt ( NodeID br,
NodeID cond,
const BranchStmt::SuccAndCondPairVec & succs )
private

Add BranchStmt.

Definition at line 241 of file PAG.cpp.

242{
243 ValVar* brNode = const_cast<ValVar*>(getValVar(br));
244 ValVar* condNode = const_cast<ValVar*>(getValVar(cond));
245 if(hasNonlabeledEdge(condNode,brNode, SVFStmt::Branch))
246 return nullptr;
247 else
248 {
249 BranchStmt* branch = new BranchStmt(brNode, condNode, succs);
250 addBranchStmt(branch,condNode,brNode);
251 return branch;
252 }
253}
BranchStmt * addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
Add BranchStmt.
Definition PAG.cpp:241

◆ addCallPE() [1/2]

void PAG::addCallPE ( CallPE * edge,
SVFVar * src,
SVFVar * dst )
private

Definition at line 331 of file PAG.cpp.

332{
333 addToStmt2TypeMap(edge);
334 addEdge(src, dst, edge);
335 fParmToCallPEMap[dst] = edge;
336}
FParmToCallPEMap fParmToCallPEMap
Map a formal param to its CallPE.
Definition PAG.h:91

◆ addCallPE() [2/2]

CallPE * PAG::addCallPE ( NodeID src,
NodeID dst,
const CallICFGNode * cs,
const FunEntryICFGNode * entry )
private

Add Call edge (phi-like: merges actual params from all call sites into formal param).

Add Call edge (phi-like: merges actual params from all call sites into formal param)

return null if we already added this CallPE

Definition at line 311 of file PAG.cpp.

312{
313 ValVar* opNode = const_cast<ValVar*>(getValVar(src));
314 ValVar* resNode = const_cast<ValVar*>(getValVar(dst));
315 FParmToCallPEMap::iterator it = fParmToCallPEMap.find(resNode);
316 // if first operand, create a new CallPE, otherwise add the operand to the existing CallPE
317 if(it == fParmToCallPEMap.end())
318 {
319 CallPE* callPE = new CallPE(resNode, {opNode}, {cs}, entry);
320 addCallPE(callPE, opNode, resNode);
321 return callPE;
322 }
323 else
324 {
325 it->second->addOpVar(opNode, cs);
327 return nullptr;
328 }
329}
CallPE * addCallPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Call edge (phi-like: merges actual params from all call sites into formal param).
Definition PAG.cpp:311

◆ addCallSite()

void SVF::PAG::addCallSite ( const CallICFGNode * call)
inlineprivate

Add callsites.

Definition at line 870 of file PAG.h.

871 {
872 callSiteSet.insert(call);
873 }
CallSiteSet callSiteSet
Definition PAG.h:103

◆ addCallSiteArgs()

void SVF::PAG::addCallSiteArgs ( CallICFGNode * callBlockNode,
const ValVar * arg )
inlineprivate

Add callsite arguments.

Definition at line 642 of file PAG.h.

643 {
644 callBlockNode->addActualParms(arg);
645 callSiteArgsListMap[callBlockNode].push_back(arg);
646 }
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition PAG.h:93

◆ addCallSiteRets()

void SVF::PAG::addCallSiteRets ( RetICFGNode * retBlockNode,
const ValVar * arg )
inlineprivate

Add callsite returns.

Definition at line 648 of file PAG.h.

649 {
650 retBlockNode->addActualRet(arg);
651 callSiteRetMap[retBlockNode]= arg;
652 }
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
Definition PAG.h:94

◆ addCmpStmt() [1/2]

void PAG::addCmpStmt ( CmpStmt * edge,
SVFVar * src,
SVFVar * dst )
private

Definition at line 184 of file PAG.cpp.

185{
186 addToStmt2TypeMap(edge);
187 addEdge(src, dst, edge);
188}

◆ addCmpStmt() [2/2]

CmpStmt * PAG::addCmpStmt ( NodeID op1,
NodeID op2,
NodeID dst,
u32_t predicate )
private

Add Copy edge.

Add Compare edge

Definition at line 168 of file PAG.cpp.

169{
170 ValVar* op1Node = const_cast<ValVar*>(getValVar(op1));
171 ValVar* op2Node = const_cast<ValVar*>(getValVar(op2));
172 ValVar* dstNode = const_cast<ValVar*>(getValVar(dst));
173 if(hasLabeledEdge(op1Node, dstNode, SVFStmt::Cmp, op2Node))
174 return nullptr;
175 else
176 {
177 std::vector<ValVar*> opnds = {op1Node, op2Node};
178 CmpStmt* cmp = new CmpStmt(dstNode, opnds, predicate);
179 addCmpStmt(cmp, op1Node, dstNode);
180 return cmp;
181 }
182}
CmpStmt * addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
Add Copy edge.
Definition PAG.cpp:168

◆ addConstantDataObjNode()

NodeID SVF::PAG::addConstantDataObjNode ( const NodeID i,
ObjTypeInfo * ti,
const ICFGNode * node )
inlineprivate

Definition at line 774 of file PAG.h.

775 {
776 ConstDataObjVar* conObj = new ConstDataObjVar(i, ti, node);
777 return addBaseObjNode(conObj);
778 }
NodeID addBaseObjNode(BaseObjVar *node)
Definition PAG.h:585

◆ addConstantDataValNode()

NodeID SVF::PAG::addConstantDataValNode ( const NodeID i,
const ICFGNode * icfgNode,
const SVFType * type )
inlineprivate

Definition at line 710 of file PAG.h.

711 {
712 SVFVar* node = new ConstDataValVar(i, icfgNode, type);
713 return addNode(node);
714 }
NodeID addNode(SVFVar *node)
Add a node into the graph.
Definition PAGBase.h:115

◆ addConstantFPObjNode()

NodeID SVF::PAG::addConstantFPObjNode ( NodeID i,
ObjTypeInfo * ti,
double dval,
const ICFGNode * node )
inlineprivate

Definition at line 748 of file PAG.h.

749 {
750 ConstFPObjVar* conObj = new ConstFPObjVar(i, dval, ti, node);
751 return addBaseObjNode(conObj);
752 }

◆ addConstantFPValNode()

NodeID SVF::PAG::addConstantFPValNode ( const NodeID i,
double dval,
const ICFGNode * icfgNode,
const SVFType * type )
inlineprivate

Definition at line 684 of file PAG.h.

686 {
687 SVFVar* node = new ConstFPValVar(i, dval, icfgNode, type);
688 return addNode(node);
689 }

◆ addConstantIntObjNode()

NodeID SVF::PAG::addConstantIntObjNode ( NodeID i,
ObjTypeInfo * ti,
const std::pair< s64_t, u64_t > & intValue,
const ICFGNode * node )
inlineprivate

Definition at line 755 of file PAG.h.

756 {
757 ConstIntObjVar* conObj =
758 new ConstIntObjVar(i, intValue.first, intValue.second, ti, node);
759 return addBaseObjNode(conObj);
760 }

◆ addConstantIntValNode()

NodeID SVF::PAG::addConstantIntValNode ( NodeID i,
const std::pair< s64_t, u64_t > & intValue,
const ICFGNode * icfgNode,
const SVFType * type )
inlineprivate

Definition at line 691 of file PAG.h.

693 {
694 SVFVar* node = new ConstIntValVar(i, intValue.first, intValue.second, icfgNode, type);
695 return addNode(node);
696 }

◆ addConstantNullPtrObjNode()

NodeID SVF::PAG::addConstantNullPtrObjNode ( const NodeID i,
ObjTypeInfo * ti,
const ICFGNode * node )
inlineprivate

Definition at line 763 of file PAG.h.

764 {
765 ConstNullPtrObjVar* conObj = new ConstNullPtrObjVar(i, ti, node);
766 return addBaseObjNode(conObj);
767 }

◆ addConstantNullPtrValNode()

NodeID SVF::PAG::addConstantNullPtrValNode ( const NodeID i,
const ICFGNode * icfgNode,
const SVFType * type )
inlineprivate

Definition at line 698 of file PAG.h.

699 {
700 SVFVar* node = new ConstNullPtrValVar(i, icfgNode, type);
701 return addNode(node);
702 }

◆ addConstantObjNode()

NodeID SVF::PAG::addConstantObjNode ( )
inlineprivate

Definition at line 831 of file PAG.h.

832 {
833 return addObjNode(new DummyObjVar(getConstantNode(), getObjTypeInfo(getConstantNode()), nullptr));
834 }
NodeID getConstantNode() const
Definition PAGBase.h:254

◆ addCopyStmt() [1/2]

void PAG::addCopyStmt ( CopyStmt * edge)
private

Definition at line 100 of file PAG.cpp.

101{
102 addToStmt2TypeMap(edge);
103 addEdge(getGNode(edge->getRHSVarID()),getGNode(edge->getLHSVarID()), edge);
104}

◆ addCopyStmt() [2/2]

CopyStmt * PAG::addCopyStmt ( NodeID src,
NodeID dst,
CopyStmt::CopyKind type )
private

Add Copy edge.

Add Copy edge

Definition at line 86 of file PAG.cpp.

87{
88 SVFVar* srcNode = getGNode(src);
89 SVFVar* dstNode = getGNode(dst);
90 if(hasNonlabeledEdge(srcNode,dstNode, SVFStmt::Copy))
91 return nullptr;
92 else
93 {
94 CopyStmt* copyPE = new CopyStmt(srcNode, dstNode, type);
95 addCopyStmt(copyPE);
96 return copyPE;
97 }
98}
CopyStmt * addCopyStmt(NodeID src, NodeID dst, CopyStmt::CopyKind type)
Add Copy edge.
Definition PAG.cpp:86

◆ addDummyObjNode() [1/3]

NodeID SVF::PAG::addDummyObjNode ( const SVFType * type)
inline

Definition at line 570 of file PAG.h.

571 {
572 return addDummyObjNode(NodeIDAllocator::get()->allocateObjectId(), type);
573 }
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID addDummyObjNode(const SVFType *type)
Definition PAG.h:570

◆ addDummyObjNode() [2/3]

NodeID PAG::addDummyObjNode ( DummyObjVar * node)
protected

Definition at line 813 of file PAG.cpp.

814{
815 return addObjNode(node);
816}

◆ addDummyObjNode() [3/3]

NodeID SVF::PAG::addDummyObjNode ( NodeID i,
const SVFType * type )
inlineprivate

Definition at line 813 of file PAG.h.

814 {
815 if (idToObjTypeInfoMap().find(i) == idToObjTypeInfoMap().end())
816 {
817 ObjTypeInfo* ti = createObjTypeInfo(type);
818 idToObjTypeInfoMap()[i] = ti;
819 return addDummyObjNode(new DummyObjVar(i, ti, nullptr));
820 }
821 else
822 {
823 return addDummyObjNode(new DummyObjVar(i, getObjTypeInfo(i), nullptr));
824 }
825 }
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
IDToTypeInfoMapTy & idToObjTypeInfoMap()
Get different kinds of syms maps.
Definition PAGBase.h:215

◆ addDummyValNode() [1/2]

NodeID SVF::PAG::addDummyValNode ( )
inline

Definition at line 566 of file PAG.h.

567 {
568 return addDummyValNode(NodeIDAllocator::get()->allocateValueId(), nullptr);
569 }

◆ addDummyValNode() [2/2]

NodeID SVF::PAG::addDummyValNode ( NodeID i,
const ICFGNode * node )
inlineprivate

Add a dummy value/object node according to node ID (llvm value is null).

Definition at line 809 of file PAG.h.

810 {
811 return addValNode(new DummyValVar(i, node));
812 }

◆ addFIObjNode()

NodeID SVF::PAG::addFIObjNode ( NodeID i,
ObjTypeInfo * ti,
const ICFGNode * node )
inlineprivate

Add a field-insensitive node, this method can only invoked by getFIGepObjNode.

Definition at line 798 of file PAG.h.

799 {
800 BaseObjVar* baseObj = new BaseObjVar(i, ti, node);
801 return addBaseObjNode(baseObj);
802 }

◆ addFunArgs() [1/2]

void SVF::PAG::addFunArgs ( const FunObjVar * fun,
const ValVar * arg )
inlineprivate

Get/set method for function/callsite arguments and returns.

Add function arguments

Definition at line 618 of file PAG.h.

619 {
620 FunEntryICFGNode* funEntryBlockNode = icfg->getFunEntryICFGNode(fun);
621 addFunArgs(funEntryBlockNode, fun, arg);
622 }
void addFunArgs(const FunObjVar *fun, const ValVar *arg)
Get/set method for function/callsite arguments and returns.
Definition PAG.h:618

◆ addFunArgs() [2/2]

void SVF::PAG::addFunArgs ( FunEntryICFGNode * funEntryBlockNode,
const FunObjVar * fun,
const ValVar * arg )
inlineprivate

Definition at line 624 of file PAG.h.

625 {
626 funEntryBlockNode->addFormalParms(arg);
627 funArgsListMap[fun].push_back(arg);
628 }
FunToArgsListMap funArgsListMap
Map a function to a list of all its formal parameters.
Definition PAG.h:92

◆ addFunObjNode()

NodeID SVF::PAG::addFunObjNode ( NodeID id,
ObjTypeInfo * ti,
const ICFGNode * node )
inlineprivate

Definition at line 741 of file PAG.h.

742 {
743 FunObjVar* funObj = new FunObjVar(id, ti, node);
744 return addBaseObjNode(funObj);
745 }

◆ addFunRet() [1/2]

void SVF::PAG::addFunRet ( const FunObjVar * fun,
const ValVar * ret )
inlineprivate

Add function returns.

Definition at line 630 of file PAG.h.

631 {
632 FunExitICFGNode* funExitBlockNode = icfg->getFunExitICFGNode(fun);
633 addFunRet(funExitBlockNode, fun, ret);
634 }
void addFunRet(const FunObjVar *fun, const ValVar *ret)
Add function returns.
Definition PAG.h:630

◆ addFunRet() [2/2]

void SVF::PAG::addFunRet ( FunExitICFGNode * funExitBlockNode,
const FunObjVar * fun,
const ValVar * ret )
inlineprivate

Definition at line 636 of file PAG.h.

637 {
638 funExitBlockNode->addFormalRet(ret);
639 funRetMap[fun] = ret;
640 }
FunToRetMap funRetMap
Map a function to its unique function return PAGNodes.
Definition PAG.h:95

◆ addFunValNode()

NodeID SVF::PAG::addFunValNode ( NodeID i,
const ICFGNode * icfgNode,
const FunObjVar * funObjVar,
const SVFType * type )
inlineprivate

Definition at line 671 of file PAG.h.

672 {
673 FunValVar* node = new FunValVar(i, icfgNode, funObjVar, type);
674 return addValNode(node);
675 }

◆ addGepObjNode() [1/2]

NodeID PAG::addGepObjNode ( const BaseObjVar * baseObj,
const APOffset & apOffset,
const NodeID gepId )
private

Add a field obj node, this method can only invoked by getGepObjVar.

Add a field obj node, this method can only invoked by getGepObjVar

Definition at line 559 of file PAG.cpp.

560{
561 //assert(findPAGNode(i) == false && "this node should not be created before");
562 NodeID base = baseObj->getId();
563 assert(0==GepObjVarMap.count(std::make_pair(base, apOffset))
564 && "this node should not be created before");
565 //ABTest
566 GepObjVar *node = new GepObjVar(baseObj, gepId, apOffset);
567 return addGepObjNode(node, base, apOffset);
568}
NodeID getId() const
Get the memory object id.
NodeID addGepObjNode(GepObjVar *gepObj, NodeID base, const APOffset &apOffset)
Definition PAG.cpp:547
OffsetToGepVarMap GepObjVarMap
Map a pair<base,off> to a gep obj node id.
Definition PAG.h:86
u32_t NodeID
Definition GeneralType.h:76

◆ addGepObjNode() [2/2]

NodeID PAG::addGepObjNode ( GepObjVar * gepObj,
NodeID base,
const APOffset & apOffset )
protected

Definition at line 547 of file PAG.cpp.

548{
549 assert(0==GepObjVarMap.count(std::make_pair(base, apOffset))
550 && "this node should not be created before");
551 GepObjVarMap[std::make_pair(base, apOffset)] = gepObj->getId();
552 memToFieldsMap[base].set(gepObj->getId());
553 return addObjNode(gepObj);
554}
NodeID getId() const
Get ID.
Definition SVFValue.h:158

◆ addGepStmt() [1/2]

void PAG::addGepStmt ( GepStmt * edge)
private

Definition at line 452 of file PAG.cpp.

453{
454 SVFVar* baseNode = getGNode(gepPE->getRHSVarID());
455 SVFVar* dstNode = getGNode(gepPE->getLHSVarID());
456 addToStmt2TypeMap(gepPE);
457 addEdge(baseNode, dstNode, gepPE);
458
459}

◆ addGepStmt() [2/2]

GepStmt * PAG::addGepStmt ( NodeID src,
NodeID dst,
const AccessPath & ap,
bool constGep )
private

Add Gep edge.

Add Offset(Gep) edge Find the base node id of src and connect base node to dst node Create gep offset: (offset + baseOff <nested struct gep size>)

Since the offset from base to src is variant, the new gep edge being created is also a Variant GepStmt edge.

Definition at line 419 of file PAG.cpp.

420{
421
422 SVFVar* node = getGNode(src);
423 if (!constGep || node->hasIncomingVariantGepEdge())
424 {
427 return addVariantGepStmt(src, dst, ap);
428 }
429 else
430 {
431 return addNormalGepStmt(src, dst, ap);
432 }
433}
GepStmt * addVariantGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
Definition PAG.cpp:465
GepStmt * addNormalGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
Definition PAG.cpp:438
bool hasIncomingVariantGepEdge() const
Check for incoming variable field GEP edges.

◆ addGepValNode()

NodeID PAG::addGepValNode ( NodeID curInst,
const ValVar * baseVar,
const AccessPath & ap,
NodeID i,
const SVFType * type,
const ICFGNode * icn )
private

Add a temp field value node, this method can only invoked by getGepValVar.

Add a temp field value node, this method can only invoked by getGepValVar due to constraint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar.

Definition at line 486 of file PAG.cpp.

487{
488 NodeID base = baseVar->getId();
489 //assert(findPAGNode(i) == false && "this node should not be created before");
490 assert(0==GepValObjMap[curInst].count(std::make_pair(base, ap))
491 && "this node should not be created before");
492 GepValObjMap[curInst][std::make_pair(base, ap)] = i;
493 GepValVar *node = new GepValVar(baseVar, i, ap, type, icn);
494 node->setLLVMVarInstID(curInst);
495 return addValNode(node);
496}
int count
Definition cJSON.h:216
void setLLVMVarInstID(NodeID id)
Set the LLVM variable ID associated with this GepValVar.
GepValueVarMap GepValObjMap
Map a pair<base,off> to a gep value node id.
Definition PAG.h:84

◆ addGepValObjFromDB()

void SVF::PAG::addGepValObjFromDB ( NodeID curInstID,
const GepValVar * gepValvar )
inlineprotected

Definition at line 595 of file PAG.h.

596 {
597 GepValObjMap[curInstID][std::make_pair(gepValvar->getBaseNode()->getId(), gepValvar->getAccessPath())] = gepValvar->getId();
598 }

◆ addGlobalObjNode()

NodeID SVF::PAG::addGlobalObjNode ( const NodeID i,
ObjTypeInfo * ti,
const ICFGNode * node )
inlineprivate

Definition at line 769 of file PAG.h.

770 {
771 GlobalObjVar* gObj = new GlobalObjVar(i, ti, node);
772 return addBaseObjNode(gObj);
773 }

◆ addGlobalPAGEdge()

void SVF::PAG::addGlobalPAGEdge ( const SVFStmt * edge)
inlineprivate

Add global PAGEdges (not in a procedure).

Definition at line 865 of file PAG.h.

866 {
867 globSVFStmtSet.insert(edge);
868 }
SVFStmtSet globSVFStmtSet
Global PAGEdges without control flow information.
Definition PAG.h:89

◆ addGlobalValNode()

NodeID SVF::PAG::addGlobalValNode ( const NodeID i,
const ICFGNode * icfgNode,
const SVFType * svfType )
inlineprivate

Definition at line 704 of file PAG.h.

705 {
706 SVFVar* node = new GlobalValVar(i, icfgNode, svfType);
707 return addNode(node);
708 }

◆ addHeapObjNode()

NodeID SVF::PAG::addHeapObjNode ( NodeID i,
ObjTypeInfo * ti,
const ICFGNode * node )
inlineprivate

Creates and adds a heap object node to the PAG

Definition at line 726 of file PAG.h.

727 {
728 HeapObjVar *heapObj = new HeapObjVar(i, ti, node);
729 return addBaseObjNode(heapObj);
730 }

◆ addIndirectCallsites()

void SVF::PAG::addIndirectCallsites ( const CallICFGNode * cs,
NodeID funPtr )
inlineprivate

Add indirect callsites.

Definition at line 654 of file PAG.h.

655 {
656 bool added = indCallSiteToFunPtrMap.emplace(cs, funPtr).second;
657 (void) added;
658 funPtrToCallSitesMap[funPtr].insert(cs);
659 assert(added && "adding the same indirect callsite twice?");
660 }
FunPtrToCallSitesMap funPtrToCallSitesMap
Definition PAG.h:97
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition PAG.h:96

◆ addIntrinsicValNode()

NodeID SVF::PAG::addIntrinsicValNode ( NodeID i,
const SVFType * type )
inlineprivate

Definition at line 839 of file PAG.h.

840 {
841 return addValNode(new IntrinsicValVar(i, type));
842 }

◆ addLoadStmt() [1/2]

void PAG::addLoadStmt ( LoadStmt * edge)
private

Definition at line 278 of file PAG.cpp.

279{
280 addToStmt2TypeMap(edge);
281 addEdge(getGNode(edge->getRHSVarID()),getGNode(edge->getLHSVarID()), edge);
282}

◆ addLoadStmt() [2/2]

LoadStmt * PAG::addLoadStmt ( NodeID src,
NodeID dst )
private

Add Load edge.

Add Load edge

Definition at line 264 of file PAG.cpp.

265{
266 SVFVar* srcNode = getGNode(src);
267 SVFVar* dstNode = getGNode(dst);
268 if(hasNonlabeledEdge(srcNode,dstNode, SVFStmt::Load))
269 return nullptr;
270 else
271 {
272 LoadStmt* loadPE = new LoadStmt(srcNode, dstNode);
273 addLoadStmt(loadPE);
274 return loadPE;
275 }
276}
LoadStmt * addLoadStmt(NodeID src, NodeID dst)
Add Load edge.
Definition PAG.cpp:264

◆ addNormalGepStmt()

GepStmt * PAG::addNormalGepStmt ( NodeID src,
NodeID dst,
const AccessPath & ap )
private

Add Offset(Gep) edge.

Add normal (Gep) edge

Definition at line 438 of file PAG.cpp.

439{
440 SVFVar* baseNode = getGNode(src);
441 SVFVar* dstNode = getGNode(dst);
442 if(hasNonlabeledEdge(baseNode, dstNode, SVFStmt::Gep))
443 return nullptr;
444 else
445 {
446 GepStmt* gepPE = new GepStmt(baseNode, dstNode, ap);
447 addGepStmt(gepPE);
448 return gepPE;
449 }
450}
GepStmt * addGepStmt(NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
Add Gep edge.
Definition PAG.cpp:419

◆ addObjNode() [1/2]

NodeID SVF::PAG::addObjNode ( NodeID i,
ObjTypeInfo * ti,
const ICFGNode * node )
inlineprivate

Add a memory obj node.

Definition at line 718 of file PAG.h.

719 {
720 return addFIObjNode( i, ti, node);
721 }
NodeID addFIObjNode(NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
Definition PAG.h:798

◆ addObjNode() [2/2]

NodeID PAG::addObjNode ( ObjVar * node)
private

Add a memory obj node.

Definition at line 796 of file PAG.cpp.

797{
798 assert(node && "node cannot be nullptr.");
799 assert(hasGNode(node->getId()) == false &&
800 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
801 "Strategy::DBUG to SEQ or DENSE");
802 NodeID id = addNode(node);
803 // An object's constness is fixed by the time its node is added: SymbolTableBuilder sets
804 // the constant flags before the PAG is built, and a field object (GepObjVar) shares
805 // the constness of its base object, which is added first.
806 const BaseObjVar* obj = getBaseObject(id);
807 assert(obj && "not an object node?");
808 if (isConstantSym(id) || obj->isConstDataOrConstGlobal())
809 constantObjs.insert(id);
810 return id;
811}
bool isConstDataOrConstGlobal() const
static bool isConstantSym(NodeID id)
Definition PAGBase.h:172
const BaseObjVar * getBaseObject(NodeID id) const
Definition PAG.h:499
NodeSet constantObjs
Constant objects and their fields, recorded when each object node is added.
Definition PAG.h:88

◆ addPhiStmt() [1/2]

PhiStmt * PAG::addPhiStmt ( NodeID res,
NodeID opnd,
const ICFGNode * pred )
private

Add phi node information.

Add Phi statement

return null if we already added this PhiStmt

Definition at line 109 of file PAG.cpp.

110{
111 ValVar* opNode = const_cast<ValVar*>(getValVar(opnd));
112 ValVar* resNode = const_cast<ValVar*>(getValVar(res));
113 PHINodeMap::iterator it = phiNodeMap.find(resNode);
114 if(it == phiNodeMap.end())
115 {
116 PhiStmt* phi = new PhiStmt(resNode, {opNode}, {pred});
117 addPhiStmt(phi, opNode, resNode);
118 return phi;
119 }
120 else
121 {
122 it->second->addOpVar(opNode,pred);
124 return nullptr;
125 }
126}
PhiStmt * addPhiStmt(NodeID res, NodeID opnd, const ICFGNode *pred)
Add phi node information.
Definition PAG.cpp:109
PHINodeMap phiNodeMap
A set of phi copy edges.
Definition PAG.h:90

◆ addPhiStmt() [2/2]

void PAG::addPhiStmt ( PhiStmt * edge,
SVFVar * src,
SVFVar * dst )
private

Definition at line 128 of file PAG.cpp.

129{
130 SVFVar* opNode = src;
131 SVFVar* resNode = dst;
132
133 addToStmt2TypeMap(edge);
134 addEdge(opNode, resNode, edge);
135 phiNodeMap[resNode] = edge;
136
137}

◆ addRetNode() [1/2]

NodeID SVF::PAG::addRetNode ( const FunObjVar * ,
SVFVar * node )
inlineprivate

Add a unique return node for a procedure.

Definition at line 854 of file PAG.h.

855 {
856 return addNode(node);
857 }

◆ addRetNode() [2/2]

NodeID SVF::PAG::addRetNode ( NodeID i,
const FunObjVar * callGraphNode,
const SVFType * type,
const ICFGNode * icn )
inlineprivate

Add a unique return node for a procedure.

Definition at line 781 of file PAG.h.

782 {
783 SVFVar *node = new RetValPN(i, callGraphNode, type, icn);
784 return addRetNode(callGraphNode, node);
785 }
NodeID addRetNode(NodeID i, const FunObjVar *callGraphNode, const SVFType *type, const ICFGNode *icn)
Add a unique return node for a procedure.
Definition PAG.h:781

◆ addRetPE() [1/2]

RetPE * PAG::addRetPE ( NodeID src,
NodeID dst,
const CallICFGNode * cs,
const FunExitICFGNode * exit )
private

Add Return edge.

Add Return edge

Definition at line 341 of file PAG.cpp.

342{
343 SVFVar* srcNode = getGNode(src);
344 SVFVar* dstNode = getGNode(dst);
345 if(hasLabeledEdge(srcNode,dstNode, SVFStmt::Ret, cs))
346 return nullptr;
347 else
348 {
349 RetPE* retPE = new RetPE(srcNode, dstNode, cs, exit);
350 addRetPE(retPE,srcNode,dstNode);
351 return retPE;
352 }
353}
RetPE * addRetPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Return edge.
Definition PAG.cpp:341

◆ addRetPE() [2/2]

void PAG::addRetPE ( RetPE * edge,
SVFVar * src,
SVFVar * dst )
private

Definition at line 355 of file PAG.cpp.

356{
357 addToStmt2TypeMap(edge);
358 addEdge(src, dst, edge);
359}

◆ addSelectStmt() [1/2]

SelectStmt * PAG::addSelectStmt ( NodeID res,
NodeID op1,
NodeID op2,
NodeID cond )
private

Add SelectStmt.

Add Phi statement

Definition at line 142 of file PAG.cpp.

143{
144 ValVar* op1Node = const_cast<ValVar*>(getValVar(op1));
145 ValVar* op2Node = const_cast<ValVar*>(getValVar(op2));
146 ValVar* dstNode = const_cast<ValVar*>(getValVar(res));
147 const SVFVar* condNode = getGNode(cond);
148 if(hasLabeledEdge(op1Node, dstNode, SVFStmt::Select, op2Node))
149 return nullptr;
150 else
151 {
152 std::vector<ValVar*> opnds = {op1Node, op2Node};
153 SelectStmt* select = new SelectStmt(dstNode, opnds, condNode);
154 addSelectStmt(select, op1Node, dstNode);
155 return select;
156 }
157}
SelectStmt * addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
Add SelectStmt.
Definition PAG.cpp:142

◆ addSelectStmt() [2/2]

void PAG::addSelectStmt ( SelectStmt * edge,
SVFVar * src,
SVFVar * dst )
private

Definition at line 159 of file PAG.cpp.

160{
161 addToStmt2TypeMap(edge);
162 addEdge(src, dst, edge);
163}

◆ addStackObjNode()

NodeID SVF::PAG::addStackObjNode ( NodeID i,
ObjTypeInfo * ti,
const ICFGNode * node )
inlineprivate

Creates and adds a stack object node to the PAG

Definition at line 735 of file PAG.h.

736 {
737 StackObjVar *stackObj = new StackObjVar(i, ti, node);
738 return addBaseObjNode(stackObj);
739 }

◆ addStoreStmt() [1/2]

StoreStmt * PAG::addStoreStmt ( NodeID src,
NodeID dst,
const ICFGNode * curVal )
private

Add Store edge.

Add Store edge Note that two store instructions may share the same Store SVFStmt

Definition at line 288 of file PAG.cpp.

289{
290 SVFVar* srcNode = getGNode(src);
291 SVFVar* dstNode = getGNode(dst);
292 if(hasLabeledEdge(srcNode,dstNode, SVFStmt::Store, curVal))
293 return nullptr;
294 else
295 {
296 StoreStmt* storePE = new StoreStmt(srcNode, dstNode, curVal);
297 addStoreStmt(storePE,srcNode,dstNode);
298 return storePE;
299 }
300}
StoreStmt * addStoreStmt(NodeID src, NodeID dst, const ICFGNode *val)
Add Store edge.
Definition PAG.cpp:288

◆ addStoreStmt() [2/2]

void PAG::addStoreStmt ( StoreStmt * edge,
SVFVar * src,
SVFVar * dst )
private

Definition at line 302 of file PAG.cpp.

303{
304 addToStmt2TypeMap(edge);
305 addEdge(src,dst, edge);
306}

◆ addThreadForkPE()

TDForkPE * PAG::addThreadForkPE ( NodeID src,
NodeID dst,
const CallICFGNode * cs,
const FunEntryICFGNode * entry )
private

Add Thread fork edge for parameter passing.

Add Thread fork edge for parameter passing from a spawner to its spawnees

Definition at line 375 of file PAG.cpp.

376{
377 ValVar* opNode = const_cast<ValVar*>(getValVar(src));
378 ValVar* resNode = const_cast<ValVar*>(getValVar(dst));
379 FParmToCallPEMap::iterator it = fParmToCallPEMap.find(resNode);
380 // if first operand, create a new TDForkPE, otherwise add the operand to the existing TDForkPE
381 if(it == fParmToCallPEMap.end())
382 {
383 TDForkPE* forkPE = new TDForkPE(resNode, {opNode}, {cs}, entry);
384 addToStmt2TypeMap(forkPE);
385 addEdge(opNode, resNode, forkPE);
386 fParmToCallPEMap[resNode] = forkPE;
387 return forkPE;
388 }
389 else
390 {
391 it->second->addOpVar(opNode, cs);
392 return nullptr;
393 }
394}

◆ addThreadJoinPE()

TDJoinPE * PAG::addThreadJoinPE ( NodeID src,
NodeID dst,
const CallICFGNode * cs,
const FunExitICFGNode * exit )
private

Add Thread join edge for parameter passing.

Add Thread fork edge for parameter passing from a spawnee back to its spawners

Definition at line 399 of file PAG.cpp.

400{
401 SVFVar* srcNode = getGNode(src);
402 SVFVar* dstNode = getGNode(dst);
403 if(hasLabeledEdge(srcNode,dstNode, SVFStmt::ThreadJoin, cs))
404 return nullptr;
405 else
406 {
407 TDJoinPE* joinPE = new TDJoinPE(srcNode, dstNode, cs, exit);
408 addRetPE(joinPE,srcNode,dstNode);
409 return joinPE;
410 }
411}

◆ addToStmt2TypeMap()

void SVF::PAG::addToStmt2TypeMap ( SVFStmt * edge)
inlineprivate

Map a SVFStatement type to a set of corresponding SVF statements.

this is a pointer-related SVFStmt if (1) both RHS and LHS are pointers or (2) this an int2ptr statment, i.e., LHS = int2ptr RHS

Definition at line 603 of file PAG.h.

604 {
605 bool added = KindToSVFStmtSetMap[edge->getEdgeKind()].insert(edge).second;
606 (void)added; // Suppress warning of unused variable under release build
607 assert(added && "duplicated edge, not added!!!");
609 if (edge->isPTAEdge() || (SVFUtil::isa<CopyStmt>(edge) && SVFUtil::cast<CopyStmt>(edge)->isInt2Ptr()))
610 {
612 KindToPTASVFStmtSetMap[edge->getEdgeKind()].insert(edge);
613 }
614 }
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
PAG edge map containing all PAGEdges.
Definition PAGBase.h:106
u32_t totalPTAPAGEdge
Definition PAGBase.h:110
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
PAG edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
Definition PAGBase.h:107
std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > cast(const Y &Val)
Definition Casting.h:360
LLVM_NODISCARD bool isa(const Y &Val)
Definition Casting.h:241

◆ addToSVFStmtList()

void SVF::PAG::addToSVFStmtList ( ICFGNode * inst,
SVFStmt * edge )
inline

Add a SVFStmt into instruction map.

Definition at line 329 of file PAG.h.

330 {
331 edge->setICFGNode(inst);
332 icfgNode2SVFStmtsMap[inst].push_back(edge);
333 if (edge->isPTAEdge())
334 icfgNode2PTASVFStmtsMap[inst].push_back(edge);
335 }
ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap
Map an ICFGNode to its PointerAnalysis related SVFStmts.
Definition PAG.h:83
ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap
Map an ICFGNode to its SVFStmts.
Definition PAG.h:82

◆ addToTypeLocSetsMap()

void SVF::PAG::addToTypeLocSetsMap ( NodeID argId,
SVFTypeLocSetsPair & locSets )
inline

Add a base SVFType* and all its field location sets to an arg NodeId.

Definition at line 337 of file PAG.h.

338 {
339 typeLocSetsMap[argId]=locSets;
340 }
TypeLocSetsMap typeLocSetsMap
Map an arg to its base SVFType* and all its field location sets.
Definition PAG.h:85

◆ addUnaryOPStmt() [1/2]

UnaryOPStmt * PAG::addUnaryOPStmt ( NodeID src,
NodeID dst,
u32_t opcode )
private

Add Unary edge.

Add Unary edge

Definition at line 218 of file PAG.cpp.

219{
220 ValVar* srcNode = const_cast<ValVar*>(getValVar(src));
221 ValVar* dstNode = const_cast<ValVar*>(getValVar(dst));
222 if(hasNonlabeledEdge(srcNode,dstNode, SVFStmt::UnaryOp))
223 return nullptr;
224 else
225 {
226 UnaryOPStmt* unaryOP = new UnaryOPStmt(srcNode, dstNode, opcode);
227 addUnaryOPStmt(unaryOP, srcNode,dstNode);
228 return unaryOP;
229 }
230}
UnaryOPStmt * addUnaryOPStmt(NodeID src, NodeID dst, u32_t opcode)
Add Unary edge.
Definition PAG.cpp:218

◆ addUnaryOPStmt() [2/2]

void PAG::addUnaryOPStmt ( UnaryOPStmt * edge,
SVFVar * src,
SVFVar * dst )
private

Definition at line 232 of file PAG.cpp.

233{
234 addToStmt2TypeMap(edge);
235 addEdge(src, dst, edge);
236}

◆ addValNode() [1/2]

NodeID SVF::PAG::addValNode ( NodeID i,
const SVFType * type,
const ICFGNode * icfgNode )
inlineprivate

add node into PAG

Add a value (pointer) node

Definition at line 665 of file PAG.h.

666 {
667 ValVar *node = new ValVar(i, type, icfgNode, ValVar::ValNode);
668 return addValNode(node);
669 }

◆ addValNode() [2/2]

NodeID PAG::addValNode ( ValVar * node)
private

Add a value (pointer) node.

Definition at line 787 of file PAG.cpp.

788{
789 assert(node && "node cannot be nullptr.");
790 assert(hasGNode(node->getId()) == false &&
791 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
792 "Strategy::DBUG to SEQ or DENSE");
793 return addNode(node);
794}

◆ addVarargNode() [1/2]

NodeID SVF::PAG::addVarargNode ( const FunObjVar * ,
SVFVar * node )
inlineprivate

Add a unique vararg node for a procedure.

Definition at line 859 of file PAG.h.

860 {
861 return addNode(node);
862 }

◆ addVarargNode() [2/2]

NodeID SVF::PAG::addVarargNode ( NodeID i,
const FunObjVar * val,
const SVFType * type,
const ICFGNode * n )
inlineprivate

Add a unique vararg node for a procedure.

Definition at line 787 of file PAG.h.

788 {
789 SVFVar *node = new VarArgValPN(i, val, type, n);
790 return addNode(node);
791 }
cJSON * n
Definition cJSON.cpp:2558

◆ addVariantGepStmt()

GepStmt * PAG::addVariantGepStmt ( NodeID src,
NodeID dst,
const AccessPath & ap )
private

Add Variant(Gep) edge.

Add variant(Gep) edge Find the base node id of src and connect base node to dst node

Definition at line 465 of file PAG.cpp.

466{
467 SVFVar* baseNode = getGNode(src);
468 SVFVar* dstNode = getGNode(dst);
469 if(hasNonlabeledEdge(baseNode, dstNode, SVFStmt::Gep))
470 return nullptr;
471 else
472 {
473 GepStmt* gepPE = new GepStmt(baseNode, dstNode, ap, true);
474 addToStmt2TypeMap(gepPE);
475 addEdge(baseNode, dstNode, gepPE);
476 return gepPE;
477 }
478}

◆ callsiteHasRet()

bool SVF::PAG::callsiteHasRet ( const RetICFGNode * cs) const
inline

Definition at line 414 of file PAG.h.

415 {
416 return callSiteRetMap.find(cs) != callSiteRetMap.end();
417 }

◆ destroy()

void PAG::destroy ( )
private

Clean up memory.

Clean up memory

Definition at line 636 of file PAG.cpp.

637{
638 delete icfg;
639 icfg = nullptr;
640 delete chgraph;
641 chgraph = nullptr;
642 delete callGraph;
643 callGraph = nullptr;
644}
CallGraph * callGraph
all the callsites of a program
Definition PAG.h:104

◆ funHasRet()

bool SVF::PAG::funHasRet ( const FunObjVar * func) const
inline

Definition at line 430 of file PAG.h.

431 {
432 return funRetMap.find(func) != funRetMap.end();
433 }

◆ getAllFieldsObjVars() [1/2]

NodeBS & PAG::getAllFieldsObjVars ( const BaseObjVar * obj)

Get all fields of an object.

Get all fields object nodes of an object

Definition at line 573 of file PAG.cpp.

574{
575 NodeID base = obj->getId();
576 return memToFieldsMap[base];
577}

◆ getAllFieldsObjVars() [2/2]

NodeBS & PAG::getAllFieldsObjVars ( NodeID id)

Get all fields object nodes of an object

Definition at line 582 of file PAG.cpp.

583{
584 const SVFVar* node = pag->getSVFVar(id);
585 (void)node; // Suppress warning of unused variable under release build
586 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
588}
NodeBS & getAllFieldsObjVars(const BaseObjVar *obj)
Get all fields of an object.
Definition PAG.cpp:573

◆ getAllValidPtrs()

OrderedNodeSet & SVF::PAG::getAllValidPtrs ( )
inline

Return valid pointers.

Definition at line 209 of file PAG.h.

210 {
211 return candidatePointers;
212 }
OrderedNodeSet candidatePointers
Definition PAG.h:100

◆ getBaseObject()

const BaseObjVar * SVF::PAG::getBaseObject ( NodeID id) const
inline

Get memory object - Return memory object according to pag node id return whole allocated memory object if this node is a gep obj node return nullptr is this node is not a ObjVar type

Definition at line 499 of file PAG.h.

500 {
501 const SVFVar* node = getSVFVar(id);
502 if(const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(node))
504 getSVFVar(gepObjVar->getBaseNode()));
505 else
507 }
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
Definition PAG.h:136
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

◆ getBaseObjVar()

const BaseObjVar * SVF::PAG::getBaseObjVar ( NodeID id) const
inline

Definition at line 160 of file PAG.h.

161 {
162 if(const SVFVar* var = getSVFVar(id))
164 else
165 {
166 assert(false && "the Node is not a BaseObjVar");
167 return nullptr;
168 }
169 }

◆ getBaseObjVarID()

NodeID SVF::PAG::getBaseObjVarID ( NodeID id) const
inline

Base and Offset methods for Value and Object node.

Get a base pointer node given a field pointer

Definition at line 554 of file PAG.h.

555 {
556 return getBaseObject(id)->getId();
557 }

◆ getBaseValVar()

const ValVar * SVF::PAG::getBaseValVar ( NodeID id) const
inline

Definition at line 509 of file PAG.h.

510 {
511 const SVFVar* node = getSVFVar(id);
512 if(const GepValVar* gepVar = SVFUtil::dyn_cast<GepValVar>(node))
513 return gepVar->getBaseNode();
514 else
515 return SVFUtil::dyn_cast<ValVar>(node);
516 }

◆ getCallGraph()

const CallGraph * SVF::PAG::getCallGraph ( )
inline

Get CG.

Definition at line 249 of file PAG.h.

250 {
251 assert(callGraph && "empty CallGraph! Build PAG first!");
252 return callGraph;
253 }

◆ getCallPEForFormalParm()

CallPE * SVF::PAG::getCallPEForFormalParm ( const SVFVar * param) const
inline

Get the CallPE for a formal parameter (phi-like, nullptr if not found).

Definition at line 362 of file PAG.h.

363 {
364 auto it = fParmToCallPEMap.find(param);
365 return it != fParmToCallPEMap.end() ? it->second : nullptr;
366 }

◆ getCallSiteArgsList()

const ValVarList & SVF::PAG::getCallSiteArgsList ( const CallICFGNode * cs) const
inline

Get callsite argument list.

Definition at line 396 of file PAG.h.

397 {
398 CSToArgsListMap::const_iterator it = callSiteArgsListMap.find(cs);
399 assert(it != callSiteArgsListMap.end() && "this call site doesn't have arguments");
400 return it->second;
401 }

◆ getCallSiteArgsMap()

CSToArgsListMap & SVF::PAG::getCallSiteArgsMap ( )
inline

Get callsite argument list.

Definition at line 391 of file PAG.h.

392 {
393 return callSiteArgsListMap;
394 }

◆ getCallSiteRet()

const ValVar * SVF::PAG::getCallSiteRet ( const RetICFGNode * cs) const
inline

Get callsite return.

Definition at line 408 of file PAG.h.

409 {
410 CSToRetMap::const_iterator it = callSiteRetMap.find(cs);
411 assert(it != callSiteRetMap.end() && "this call site doesn't have return");
412 return it->second;
413 }

◆ getCallSiteRets()

CSToRetMap & SVF::PAG::getCallSiteRets ( )
inline

Get callsite return.

Definition at line 403 of file PAG.h.

404 {
405 return callSiteRetMap;
406 }

◆ getCallSiteSet()

const CallSiteSet & SVF::PAG::getCallSiteSet ( ) const
inline

Get all callsites.

Definition at line 352 of file PAG.h.

353 {
354 return callSiteSet;
355 }

◆ getCHG()

CommonCHGraph * SVF::PAG::getCHG ( )
inline

Definition at line 242 of file PAG.h.

243 {
244 assert(chgraph && "empty ICFG! Build PAG first!");
245 return chgraph;
246 }

◆ getFieldObjNodeNum()

u32_t SVF::PAG::getFieldObjNodeNum ( ) const
inline

Definition at line 442 of file PAG.h.

443 {
444 return GepObjVarMap.size();
445 }

◆ getFieldsAfterCollapse()

NodeBS PAG::getFieldsAfterCollapse ( NodeID id)

Get all fields object nodes of an object If this object is collapsed into one field insensitive object Then only return this field insensitive object

Definition at line 595 of file PAG.cpp.

596{
597 const SVFVar* node = pag->getSVFVar(id);
598 (void)node; // Suppress warning of unused variable under release build
599 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
600 const BaseObjVar* obj = getBaseObject(id);
601 if(obj->isFieldInsensitive())
602 {
603 NodeBS bs;
604 bs.set(getFIObjVar(obj));
605 return bs;
606 }
607 else
608 return getAllFieldsObjVars(obj);
609}
bool isFieldInsensitive() const
Return true if its field limit is 0.
NodeID getFIObjVar(const BaseObjVar *obj) const
Get a field-insensitive obj PAG node according to a mem obj.
Definition PAG.h:525
void set(unsigned Idx)
SparseBitVector NodeBS
Definition GeneralType.h:82

◆ getFieldValNodeNum()

u32_t SVF::PAG::getFieldValNodeNum ( ) const
inline

Node and edge statistics.

Definition at line 438 of file PAG.h.

439 {
440 return GepValObjMap.size();
441 }

◆ getFIObjVar() [1/2]

NodeID SVF::PAG::getFIObjVar ( const BaseObjVar * obj) const
inline

Get a field-insensitive obj PAG node according to a mem obj.

Definition at line 525 of file PAG.h.

526 {
527 return obj->getId();
528 }

◆ getFIObjVar() [2/2]

NodeID SVF::PAG::getFIObjVar ( NodeID id) const
inline

Definition at line 529 of file PAG.h.

530 {
531 return getBaseObjVarID(id);
532 }
NodeID getBaseObjVarID(NodeID id) const
Base and Offset methods for Value and Object node.
Definition PAG.h:554

◆ getFunArgsList()

const ValVarList & SVF::PAG::getFunArgsList ( const FunObjVar * func) const
inline

Get function arguments list.

Definition at line 379 of file PAG.h.

380 {
381 FunToArgsListMap::const_iterator it = funArgsListMap.find(func);
382 assert(it != funArgsListMap.end() && "this function doesn't have arguments");
383 return it->second;
384 }

◆ getFunArgsMap()

FunToArgsListMap & SVF::PAG::getFunArgsMap ( )
inline

Get function arguments list.

Definition at line 374 of file PAG.h.

375 {
376 return funArgsListMap;
377 }

◆ getFunObjVar()

const FunObjVar * PAG::getFunObjVar ( const std::string & name)

Definition at line 48 of file PAG.cpp.

49{
50 for (const auto &item: *callGraph)
51 {
52 if (item.second->getName() == name)
53 {
54 return item.second->getFunction();
55 }
56 }
57 return nullptr;
58}
const char *const name
Definition cJSON.h:264
cJSON * item
Definition cJSON.h:222

◆ getFunPtr()

NodeID SVF::PAG::getFunPtr ( const CallICFGNode * cs) const
inline

Definition at line 458 of file PAG.h.

459 {
460 CallSiteToFunPtrMap::const_iterator it = indCallSiteToFunPtrMap.find(cs);
461 assert(it!=indCallSiteToFunPtrMap.end() && "indirect callsite not have a function pointer?");
462 return it->second;
463 }

◆ getFunRet()

const ValVar * SVF::PAG::getFunRet ( const FunObjVar * func) const
inline

Get function return list.

Definition at line 424 of file PAG.h.

425 {
426 FunToRetMap::const_iterator it = funRetMap.find(func);
427 assert(it != funRetMap.end() && "this function doesn't have return");
428 return it->second;
429 }

◆ getFunRets()

FunToRetMap & SVF::PAG::getFunRets ( )
inline

Get function return list.

Definition at line 419 of file PAG.h.

420 {
421 return funRetMap;
422 }

◆ getGepObjNodeMap()

OffsetToGepVarMap & SVF::PAG::getGepObjNodeMap ( )
inline

Return GepObjVarMap.

Definition at line 204 of file PAG.h.

205 {
206 return GepObjVarMap;
207 }

◆ getGepObjVar() [1/3]

NodeID PAG::getGepObjVar ( const BaseObjVar * baseObj,
const APOffset & apOffset )

Get a field PAG Object node according to base mem obj and offset.

Get a field obj PAG node according to base mem obj and offset To support flexible field sensitive analysis with regard to MaxFieldOffset offset = offset % obj->getMaxFieldOffsetLimit() to create limited number of mem objects maximum number of field object creation is obj->getMaxFieldOffsetLimit()

if this obj is field-insensitive, just return the field-insensitive node.

Definition at line 523 of file PAG.cpp.

524{
525 NodeID base = baseObj->getId();
526
528 if (baseObj->isFieldInsensitive())
529 return getFIObjVar(baseObj);
530
531 APOffset newLS = pag->getModulusOffset(baseObj, apOffset);
532
533 // Base and first field are the same memory location.
534 if (Options::FirstFieldEqBase() && newLS == 0) return base;
535
536 OffsetToGepVarMap::iterator iter = GepObjVarMap.find(std::make_pair(base, newLS));
537 if (iter == GepObjVarMap.end())
538 {
540 return addGepObjNode(baseObj, newLS, gepId);
541 }
542 else
543 return iter->second;
544
545}
NodeID allocateGepObjectId(NodeID base, u32_t offset, u32_t maxFieldLimit)
static const Option< bool > FirstFieldEqBase
Definition Options.h:100
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
Definition Options.h:34
s64_t APOffset
Definition GeneralType.h:80

◆ getGepObjVar() [2/3]

const GepObjVar * SVF::PAG::getGepObjVar ( NodeID id) const
inline

Definition at line 170 of file PAG.h.

171 {
172 if(const SVFVar* var = getSVFVar(id))
174 else
175 {
176 assert(false && "the Node is not a GepObjVar");
177 return nullptr;
178 }
179 }

◆ getGepObjVar() [3/3]

NodeID PAG::getGepObjVar ( NodeID id,
const APOffset & apOffset )

Get a field obj PAG node according to a mem obj and a given offset.

Given an object node, find its field object node

Definition at line 501 of file PAG.cpp.

502{
503 const SVFVar* node = pag->getSVFVar(id);
504 if (const GepObjVar* gepNode = SVFUtil::dyn_cast<GepObjVar>(node))
505 return getGepObjVar(gepNode->getBaseObj(), gepNode->getConstantFieldIdx() + apOffset);
506 else if (const BaseObjVar* baseNode = SVFUtil::dyn_cast<BaseObjVar>(node))
507 return getGepObjVar(baseNode, apOffset);
508 else if (const DummyObjVar* baseNode = SVFUtil::dyn_cast<DummyObjVar>(node))
509 return getGepObjVar(baseNode, apOffset);
510 else
511 {
512 assert(false && "new gep obj node kind?");
513 return id;
514 }
515}
const GepObjVar * getGepObjVar(NodeID id) const
Definition PAG.h:170

◆ getGepValVar()

NodeID PAG::getGepValVar ( NodeID curInst,
NodeID base,
const AccessPath & ap ) const

Due to constraint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar.

It is used to create a dummy GepValVar during global initialization.

Definition at line 614 of file PAG.cpp.

615{
616 GepValueVarMap::const_iterator iter = GepValObjMap.find(curInst);
617 if(iter==GepValObjMap.end())
618 {
619 return UINT_MAX;
620 }
621 else
622 {
623 NodeAccessPathMap::const_iterator lit =
624 iter->second.find(std::make_pair(base, ap));
625 if (lit == iter->second.end())
626 return UINT_MAX;
627 else
628 return lit->second;
629 }
630}

◆ getGlobalSVFStmtSet()

SVFStmtSet & SVF::PAG::getGlobalSVFStmtSet ( )
inline

Get global PAGEdges (not in a procedure).

Definition at line 347 of file PAG.h.

348 {
349 return globSVFStmtSet;
350 }

◆ getICFG()

ICFG * SVF::PAG::getICFG ( ) const
inline

Definition at line 232 of file PAG.h.

233 {
234 assert(icfg->totalICFGNode>0 && "empty ICFG! Build PAG first!");
235 return icfg;
236 }

◆ getIndCallSites()

const CallSiteSet & SVF::PAG::getIndCallSites ( NodeID funPtr) const
inline

Definition at line 464 of file PAG.h.

465 {
466 FunPtrToCallSitesMap::const_iterator it = funPtrToCallSitesMap.find(funPtr);
467 assert(it!=funPtrToCallSitesMap.end() && "function pointer not used at any indirect callsite?");
468 return it->second;
469 }

◆ getIndirectCallsites()

const CallSiteToFunPtrMap & SVF::PAG::getIndirectCallsites ( ) const
inline

Add/get indirect callsites.

Definition at line 454 of file PAG.h.

455 {
457 }

◆ getIntraPAGEdge() [1/2]

SVFStmt * SVF::PAG::getIntraPAGEdge ( NodeID src,
NodeID dst,
SVFStmt::PEDGEK kind )
inline

Get an edge according to src, dst and kind.

Definition at line 481 of file PAG.h.

482 {
483 return getIntraPAGEdge(getGNode(src), getGNode(dst), kind);
484 }
SVFStmt * getIntraPAGEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind)
Get an edge according to src, dst and kind.
Definition PAG.h:481

◆ getIntraPAGEdge() [2/2]

SVFStmt * SVF::PAG::getIntraPAGEdge ( SVFVar * src,
SVFVar * dst,
SVFStmt::PEDGEK kind )
inline

Definition at line 485 of file PAG.h.

486 {
487 SVFStmt edge(src, dst, kind, false);
488 const SVFStmt::SVFStmtSetTy& edgeSet = getSVFStmtSet(kind);
489 SVFStmt::SVFStmtSetTy::const_iterator it = edgeSet.find(&edge);
490 assert(it != edgeSet.end() && "can not find pag edge");
491 return (*it);
492 }
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition PAG.h:299
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy

◆ getMemToFieldsMap()

MemObjToFieldsMap & SVF::PAG::getMemToFieldsMap ( )
inline

Return memToFieldsMap.

Definition at line 199 of file PAG.h.

200 {
201 return memToFieldsMap;
202 }

◆ getModuleIdentifier()

const std::string & SVF::PAG::getModuleIdentifier ( ) const
inline

Definition at line 262 of file PAG.h.

263 {
264 if (pagReadFromTxt.empty())
265 {
266 assert(!moduleIdentifier.empty() &&
267 "No module found! Reading from a file other than LLVM-IR?");
268 return moduleIdentifier;
269 }
270 else
271 {
272 return pagReadFromTxt;
273 }
274 }
static std::string pagReadFromTxt
Definition PAG.h:107
std::string moduleIdentifier
Definition PAG.h:109

◆ getObjVar()

const ObjVar * SVF::PAG::getObjVar ( NodeID id) const
inline

Definition at line 150 of file PAG.h.

151 {
152 if(const SVFVar* var = getSVFVar(id))
153 return SVFUtil::dyn_cast<ObjVar>(var);
154 else
155 {
156 assert(false && "the Node is not an ObjVar");
157 return nullptr;
158 }
159 }

◆ getPAG()

PAG * SVF::PAG::getPAG ( bool buildFromFile = false)
inlinestatic

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

Definition at line 121 of file PAG.h.

122 {
123 if (pag == nullptr)
124 {
125 pag = std::unique_ptr<PAG>(new PAG(buildFromFile));
126 }
127 return pag.get();
128 }
PAG(bool buildFromFile)
Constructor.
Definition PAG.cpp:43

◆ getPTASVFStmtList()

SVFStmtList & SVF::PAG::getPTASVFStmtList ( const ICFGNode * inst)
inline

Given an instruction, get all its PTA PAGEdges.

Definition at line 324 of file PAG.h.

325 {
326 return icfgNode2PTASVFStmtsMap[inst];
327 }

◆ getPTASVFStmtSet()

SVFStmt::SVFStmtSetTy & SVF::PAG::getPTASVFStmtSet ( SVFStmt::PEDGEK kind)
inline

Get PTA edges set according to its kind.

Definition at line 304 of file PAG.h.

305 {
306 return KindToPTASVFStmtSetMap[kind];
307 }

◆ getSVFStmtList()

SVFStmtList & SVF::PAG::getSVFStmtList ( const ICFGNode * inst)
inline

Given an instruction, get all its PAGEdges.

Definition at line 319 of file PAG.h.

320 {
321 return icfgNode2SVFStmtsMap[inst];
322 }

◆ getSVFStmtSet()

SVFStmt::SVFStmtSetTy & SVF::PAG::getSVFStmtSet ( SVFStmt::PEDGEK kind)
inline

Get/set methods to get SVFStmts based on their kinds and ICFGNodes.

Get edges set according to its kind

Definition at line 299 of file PAG.h.

300 {
301 return KindToSVFStmtSetMap[kind];
302 }

◆ getSVFVar()

const SVFVar * SVF::PAG::getSVFVar ( NodeID id) const
inline

ObjVar/GepObjVar/BaseObjVar.

Definition at line 136 of file PAG.h.

137 {
138 return getGNode(id);
139 }

◆ getSVFVarMap()

const IDToNodeMapTy & SVF::PAG::getSVFVarMap ( ) const
inline

Return the entire SVFID to SVFVar map.

Definition at line 193 of file PAG.h.

194 {
195 return IDToNodeMap;
196 }

◆ getTypeLocSetsMap()

SVFTypeLocSetsPair & SVF::PAG::getTypeLocSetsMap ( NodeID argId)
inline

Given an arg NodeId, get its base SVFType* and all its field location sets.

Definition at line 342 of file PAG.h.

343 {
344 return typeLocSetsMap[argId];
345 }

◆ getValVar()

const ValVar * SVF::PAG::getValVar ( NodeID id) const
inline

Definition at line 140 of file PAG.h.

141 {
142 if(const SVFVar* var = getSVFVar(id))
143 return SVFUtil::dyn_cast<ValVar>(var);
144 else
145 {
146 assert(false && "the Node is not a ValVar");
147 return nullptr;
148 }
149 }

◆ handleBlackHole()

void PAG::handleBlackHole ( bool b)
static

PAG build configurations.

Whether to handle blackhole edge

Definition at line 782 of file PAG.cpp.

783{
785}
const cJSON *const b
Definition cJSON.h:255
void setValue(T v)

◆ hasCallSiteArgsMap()

bool SVF::PAG::hasCallSiteArgsMap ( const CallICFGNode * cs) const
inline

Callsite has argument list.

Definition at line 386 of file PAG.h.

387 {
388 return (callSiteArgsListMap.find(cs) != callSiteArgsListMap.end());
389 }

◆ hasFunArgsList()

bool SVF::PAG::hasFunArgsList ( const FunObjVar * func) const
inline

Function has arguments list.

Definition at line 369 of file PAG.h.

370 {
371 return (funArgsListMap.find(func) != funArgsListMap.end());
372 }

◆ hasPTASVFStmtList()

bool SVF::PAG::hasPTASVFStmtList ( const ICFGNode * inst) const
inline

Definition at line 313 of file PAG.h.

314 {
315 return icfgNode2PTASVFStmtsMap.find(inst) !=
317 }

◆ hasSVFStmtList()

bool SVF::PAG::hasSVFStmtList ( const ICFGNode * inst) const
inline

Whether this instruction has PAG Edge.

Definition at line 309 of file PAG.h.

310 {
311 return icfgNode2SVFStmtsMap.find(inst) != icfgNode2SVFStmtsMap.end();
312 }

◆ initialiseCandidatePointers()

void PAG::initialiseCandidatePointers ( )

Initialize candidate pointers.

Definition at line 734 of file PAG.cpp.

735{
736 // collect candidate pointers for demand-driven analysis
737 for (iterator nIter = begin(); nIter != end(); ++nIter)
738 {
739 NodeID nodeId = nIter->first;
740 // do not compute points-to for isolated node
741 if (isValidPointer(nodeId) == false)
742 continue;
743 candidatePointers.insert(nodeId);
744 }
745}
IDToNodeMapTy::iterator iterator
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Definition PAG.cpp:750

◆ isBaseObjVar()

bool SVF::PAG::isBaseObjVar ( NodeID id) const
inline

Definition at line 184 of file PAG.h.

185 {
187 }

◆ isBlkObjOrConstantObj()

bool SVF::PAG::isBlkObjOrConstantObj ( NodeID id) const
inline

Get black hole and constant id.

Definition at line 538 of file PAG.h.

539 {
540 return (isBlkObj(id) || isConstantObj(id));
541 }
static bool isBlkObj(NodeID id)
Definition PAGBase.h:163
bool isConstantObj(NodeID id) const
Definition PAG.h:545

◆ isConstantObj()

bool SVF::PAG::isConstantObj ( NodeID id) const
inline

Answered from a set filled in addObjNode, so the solvers' per-object test does not look the node up in the node map.

Definition at line 545 of file PAG.h.

546 {
547 return constantObjs.find(id) != constantObjs.end();
548 }

◆ isFunPtr()

bool SVF::PAG::isFunPtr ( NodeID id) const
inline

Definition at line 474 of file PAG.h.

475 {
476 return (funPtrToCallSitesMap.find(id) != funPtrToCallSitesMap.end());
477 }

◆ isGepObjVar()

bool SVF::PAG::isGepObjVar ( NodeID id) const
inline

Definition at line 188 of file PAG.h.

189 {
191 }

◆ isIndirectCallSites()

bool SVF::PAG::isIndirectCallSites ( const CallICFGNode * cs) const
inline

Definition at line 470 of file PAG.h.

471 {
472 return (indCallSiteToFunPtrMap.find(cs) != indCallSiteToFunPtrMap.end());
473 }

◆ isObjVar()

bool SVF::PAG::isObjVar ( NodeID id) const
inline

Definition at line 180 of file PAG.h.

181 {
183 }

◆ isPhiNode()

bool SVF::PAG::isPhiNode ( const SVFVar * node) const
inline

Whether this SVFVar is a result operand a of phi node.

Definition at line 357 of file PAG.h.

358 {
359 return phiNodeMap.find(node) != phiNodeMap.end();
360 }

◆ isValidPointer()

bool PAG::isValidPointer ( NodeID nodeId) const

Whether a node is a valid pointer.

Definition at line 750 of file PAG.cpp.

751{
752 const SVFVar* node = pag->getSVFVar(nodeId);
753
754 if(node->isPointer())
755 if (const ValVar* pVar = pag->getBaseValVar(nodeId))
756 if (const ArgValVar* arg = SVFUtil::dyn_cast<ArgValVar>(pVar))
757 if (!(arg->getParent()->isDeclaration()))
758 return true;
759
760 if ((node->getInEdges().empty() && node->getOutEdges().empty()))
761 return false;
762 return node->isPointer();
763}
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
virtual bool isPointer() const
Check if this variable represents a pointer.

◆ isValidTopLevelPtr()

bool PAG::isValidTopLevelPtr ( const SVFVar * node)

Definition at line 765 of file PAG.cpp.

766{
767 if (SVFUtil::isa<ValVar>(node))
768 {
769 if (isValidPointer(node->getId()))
770 {
771 const ValVar* baseVar = pag->getBaseValVar(node->getId());
773 return !SVFUtil::isArgOfUncalledFunction(baseVar);
774 }
775 }
776 return false;
777}
bool isArgOfUncalledFunction(const SVFVar *svfvar)
Definition SVFUtil.cpp:509

◆ pagFileName()

std::string SVF::PAG::pagFileName ( )
inlinestatic

Definition at line 276 of file PAG.h.

277 {
278 return pagReadFromTxt;
279 }

◆ pagReadFromTXT()

bool SVF::PAG::pagReadFromTXT ( )
inlinestatic

Definition at line 281 of file PAG.h.

282 {
283 return !pagReadFromTxt.empty();
284 }

◆ print()

void PAG::print ( )

Print PAG.

Print this PAG graph including its nodes and edges

Definition at line 649 of file PAG.cpp.

650{
651
652 outs() << "-------------------PAG------------------------------------\n";
653 SVFStmt::SVFStmtSetTy& addrs = pag->getSVFStmtSet(SVFStmt::Addr);
654 for (SVFStmt::SVFStmtSetTy::iterator iter = addrs.begin(), eiter =
655 addrs.end(); iter != eiter; ++iter)
656 {
657 outs() << (*iter)->getSrcID() << " -- Addr --> " << (*iter)->getDstID()
658 << "\n";
659 }
660
661 SVFStmt::SVFStmtSetTy& copys = pag->getSVFStmtSet(SVFStmt::Copy);
662 for (SVFStmt::SVFStmtSetTy::iterator iter = copys.begin(), eiter =
663 copys.end(); iter != eiter; ++iter)
664 {
665 outs() << (*iter)->getSrcID() << " -- Copy --> " << (*iter)->getDstID()
666 << "\n";
667 }
668
669 SVFStmt::SVFStmtSetTy& calls = pag->getSVFStmtSet(SVFStmt::Call);
670 for (SVFStmt::SVFStmtSetTy::iterator iter = calls.begin(), eiter =
671 calls.end(); iter != eiter; ++iter)
672 {
673 outs() << (*iter)->getSrcID() << " -- Call --> " << (*iter)->getDstID()
674 << "\n";
675 }
676
677 SVFStmt::SVFStmtSetTy& rets = pag->getSVFStmtSet(SVFStmt::Ret);
678 for (SVFStmt::SVFStmtSetTy::iterator iter = rets.begin(), eiter =
679 rets.end(); iter != eiter; ++iter)
680 {
681 outs() << (*iter)->getSrcID() << " -- Ret --> " << (*iter)->getDstID()
682 << "\n";
683 }
684
685 SVFStmt::SVFStmtSetTy& tdfks = pag->getSVFStmtSet(SVFStmt::ThreadFork);
686 for (SVFStmt::SVFStmtSetTy::iterator iter = tdfks.begin(), eiter =
687 tdfks.end(); iter != eiter; ++iter)
688 {
689 outs() << (*iter)->getSrcID() << " -- ThreadFork --> "
690 << (*iter)->getDstID() << "\n";
691 }
692
693 SVFStmt::SVFStmtSetTy& tdjns = pag->getSVFStmtSet(SVFStmt::ThreadJoin);
694 for (SVFStmt::SVFStmtSetTy::iterator iter = tdjns.begin(), eiter =
695 tdjns.end(); iter != eiter; ++iter)
696 {
697 outs() << (*iter)->getSrcID() << " -- ThreadJoin --> "
698 << (*iter)->getDstID() << "\n";
699 }
700
701 SVFStmt::SVFStmtSetTy& ngeps = pag->getSVFStmtSet(SVFStmt::Gep);
702 for (SVFStmt::SVFStmtSetTy::iterator iter = ngeps.begin(), eiter =
703 ngeps.end(); iter != eiter; ++iter)
704 {
705 GepStmt* gep = SVFUtil::cast<GepStmt>(*iter);
706 if(gep->isVariantFieldGep())
707 outs() << (*iter)->getSrcID() << " -- VariantGep --> "
708 << (*iter)->getDstID() << "\n";
709 else
710 outs() << gep->getRHSVarID() << " -- Gep (" << gep->getConstantStructFldIdx()
711 << ") --> " << gep->getLHSVarID() << "\n";
712 }
713
714 SVFStmt::SVFStmtSetTy& loads = pag->getSVFStmtSet(SVFStmt::Load);
715 for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
716 loads.end(); iter != eiter; ++iter)
717 {
718 outs() << (*iter)->getSrcID() << " -- Load --> " << (*iter)->getDstID()
719 << "\n";
720 }
721
722 SVFStmt::SVFStmtSetTy& stores = pag->getSVFStmtSet(SVFStmt::Store);
723 for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
724 stores.end(); iter != eiter; ++iter)
725 {
726 outs() << (*iter)->getSrcID() << " -- Store --> " << (*iter)->getDstID()
727 << "\n";
728 }
729 outs() << "----------------------------------------------------------\n";
730
731}
bool isVariantFieldGep() const
Gep statement with a variant field index (pointer arithmetic) for struct field access.
APOffset getConstantStructFldIdx() const
Field index of the gep statement if it access the field of a struct.
std::ostream & outs()
Overwrite llvm::outs().
Definition SVFUtil.h:58

◆ releasePAG()

void SVF::PAG::releasePAG ( )
inlinestatic

Definition at line 129 of file PAG.h.

130 {
131 pag = nullptr;
132 }

◆ setCallGraph()

void SVF::PAG::setCallGraph ( CallGraph * cg)
inline

Definition at line 255 of file PAG.h.

256 {
257 callGraph = cg;
258 }

◆ setCHG()

void SVF::PAG::setCHG ( CommonCHGraph * c)
inline

Set/Get CHG.

Definition at line 238 of file PAG.h.

239 {
240 chgraph = c;
241 }

◆ setICFG()

void SVF::PAG::setICFG ( ICFG * i)
inline

Set/Get ICFG.

Definition at line 228 of file PAG.h.

229 {
230 icfg = i;
231 }

◆ setModuleIdentifier()

void SVF::PAG::setModuleIdentifier ( const std::string & moduleIdentifier)
inline

Definition at line 291 of file PAG.h.

292 {
294 }

◆ setPagFromTXT()

void SVF::PAG::setPagFromTXT ( const std::string & txt)
inlinestatic

Definition at line 286 of file PAG.h.

287 {
288 pagReadFromTxt = txt;
289 }

◆ BVDataPTAImpl

friend class BVDataPTAImpl
friend

Definition at line 50 of file PAG.h.

◆ ExternalPAG

friend class ExternalPAG
friend

Definition at line 48 of file PAG.h.

◆ GraphDBClient

friend class GraphDBClient
friend

Definition at line 51 of file PAG.h.

◆ GraphDBSVFIRBuilder

friend class GraphDBSVFIRBuilder
friend

Definition at line 52 of file PAG.h.

◆ PAGBuilder

friend class PAGBuilder
friend

Definition at line 47 of file PAG.h.

◆ PAGBuilderFromFile

friend class PAGBuilderFromFile
friend

Definition at line 49 of file PAG.h.

Member Data Documentation

◆ callGraph

CallGraph* SVF::PAG::callGraph
private

all the callsites of a program

Definition at line 104 of file PAG.h.

◆ callSiteArgsListMap

CSToArgsListMap SVF::PAG::callSiteArgsListMap
private

Map a callsite to a list of all its actual parameters.

Definition at line 93 of file PAG.h.

◆ callSiteRetMap

CSToRetMap SVF::PAG::callSiteRetMap
private

Map a callsite to its callsite returns PAGNodes.

Definition at line 94 of file PAG.h.

◆ callSiteSet

CallSiteSet SVF::PAG::callSiteSet
private

Definition at line 103 of file PAG.h.

◆ candidatePointers

OrderedNodeSet SVF::PAG::candidatePointers
private

Valid pointers for pointer analysis resolution connected by PAG edges (constraints) this set of candidate pointers can change during pointer resolution (e.g. adding new object nodes)

Definition at line 100 of file PAG.h.

◆ chgraph

CommonCHGraph* SVF::PAG::chgraph
private

Definition at line 102 of file PAG.h.

◆ constantObjs

NodeSet SVF::PAG::constantObjs
private

Constant objects and their fields, recorded when each object node is added.

Definition at line 88 of file PAG.h.

◆ fParmToCallPEMap

FParmToCallPEMap SVF::PAG::fParmToCallPEMap
private

Map a formal param to its CallPE.

Definition at line 91 of file PAG.h.

◆ funArgsListMap

FunToArgsListMap SVF::PAG::funArgsListMap
private

Map a function to a list of all its formal parameters.

Definition at line 92 of file PAG.h.

◆ funPtrToCallSitesMap

FunPtrToCallSitesMap SVF::PAG::funPtrToCallSitesMap
private

Map a function pointer to the callsites where it is used

Definition at line 97 of file PAG.h.

◆ funRetMap

FunToRetMap SVF::PAG::funRetMap
private

Map a function to its unique function return PAGNodes.

Definition at line 95 of file PAG.h.

◆ GepObjVarMap

OffsetToGepVarMap SVF::PAG::GepObjVarMap
private

Map a pair<base,off> to a gep obj node id.

Definition at line 86 of file PAG.h.

◆ GepValObjMap

GepValueVarMap SVF::PAG::GepValObjMap
private

Map a pair<base,off> to a gep value node id.

Definition at line 84 of file PAG.h.

◆ globSVFStmtSet

SVFStmtSet SVF::PAG::globSVFStmtSet
private

Global PAGEdges without control flow information.

Definition at line 89 of file PAG.h.

◆ icfg

ICFG* SVF::PAG::icfg
private

Definition at line 101 of file PAG.h.

◆ icfgNode2PTASVFStmtsMap

ICFGNode2SVFStmtsMap SVF::PAG::icfgNode2PTASVFStmtsMap
private

Map an ICFGNode to its PointerAnalysis related SVFStmts.

Definition at line 83 of file PAG.h.

◆ icfgNode2SVFStmtsMap

ICFGNode2SVFStmtsMap SVF::PAG::icfgNode2SVFStmtsMap
private

Map an ICFGNode to its SVFStmts.

ValueNodes - This map indicates the Node that a particular SVFValue* is represented by. This contains entries for all pointers.

Definition at line 82 of file PAG.h.

◆ indCallSiteToFunPtrMap

CallSiteToFunPtrMap SVF::PAG::indCallSiteToFunPtrMap
private

Map an indirect callsite to its function pointer.

Definition at line 96 of file PAG.h.

◆ memToFieldsMap

MemObjToFieldsMap SVF::PAG::memToFieldsMap
private

Map a mem object id to all its fields.

Definition at line 87 of file PAG.h.

◆ moduleIdentifier

std::string SVF::PAG::moduleIdentifier
private

Definition at line 109 of file PAG.h.

◆ pag

std::unique_ptr< PAG > PAG::pag
staticprivate

Callgraph with direct calls only; no change allowed after init and use callgraph in PointerAnalysis for indirect calls).

Singleton pattern here to enable instance of PAG can only be created once.

Definition at line 106 of file PAG.h.

◆ pagReadFromTxt

std::string PAG::pagReadFromTxt = ""
staticprivate

Definition at line 107 of file PAG.h.

◆ phiNodeMap

PHINodeMap SVF::PAG::phiNodeMap
private

A set of phi copy edges.

Definition at line 90 of file PAG.h.

◆ typeLocSetsMap

TypeLocSetsMap SVF::PAG::typeLocSetsMap
private

Map an arg to its base SVFType* and all its field location sets.

Definition at line 85 of file PAG.h.


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