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

#include <SVFIR.h>

Inheritance diagram for SVF::SVFIR:
SVF::IRGraph 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::IRGraph
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 ~SVFIR ()
 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 SVFIR 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 SVFIR Object node according to base mem obj and offset.
 
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 Get a field obj SVFIR node according to a mem obj and a given offset.
 
NodeID getFIObjVar (const BaseObjVar *obj) const
 Get a field-insensitive obj SVFIR 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 SVFIR.
 
- Public Member Functions inherited from SVF::IRGraph
 IRGraph (bool buildFromFile)
 
virtual ~IRGraph ()
 
bool isBuiltFromFile ()
 Whether this SVFIR built from a txt file.
 
NodeID blkPtrSymID () const
 
NodeID nullPtrSymID () const
 
NodeID constantSymID () const
 
NodeID blackholeSymID () const
 
u32_t getTotalSymNum () const
 Statistics.
 
u32_t getMaxStructSize () const
 
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 SVFIR.
 
void view ()
 View graph from the debugger.
 
void addTypeInfo (const SVFType *ty)
 
void addStInfo (StInfo *stInfo)
 
- Public Member Functions inherited from SVF::GenericGraph< SVFVar, SVFStmt >
 GenericGraph ()
 Constructor.
 
virtual ~GenericGraph ()
 Destructor.
 
void destroy ()
 Release memory.
 
iterator begin ()
 Iterators.
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node.
 
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 SVFIR * getPAG (bool buildFromFile=false)
 Singleton design here to make sure we only have one instance during any analysis.
 
static void releaseSVFIR ()
 
static void handleBlackHole (bool b)
 SVFIR build configurations.
 
static std::string pagFileName ()
 
static bool pagReadFromTXT ()
 
static void setPagFromTXT (const std::string &txt)
 
- Static Public Member Functions inherited from SVF::IRGraph
static bool isBlkPtr (NodeID id)
 special value
 
static bool isNullPtr (NodeID id)
 
static bool isBlkObj (NodeID id)
 
static bool isConstantSym (NodeID id)
 
static bool isBlkObjOrConstantObj (NodeID id)
 

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::IRGraph
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

 SVFIR (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 SVFIR
 
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 SVFIR.
 
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< SVFIR > 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 SVFIRBuilder
 
class ExternalPAG
 
class PAGBuilderFromFile
 
class BVDataPTAImpl
 
class GraphDBClient
 
class GraphDBSVFIRBuilder
 

Additional Inherited Members

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

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 SVFIR.h.

Member Typedef Documentation

◆ CallSiteSet

Definition at line 55 of file SVFIR.h.

◆ CallSiteToFunPtrMap

Definition at line 56 of file SVFIR.h.

◆ CSToArgsListMap

Definition at line 64 of file SVFIR.h.

◆ CSToRetMap

Definition at line 65 of file SVFIR.h.

◆ FParmToCallPEMap

Definition at line 62 of file SVFIR.h.

◆ FunPtrToCallSitesMap

Definition at line 57 of file SVFIR.h.

◆ FunToArgsListMap

Definition at line 63 of file SVFIR.h.

◆ FunToPAGEdgeSetMap

Definition at line 67 of file SVFIR.h.

◆ FunToRetMap

Definition at line 66 of file SVFIR.h.

◆ GepOffset

Definition at line 70 of file SVFIR.h.

◆ GepValueVarMap

Definition at line 74 of file SVFIR.h.

◆ ICFGNode2SVFStmtsMap

Definition at line 68 of file SVFIR.h.

◆ MemObjToFieldsMap

Definition at line 58 of file SVFIR.h.

◆ NodeAccessPath

Definition at line 71 of file SVFIR.h.

◆ NodeAccessPathMap

Definition at line 73 of file SVFIR.h.

◆ NodePairSetMap

Definition at line 77 of file SVFIR.h.

◆ NodeToNodeMap

Definition at line 69 of file SVFIR.h.

◆ OffsetToGepVarMap

Definition at line 72 of file SVFIR.h.

◆ PHINodeMap

Definition at line 61 of file SVFIR.h.

◆ SVFStmtList

Definition at line 59 of file SVFIR.h.

◆ SVFTypeLocSetsPair

Definition at line 75 of file SVFIR.h.

◆ TypeLocSetsMap

Definition at line 76 of file SVFIR.h.

◆ ValVarList

Definition at line 60 of file SVFIR.h.

Constructor & Destructor Documentation

◆ SVFIR()

SVFIR::SVFIR ( bool  buildFromFile)
private

Constructor.

Definition at line 43 of file SVFIR.cpp.

43 : IRGraph(buildFromFile), icfg(nullptr), chgraph(nullptr)
44{
45}
CommonCHGraph * chgraph
Definition SVFIR.h:102
ICFG * icfg
Definition SVFIR.h:101
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~SVFIR()

virtual SVF::SVFIR::~SVFIR ( )
inlinevirtual

Destructor.

Definition at line 217 of file SVFIR.h.

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

Member Function Documentation

◆ addAddrStmt() [1/2]

void SVFIR::addAddrStmt ( AddrStmt *  edge)
private

Definition at line 77 of file SVFIR.cpp.

78{
80 addEdge(getGNode(edge->getRHSVarID()),getGNode(edge->getLHSVarID()), edge);
81}
NodeType * getGNode(NodeID id) const
Get a node.
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 SVFIR.h:603

◆ addAddrStmt() [2/2]

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

Add an edge into SVFIR.

Add Address edge

Definition at line 64 of file SVFIR.cpp.

65{
66 SVFVar* srcNode = getGNode(src);
67 SVFVar* dstNode = getGNode(dst);
69 return nullptr;
70 else
71 {
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 SVFIR.
Definition SVFIR.cpp:64

◆ addArgValNode()

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

Definition at line 677 of file SVFIR.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 SVFIR
Definition SVFIR.h:665

◆ addAsmPCValNode()

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

Definition at line 843 of file SVFIR.h.

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

◆ addBaseObjNode()

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

Definition at line 585 of file SVFIR.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 SVFIR.h:87
NodeID addObjNode(NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
Add a memory obj node.
Definition SVFIR.h:718

◆ addBinaryOPStmt() [1/2]

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

Definition at line 210 of file SVFIR.cpp.

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

◆ addBinaryOPStmt() [2/2]

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

Add Copy edge.

Add Compare edge

Definition at line 194 of file SVFIR.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));
200 return nullptr;
201 else
202 {
203 std::vector<ValVar*> opnds = {op1Node, op2Node};
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 SVFIR.cpp:194
const ValVar * getValVar(NodeID id) const
Definition SVFIR.h:140

◆ addBlackHoleAddrStmt()

SVFStmt * SVFIR::addBlackHoleAddrStmt ( NodeID  node)
private

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

Add blackhole/constant edge

Definition at line 364 of file SVFIR.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< SVFIR > pag
Callgraph with direct calls only; no change allowed after init and use callgraph in PointerAnalysis f...
Definition SVFIR.h:106

◆ addBlackholeObjNode()

NodeID SVF::SVFIR::addBlackholeObjNode ( )
inlineprivate

Definition at line 827 of file SVFIR.h.

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

◆ addBlackholePtrNode()

NodeID SVF::SVFIR::addBlackholePtrNode ( )
inlineprivate

Definition at line 835 of file SVFIR.h.

836 {
837 return addDummyValNode(getBlkPtr(), nullptr);
838 }
NodeID getBlkPtr() const
Definition IRGraph.h:254
NodeID addDummyValNode()
Definition SVFIR.h:566

◆ addBranchStmt() [1/2]

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

Definition at line 255 of file SVFIR.cpp.

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

◆ addBranchStmt() [2/2]

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

Add BranchStmt.

Definition at line 241 of file SVFIR.cpp.

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

◆ addCallPE() [1/2]

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

Definition at line 331 of file SVFIR.cpp.

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

◆ addCallPE() [2/2]

CallPE * SVFIR::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 SVFIR.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}
void addOpVar(ValVar *op, const CallICFGNode *call)
Add an operand (actual param) from a call site.
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 SVFIR.cpp:311

◆ addCallSite()

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

Add callsites.

Definition at line 870 of file SVFIR.h.

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

◆ addCallSiteArgs()

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

Add callsite arguments.

Definition at line 642 of file SVFIR.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 SVFIR.h:93

◆ addCallSiteRets()

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

Add callsite returns.

Definition at line 648 of file SVFIR.h.

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

◆ addCmpStmt() [1/2]

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

Definition at line 184 of file SVFIR.cpp.

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

◆ addCmpStmt() [2/2]

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

Add Copy edge.

Add Compare edge

Definition at line 168 of file SVFIR.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));
174 return nullptr;
175 else
176 {
177 std::vector<ValVar*> opnds = {op1Node, op2Node};
178 CmpStmt* cmp = new CmpStmt(dstNode, opnds, predicate);
180 return cmp;
181 }
182}
CmpStmt * addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
Add Copy edge.
Definition SVFIR.cpp:168

◆ addConstantDataObjNode()

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

Definition at line 774 of file SVFIR.h.

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

◆ addConstantDataValNode()

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

Definition at line 710 of file SVFIR.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 IRGraph.h:116

◆ addConstantFPObjNode()

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

Definition at line 748 of file SVFIR.h.

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

◆ addConstantFPValNode()

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

Definition at line 684 of file SVFIR.h.

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

◆ addConstantIntObjNode()

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

Definition at line 755 of file SVFIR.h.

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

◆ addConstantIntValNode()

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

Definition at line 691 of file SVFIR.h.

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

◆ addConstantNullPtrObjNode()

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

Definition at line 763 of file SVFIR.h.

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

◆ addConstantNullPtrValNode()

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

Definition at line 698 of file SVFIR.h.

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

◆ addConstantObjNode()

NodeID SVF::SVFIR::addConstantObjNode ( )
inlineprivate

Definition at line 831 of file SVFIR.h.

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

◆ addCopyStmt() [1/2]

void SVFIR::addCopyStmt ( CopyStmt *  edge)
private

Definition at line 100 of file SVFIR.cpp.

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

◆ addCopyStmt() [2/2]

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

Add Copy edge.

Add Copy edge

Definition at line 86 of file SVFIR.cpp.

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

◆ addDummyObjNode() [1/3]

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

Definition at line 570 of file SVFIR.h.

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

◆ addDummyObjNode() [2/3]

NodeID SVFIR::addDummyObjNode ( DummyObjVar *  node)
protected

Definition at line 813 of file SVFIR.cpp.

814{
815 return addObjNode(node);
816}

◆ addDummyObjNode() [3/3]

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

Definition at line 813 of file SVFIR.h.

814 {
815 if (idToObjTypeInfoMap().find(i) == idToObjTypeInfoMap().end())
816 {
817 ObjTypeInfo* ti = createObjTypeInfo(type);
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 IRGraph.h:211

◆ addDummyValNode() [1/2]

NodeID SVF::SVFIR::addDummyValNode ( )
inline

Definition at line 566 of file SVFIR.h.

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

◆ addDummyValNode() [2/2]

NodeID SVF::SVFIR::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 SVFIR.h.

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

◆ addFIObjNode()

NodeID SVF::SVFIR::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 SVFIR.h.

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

◆ addFunArgs() [1/2]

void SVF::SVFIR::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 SVFIR.h.

619 {
620 FunEntryICFGNode* funEntryBlockNode = icfg->getFunEntryICFGNode(fun);
622 }
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
Definition ICFG.cpp:243
void addFunArgs(const FunObjVar *fun, const ValVar *arg)
Get/set method for function/callsite arguments and returns.
Definition SVFIR.h:618

◆ addFunArgs() [2/2]

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

Definition at line 624 of file SVFIR.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 SVFIR.h:92

◆ addFunObjNode()

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

Definition at line 741 of file SVFIR.h.

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

◆ addFunRet() [1/2]

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

Add function returns.

Definition at line 630 of file SVFIR.h.

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

◆ addFunRet() [2/2]

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

Definition at line 636 of file SVFIR.h.

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

◆ addFunValNode()

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

Definition at line 671 of file SVFIR.h.

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

◆ addGepObjNode() [1/2]

NodeID SVFIR::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 SVFIR.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 addGepObjNode(GepObjVar *gepObj, NodeID base, const APOffset &apOffset)
Definition SVFIR.cpp:547
OffsetToGepVarMap GepObjVarMap
Map a pair<base,off> to a gep obj node id.
Definition SVFIR.h:86
u32_t NodeID
Definition GeneralType.h:76

◆ addGepObjNode() [2/2]

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

Definition at line 547 of file SVFIR.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}

◆ addGepStmt() [1/2]

void SVFIR::addGepStmt ( GepStmt *  edge)
private

Definition at line 452 of file SVFIR.cpp.

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

◆ addGepStmt() [2/2]

GepStmt * SVFIR::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 SVFIR.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 SVFIR.cpp:465
GepStmt * addNormalGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
Definition SVFIR.cpp:438
bool hasIncomingVariantGepEdge() const
Check for incoming variable field GEP edges.

◆ addGepValNode()

NodeID SVFIR::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 SVFIR.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);
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 SVFIR.h:84

◆ addGepValObjFromDB()

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

Definition at line 595 of file SVFIR.h.

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

◆ addGlobalObjNode()

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

Definition at line 769 of file SVFIR.h.

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

◆ addGlobalPAGEdge()

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

Add global PAGEdges (not in a procedure)

Definition at line 865 of file SVFIR.h.

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

◆ addGlobalValNode()

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

Definition at line 704 of file SVFIR.h.

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

◆ addHeapObjNode()

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

Creates and adds a heap object node to the SVFIR

Definition at line 726 of file SVFIR.h.

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

◆ addIndirectCallsites()

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

Add indirect callsites.

Definition at line 654 of file SVFIR.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 }
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition SVFIR.h:96
FunPtrToCallSitesMap funPtrToCallSitesMap
Definition SVFIR.h:97

◆ addIntrinsicValNode()

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

Definition at line 839 of file SVFIR.h.

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

◆ addLoadStmt() [1/2]

void SVFIR::addLoadStmt ( LoadStmt *  edge)
private

Definition at line 278 of file SVFIR.cpp.

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

◆ addLoadStmt() [2/2]

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

Add Load edge.

Add Load edge

Definition at line 264 of file SVFIR.cpp.

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

◆ addNormalGepStmt()

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

Add Offset(Gep) edge.

Add normal (Gep) edge

Definition at line 438 of file SVFIR.cpp.

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

◆ addObjNode() [1/2]

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

Add a memory obj node.

Definition at line 718 of file SVFIR.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 SVFIR.h:798

◆ addObjNode() [2/2]

NodeID SVFIR::addObjNode ( ObjVar *  node)
private

Add a memory obj node.

Definition at line 796 of file SVFIR.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 SVFIR 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 hasGNode(NodeID id) const
Has a node.
static bool isConstantSym(NodeID id)
Definition IRGraph.h:168
NodeSet constantObjs
Constant objects and their fields, recorded when each object node is added.
Definition SVFIR.h:88
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:499
NodeID getId() const
Get ID.
Definition SVFValue.h:158

◆ addPhiStmt() [1/2]

PhiStmt * SVFIR::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 SVFIR.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});
118 return phi;
119 }
120 else
121 {
122 it->second->addOpVar(opNode,pred);
124 return nullptr;
125 }
126}
PHINodeMap phiNodeMap
A set of phi copy edges.
Definition SVFIR.h:90
PhiStmt * addPhiStmt(NodeID res, NodeID opnd, const ICFGNode *pred)
Add phi node information.
Definition SVFIR.cpp:109

◆ addPhiStmt() [2/2]

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

Definition at line 128 of file SVFIR.cpp.

129{
130 SVFVar* opNode = src;
131 SVFVar* resNode = dst;
132
136
137}

◆ addRetNode() [1/2]

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

Add a unique return node for a procedure.

Definition at line 854 of file SVFIR.h.

855 {
856 return addNode(node);
857 }

◆ addRetNode() [2/2]

NodeID SVF::SVFIR::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 SVFIR.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 SVFIR.h:781

◆ addRetPE() [1/2]

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

Add Return edge.

Add Return edge

Definition at line 341 of file SVFIR.cpp.

342{
343 SVFVar* srcNode = getGNode(src);
344 SVFVar* dstNode = getGNode(dst);
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 SVFIR.cpp:341

◆ addRetPE() [2/2]

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

Definition at line 355 of file SVFIR.cpp.

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

◆ addSelectStmt() [1/2]

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

Add SelectStmt.

Add Phi statement

Definition at line 142 of file SVFIR.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);
149 return nullptr;
150 else
151 {
152 std::vector<ValVar*> opnds = {op1Node, op2Node};
155 return select;
156 }
157}
SelectStmt * addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
Add SelectStmt.
Definition SVFIR.cpp:142

◆ addSelectStmt() [2/2]

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

Definition at line 159 of file SVFIR.cpp.

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

◆ addStackObjNode()

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

Creates and adds a stack object node to the SVFIR

Definition at line 735 of file SVFIR.h.

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

◆ addStoreStmt() [1/2]

StoreStmt * SVFIR::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 SVFIR.cpp.

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

◆ addStoreStmt() [2/2]

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

Definition at line 302 of file SVFIR.cpp.

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

◆ addThreadForkPE()

TDForkPE * SVFIR::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 SVFIR.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);
387 return forkPE;
388 }
389 else
390 {
391 it->second->addOpVar(opNode, cs);
392 return nullptr;
393 }
394}

◆ addThreadJoinPE()

TDJoinPE * SVFIR::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 SVFIR.cpp.

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

◆ addToStmt2TypeMap()

void SVF::SVFIR::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 SVFIR.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
SVFIR edge map containing all PAGEdges.
Definition IRGraph.h:107
u32_t totalPTAPAGEdge
Definition IRGraph.h:111
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
Definition IRGraph.h:108

◆ addToSVFStmtList()

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

Add a SVFStmt into instruction map.

Definition at line 329 of file SVFIR.h.

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

◆ addToTypeLocSetsMap()

void SVF::SVFIR::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 SVFIR.h.

338 {
340 }
TypeLocSetsMap typeLocSetsMap
Map an arg to its base SVFType* and all its field location sets.
Definition SVFIR.h:85

◆ addUnaryOPStmt() [1/2]

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

Add Unary edge.

Add Unary edge

Definition at line 218 of file SVFIR.cpp.

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

◆ addUnaryOPStmt() [2/2]

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

Definition at line 232 of file SVFIR.cpp.

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

◆ addValNode() [1/2]

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

add node into SVFIR

Add a value (pointer) node

Definition at line 665 of file SVFIR.h.

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

◆ addValNode() [2/2]

NodeID SVFIR::addValNode ( ValVar *  node)
private

Add a value (pointer) node.

Definition at line 787 of file SVFIR.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::SVFIR::addVarargNode ( const FunObjVar *  ,
SVFVar *  node 
)
inlineprivate

Add a unique vararg node for a procedure.

Definition at line 859 of file SVFIR.h.

860 {
861 return addNode(node);
862 }

◆ addVarargNode() [2/2]

NodeID SVF::SVFIR::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 SVFIR.h.

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

◆ addVariantGepStmt()

GepStmt * SVFIR::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 SVFIR.cpp.

466{
467 SVFVar* baseNode = getGNode(src);
468 SVFVar* dstNode = getGNode(dst);
470 return nullptr;
471 else
472 {
473 GepStmt* gepPE = new GepStmt(baseNode, dstNode, ap, true);
476 return gepPE;
477 }
478}

◆ callsiteHasRet()

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

Definition at line 414 of file SVFIR.h.

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

◆ destroy()

void SVFIR::destroy ( )
private

Clean up memory.

Clean up memory

Definition at line 636 of file SVFIR.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 SVFIR.h:104

◆ funHasRet()

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

Definition at line 430 of file SVFIR.h.

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

◆ getAllFieldsObjVars() [1/2]

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

Get all fields of an object.

Get all fields object nodes of an object

Definition at line 573 of file SVFIR.cpp.

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

◆ getAllFieldsObjVars() [2/2]

NodeBS & SVFIR::getAllFieldsObjVars ( NodeID  id)

Get all fields object nodes of an object

Definition at line 582 of file SVFIR.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 SVFIR.cpp:573

◆ getAllValidPtrs()

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

Return valid pointers.

Definition at line 209 of file SVFIR.h.

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

◆ getBaseObject()

const BaseObjVar * SVF::SVFIR::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 SVFIR.h.

500 {
501 const SVFVar* node = getSVFVar(id);
502 if(const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(node))
503 return SVFUtil::dyn_cast<BaseObjVar>(
504 getSVFVar(gepObjVar->getBaseNode()));
505 else
506 return SVFUtil::dyn_cast<BaseObjVar>(node);
507 }
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
Definition SVFIR.h:136

◆ getBaseObjVar()

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

Definition at line 160 of file SVFIR.h.

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

◆ getBaseObjVarID()

NodeID SVF::SVFIR::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 SVFIR.h.

555 {
556 return getBaseObject(id)->getId();
557 }
NodeID getId() const
Get the memory object id.

◆ getBaseValVar()

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

Definition at line 509 of file SVFIR.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::SVFIR::getCallGraph ( )
inline

Get CG.

Definition at line 249 of file SVFIR.h.

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

◆ getCallPEForFormalParm()

CallPE * SVF::SVFIR::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 SVFIR.h.

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

◆ getCallSiteArgsList()

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

Get callsite argument list.

Definition at line 396 of file SVFIR.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::SVFIR::getCallSiteArgsMap ( )
inline

Get callsite argument list.

Definition at line 391 of file SVFIR.h.

392 {
393 return callSiteArgsListMap;
394 }

◆ getCallSiteRet()

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

Get callsite return.

Definition at line 408 of file SVFIR.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::SVFIR::getCallSiteRets ( )
inline

Get callsite return.

Definition at line 403 of file SVFIR.h.

404 {
405 return callSiteRetMap;
406 }

◆ getCallSiteSet()

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

Get all callsites.

Definition at line 352 of file SVFIR.h.

353 {
354 return callSiteSet;
355 }

◆ getCHG()

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

Definition at line 242 of file SVFIR.h.

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

◆ getFieldObjNodeNum()

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

Definition at line 442 of file SVFIR.h.

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

◆ getFieldsAfterCollapse()

NodeBS SVFIR::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 SVFIR.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;
605 return bs;
606 }
607 else
608 return getAllFieldsObjVars(obj);
609}
NodeID getFIObjVar(const BaseObjVar *obj) const
Get a field-insensitive obj SVFIR node according to a mem obj.
Definition SVFIR.h:525
void set(unsigned Idx)

◆ getFieldValNodeNum()

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

Node and edge statistics.

Definition at line 438 of file SVFIR.h.

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

◆ getFIObjVar() [1/2]

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

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

Definition at line 525 of file SVFIR.h.

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

◆ getFIObjVar() [2/2]

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

Definition at line 529 of file SVFIR.h.

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

◆ getFunArgsList()

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

Get function arguments list.

Definition at line 379 of file SVFIR.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::SVFIR::getFunArgsMap ( )
inline

Get function arguments list.

Definition at line 374 of file SVFIR.h.

375 {
376 return funArgsListMap;
377 }

◆ getFunObjVar()

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

Definition at line 48 of file SVFIR.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::SVFIR::getFunPtr ( const CallICFGNode *  cs) const
inline

Definition at line 458 of file SVFIR.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::SVFIR::getFunRet ( const FunObjVar *  func) const
inline

Get function return list.

Definition at line 424 of file SVFIR.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::SVFIR::getFunRets ( )
inline

Get function return list.

Definition at line 419 of file SVFIR.h.

420 {
421 return funRetMap;
422 }

◆ getGepObjNodeMap()

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

Return GepObjVarMap.

Definition at line 204 of file SVFIR.h.

205 {
206 return GepObjVarMap;
207 }

◆ getGepObjVar() [1/3]

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

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

Get a field obj SVFIR 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 SVFIR.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 {
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::SVFIR::getGepObjVar ( NodeID  id) const
inline

Definition at line 170 of file SVFIR.h.

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

◆ getGepObjVar() [3/3]

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

Get a field obj SVFIR 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 SVFIR.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 SVFIR.h:170

◆ getGepValVar()

NodeID SVFIR::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 SVFIR.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::SVFIR::getGlobalSVFStmtSet ( )
inline

Get global PAGEdges (not in a procedure)

Definition at line 347 of file SVFIR.h.

348 {
349 return globSVFStmtSet;
350 }

◆ getICFG()

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

Definition at line 232 of file SVFIR.h.

233 {
234 assert(icfg->totalICFGNode>0 && "empty ICFG! Build SVF IR first!");
235 return icfg;
236 }
NodeID totalICFGNode
Definition ICFG.h:66

◆ getIndCallSites()

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

Definition at line 464 of file SVFIR.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::SVFIR::getIndirectCallsites ( ) const
inline

Add/get indirect callsites.

Definition at line 454 of file SVFIR.h.

455 {
457 }

◆ getIntraPAGEdge() [1/2]

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

Get an edge according to src, dst and kind.

Definition at line 481 of file SVFIR.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 SVFIR.h:481

◆ getIntraPAGEdge() [2/2]

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

Definition at line 485 of file SVFIR.h.

486 {
487 SVFStmt edge(src, dst, kind, false);
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 SVFIR.h:299
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy

◆ getMemToFieldsMap()

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

Return memToFieldsMap.

Definition at line 199 of file SVFIR.h.

200 {
201 return memToFieldsMap;
202 }

◆ getModuleIdentifier()

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

Definition at line 262 of file SVFIR.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 SVFIR.h:107
std::string moduleIdentifier
Definition SVFIR.h:109

◆ getObjVar()

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

Definition at line 150 of file SVFIR.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()

static SVFIR * SVF::SVFIR::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 SVFIR.h.

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

◆ getPTASVFStmtList()

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

Given an instruction, get all its PTA PAGEdges.

Definition at line 324 of file SVFIR.h.

325 {
326 return icfgNode2PTASVFStmtsMap[inst];
327 }

◆ getPTASVFStmtSet()

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

Get PTA edges set according to its kind.

Definition at line 304 of file SVFIR.h.

305 {
306 return KindToPTASVFStmtSetMap[kind];
307 }

◆ getSVFStmtList()

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

Given an instruction, get all its PAGEdges.

Definition at line 319 of file SVFIR.h.

320 {
321 return icfgNode2SVFStmtsMap[inst];
322 }

◆ getSVFStmtSet()

SVFStmt::SVFStmtSetTy & SVF::SVFIR::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 SVFIR.h.

300 {
301 return KindToSVFStmtSetMap[kind];
302 }

◆ getSVFVar()

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

ObjVar/GepObjVar/BaseObjVar.

Definition at line 136 of file SVFIR.h.

137 {
138 return getGNode(id);
139 }

◆ getSVFVarMap()

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

Return the entire SVFID to SVFVar map.

Definition at line 193 of file SVFIR.h.

194 {
195 return IDToNodeMap;
196 }

◆ getTypeLocSetsMap()

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

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

Definition at line 342 of file SVFIR.h.

343 {
344 return typeLocSetsMap[argId];
345 }

◆ getValVar()

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

Definition at line 140 of file SVFIR.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 SVFIR::handleBlackHole ( bool  b)
static

SVFIR build configurations.

Whether to handle blackhole edge

Definition at line 782 of file SVFIR.cpp.

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

◆ hasCallSiteArgsMap()

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

Callsite has argument list.

Definition at line 386 of file SVFIR.h.

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

◆ hasFunArgsList()

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

Function has arguments list.

Definition at line 369 of file SVFIR.h.

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

◆ hasPTASVFStmtList()

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

Definition at line 313 of file SVFIR.h.

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

◆ hasSVFStmtList()

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

Whether this instruction has SVFIR Edge.

Definition at line 309 of file SVFIR.h.

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

◆ initialiseCandidatePointers()

void SVFIR::initialiseCandidatePointers ( )

Initialize candidate pointers.

Definition at line 734 of file SVFIR.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;
744 }
745}
IDToNodeMapTy::iterator iterator
Node Iterators.
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Definition SVFIR.cpp:750

◆ isBaseObjVar()

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

Definition at line 184 of file SVFIR.h.

185 {
186 return SVFUtil::isa<BaseObjVar>(getSVFVar(id));
187 }

◆ isBlkObjOrConstantObj()

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

Get black hole and constant id.

Definition at line 538 of file SVFIR.h.

539 {
540 return (isBlkObj(id) || isConstantObj(id));
541 }
static bool isBlkObj(NodeID id)
Definition IRGraph.h:164
bool isConstantObj(NodeID id) const
Definition SVFIR.h:545

◆ isConstantObj()

bool SVF::SVFIR::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 SVFIR.h.

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

◆ isFunPtr()

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

Definition at line 474 of file SVFIR.h.

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

◆ isGepObjVar()

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

Definition at line 188 of file SVFIR.h.

189 {
190 return SVFUtil::isa<GepObjVar>(getSVFVar(id));
191 }

◆ isIndirectCallSites()

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

Definition at line 470 of file SVFIR.h.

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

◆ isObjVar()

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

Definition at line 180 of file SVFIR.h.

181 {
182 return SVFUtil::isa<ObjVar>(getSVFVar(id));
183 }

◆ isPhiNode()

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

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

Definition at line 357 of file SVFIR.h.

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

◆ isValidPointer()

bool SVFIR::isValidPointer ( NodeID  nodeId) const

Whether a node is a valid pointer.

Definition at line 750 of file SVFIR.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}
Class representing a function argument variable in the SVFIR.
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
virtual bool isPointer() const
Check if this variable represents a pointer.

◆ isValidTopLevelPtr()

bool SVFIR::isValidTopLevelPtr ( const SVFVar *  node)

Definition at line 765 of file SVFIR.cpp.

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

◆ pagFileName()

static std::string SVF::SVFIR::pagFileName ( )
inlinestatic

Definition at line 276 of file SVFIR.h.

277 {
278 return pagReadFromTxt;
279 }

◆ pagReadFromTXT()

static bool SVF::SVFIR::pagReadFromTXT ( )
inlinestatic

Definition at line 281 of file SVFIR.h.

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

◆ print()

void SVFIR::print ( )

Print SVFIR.

Print this SVFIR graph including its nodes and edges

Definition at line 649 of file SVFIR.cpp.

650{
651
652 outs() << "-------------------SVFIR------------------------------------\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
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
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
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}
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:58

◆ releaseSVFIR()

static void SVF::SVFIR::releaseSVFIR ( )
inlinestatic

Definition at line 129 of file SVFIR.h.

130 {
131 pag = nullptr;
132 }

◆ setCallGraph()

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

Definition at line 255 of file SVFIR.h.

256 {
257 callGraph = cg;
258 }

◆ setCHG()

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

Set/Get CHG.

Definition at line 238 of file SVFIR.h.

239 {
240 chgraph = c;
241 }

◆ setICFG()

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

Set/Get ICFG.

Definition at line 228 of file SVFIR.h.

229 {
230 icfg = i;
231 }

◆ setModuleIdentifier()

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

Definition at line 291 of file SVFIR.h.

292 {
294 }

◆ setPagFromTXT()

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

Definition at line 286 of file SVFIR.h.

287 {
289 }

Friends And Related Symbol Documentation

◆ BVDataPTAImpl

Definition at line 50 of file SVFIR.h.

◆ ExternalPAG

friend class ExternalPAG
friend

Definition at line 48 of file SVFIR.h.

◆ GraphDBClient

friend class GraphDBClient
friend

Definition at line 51 of file SVFIR.h.

◆ GraphDBSVFIRBuilder

friend class GraphDBSVFIRBuilder
friend

Definition at line 52 of file SVFIR.h.

◆ PAGBuilderFromFile

Definition at line 49 of file SVFIR.h.

◆ SVFIRBuilder

Definition at line 47 of file SVFIR.h.

Member Data Documentation

◆ callGraph

CallGraph* SVF::SVFIR::callGraph
private

all the callsites of a program

Definition at line 104 of file SVFIR.h.

◆ callSiteArgsListMap

CSToArgsListMap SVF::SVFIR::callSiteArgsListMap
private

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

Definition at line 93 of file SVFIR.h.

◆ callSiteRetMap

CSToRetMap SVF::SVFIR::callSiteRetMap
private

Map a callsite to its callsite returns PAGNodes.

Definition at line 94 of file SVFIR.h.

◆ callSiteSet

CallSiteSet SVF::SVFIR::callSiteSet
private

Definition at line 103 of file SVFIR.h.

◆ candidatePointers

OrderedNodeSet SVF::SVFIR::candidatePointers
private

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

Definition at line 100 of file SVFIR.h.

◆ chgraph

CommonCHGraph* SVF::SVFIR::chgraph
private

Definition at line 102 of file SVFIR.h.

◆ constantObjs

NodeSet SVF::SVFIR::constantObjs
private

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

Definition at line 88 of file SVFIR.h.

◆ fParmToCallPEMap

FParmToCallPEMap SVF::SVFIR::fParmToCallPEMap
private

Map a formal param to its CallPE.

Definition at line 91 of file SVFIR.h.

◆ funArgsListMap

FunToArgsListMap SVF::SVFIR::funArgsListMap
private

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

Definition at line 92 of file SVFIR.h.

◆ funPtrToCallSitesMap

FunPtrToCallSitesMap SVF::SVFIR::funPtrToCallSitesMap
private

Map a function pointer to the callsites where it is used

Definition at line 97 of file SVFIR.h.

◆ funRetMap

FunToRetMap SVF::SVFIR::funRetMap
private

Map a function to its unique function return PAGNodes.

Definition at line 95 of file SVFIR.h.

◆ GepObjVarMap

OffsetToGepVarMap SVF::SVFIR::GepObjVarMap
private

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

Definition at line 86 of file SVFIR.h.

◆ GepValObjMap

GepValueVarMap SVF::SVFIR::GepValObjMap
private

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

Definition at line 84 of file SVFIR.h.

◆ globSVFStmtSet

SVFStmtSet SVF::SVFIR::globSVFStmtSet
private

Global PAGEdges without control flow information.

Definition at line 89 of file SVFIR.h.

◆ icfg

ICFG* SVF::SVFIR::icfg
private

Definition at line 101 of file SVFIR.h.

◆ icfgNode2PTASVFStmtsMap

ICFGNode2SVFStmtsMap SVF::SVFIR::icfgNode2PTASVFStmtsMap
private

Map an ICFGNode to its PointerAnalysis related SVFStmts.

Definition at line 83 of file SVFIR.h.

◆ icfgNode2SVFStmtsMap

ICFGNode2SVFStmtsMap SVF::SVFIR::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 SVFIR.h.

◆ indCallSiteToFunPtrMap

CallSiteToFunPtrMap SVF::SVFIR::indCallSiteToFunPtrMap
private

Map an indirect callsite to its function pointer.

Definition at line 96 of file SVFIR.h.

◆ memToFieldsMap

MemObjToFieldsMap SVF::SVFIR::memToFieldsMap
private

Map a mem object id to all its fields.

Definition at line 87 of file SVFIR.h.

◆ moduleIdentifier

std::string SVF::SVFIR::moduleIdentifier
private

Definition at line 109 of file SVFIR.h.

◆ pag

std::unique_ptr< SVFIR > SVFIR::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 SVFIR can only be created once.

Definition at line 106 of file SVFIR.h.

◆ pagReadFromTxt

std::string SVFIR::pagReadFromTxt = ""
staticprivate

Definition at line 107 of file SVFIR.h.

◆ phiNodeMap

PHINodeMap SVF::SVFIR::phiNodeMap
private

A set of phi copy edges.

Definition at line 90 of file SVFIR.h.

◆ typeLocSetsMap

TypeLocSetsMap SVF::SVFIR::typeLocSetsMap
private

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

Definition at line 85 of file SVFIR.h.


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