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 *, NodeIDCallSiteToFunPtrMap
 
typedef Map< NodeID, CallSiteSetFunPtrToCallSitesMap
 
typedef Map< NodeID, NodeBSMemObjToFieldsMap
 
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 *, ValVarListFunToArgsListMap
 
typedef Map< const CallICFGNode *, ValVarListCSToArgsListMap
 
typedef Map< const RetICFGNode *, const ValVar * > CSToRetMap
 
typedef Map< const FunObjVar *, const ValVar * > FunToRetMap
 
typedef Map< const FunObjVar *, SVFStmtSetFunToPAGEdgeSetMap
 
typedef Map< const ICFGNode *, SVFStmtListICFGNode2SVFStmtsMap
 
typedef Map< NodeID, NodeIDNodeToNodeMap
 
typedef std::pair< NodeID, APOffsetGepOffset
 
typedef std::pair< NodeID, AccessPathNodeAccessPath
 
typedef Map< GepOffset, NodeIDOffsetToGepVarMap
 
typedef Map< NodeAccessPath, NodeIDNodeAccessPathMap
 
typedef Map< NodeID, NodeAccessPathMapGepValueVarMap
 
typedef std::pair< const SVFType *, std::vector< AccessPath > > SVFTypeLocSetsPair
 
typedef Map< NodeID, SVFTypeLocSetsPairTypeLocSetsMap
 
typedef Map< NodePair, NodeIDNodePairSetMap
 
- 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 *, NodeIDFunObjVarToIDMapTy
 function to sym id map
 
typedef Set< const SVFType * > SVFTypeSet
 struct type to struct info map
 
typedef Set< const SVFStmt * > SVFStmtSet
 
- Public Types inherited from SVF::GenericGraph< SVFVar, SVFStmt >
typedef SVFVar NodeType
 
typedef SVFStmt EdgeType
 
typedef OrderedMap< NodeID, NodeType * > IDToNodeMapTy
 NodeID to GenericNode map.
 
typedef IDToNodeMapTy::iterator iterator
 Node Iterators.
 
typedef IDToNodeMapTy::const_iterator const_iterator
 

Public Member Functions

const SVFVargetSVFVar (NodeID id) const
 ObjVar/GepObjVar/BaseObjVar.
 
const ValVargetValVar (NodeID id) const
 
const ObjVargetObjVar (NodeID id) const
 
const BaseObjVargetBaseObjVar (NodeID id) const
 
const GepObjVargetGepObjVar (NodeID id) const
 
bool isObjVar (NodeID id) const
 
bool isBaseObjVar (NodeID id) const
 
bool isGepObjVar (NodeID id) const
 
const IDToNodeMapTygetSVFVarMap () const
 Return the entire SVFID to SVFVar map.
 
MemObjToFieldsMapgetMemToFieldsMap ()
 Return memToFieldsMap.
 
OffsetToGepVarMapgetGepObjNodeMap ()
 Return GepObjVarMap.
 
OrderedNodeSetgetAllValidPtrs ()
 Return valid pointers.
 
void initialiseCandidatePointers ()
 Initialize candidate pointers.
 
virtual ~SVFIR ()
 Destructor.
 
void setICFG (ICFG *i)
 Set/Get ICFG.
 
ICFGgetICFG () const
 
void setCHG (CommonCHGraph *c)
 Set/Get CHG.
 
CommonCHGraphgetCHG ()
 
const CallGraphgetCallGraph ()
 Get CG.
 
void setCallGraph (CallGraph *cg)
 
const FunObjVargetFunObjVar (const std::string &name)
 
const std::string & getModuleIdentifier () const
 
void setModuleIdentifier (const std::string &moduleIdentifier)
 
SVFStmt::SVFStmtSetTygetSVFStmtSet (SVFStmt::PEDGEK kind)
 Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
 
SVFStmt::SVFStmtSetTygetPTASVFStmtSet (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
 
SVFStmtListgetSVFStmtList (const ICFGNode *inst)
 Given an instruction, get all its PAGEdges.
 
SVFStmtListgetPTASVFStmtList (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.
 
SVFTypeLocSetsPairgetTypeLocSetsMap (NodeID argId)
 Given an arg NodeId, get its base SVFType* and all its field location sets.
 
SVFStmtSetgetGlobalSVFStmtSet ()
 Get global PAGEdges (not in a procedure)
 
const CallSiteSetgetCallSiteSet () const
 Get all callsites.
 
bool isPhiNode (const SVFVar *node) const
 Whether this SVFVar is a result operand a of phi node.
 
CallPEgetCallPEForFormalParm (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.
 
FunToArgsListMapgetFunArgsMap ()
 Get function arguments list.
 
const ValVarListgetFunArgsList (const FunObjVar *func) const
 Get function arguments list.
 
bool hasCallSiteArgsMap (const CallICFGNode *cs) const
 Callsite has argument list.
 
CSToArgsListMapgetCallSiteArgsMap ()
 Get callsite argument list.
 
const ValVarListgetCallSiteArgsList (const CallICFGNode *cs) const
 Get callsite argument list.
 
CSToRetMapgetCallSiteRets ()
 Get callsite return.
 
const ValVargetCallSiteRet (const RetICFGNode *cs) const
 Get callsite return.
 
bool callsiteHasRet (const RetICFGNode *cs) const
 
FunToRetMapgetFunRets ()
 Get function return list.
 
const ValVargetFunRet (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 CallSiteToFunPtrMapgetIndirectCallsites () const
 Add/get indirect callsites.
 
NodeID getFunPtr (const CallICFGNode *cs) const
 
const CallSiteSetgetIndCallSites (NodeID funPtr) const
 
bool isIndirectCallSites (const CallICFGNode *cs) const
 
bool isFunPtr (NodeID id) const
 
SVFStmtgetIntraPAGEdge (NodeID src, NodeID dst, SVFStmt::PEDGEK kind)
 Get an edge according to src, dst and kind.
 
SVFStmtgetIntraPAGEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
 
const BaseObjVargetBaseObject (NodeID id) const
 
const ValVargetBaseValVar (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.
 
NodeBSgetAllFieldsObjVars (const BaseObjVar *obj)
 Get all fields of an object.
 
NodeBSgetAllFieldsObjVars (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
 
IDToTypeInfoMapTyidToObjTypeInfoMap ()
 Get different kinds of syms maps.
 
const IDToTypeInfoMapTyidToObjTypeInfoMap () const
 
FunObjVarToIDMapTyretFunObjSyms ()
 
FunObjVarToIDMapTyvarargFunObjSyms ()
 
ObjTypeInfogetObjTypeInfo (NodeID id) const
 
NodeID getReturnNode (const FunObjVar *func) const
 GetReturnNode - Return the unique node representing the return value of a function.
 
NodeID getVarargNode (const FunObjVar *func) const
 getVarargNode - Return the unique node representing the variadic argument of a variadic function.
 
NodeID getBlackHoleNode () const
 
NodeID getConstantNode () const
 
NodeID getBlkPtr () const
 
NodeID getNullPtr () const
 
u32_t getValueNodeNum ()
 
u32_t getObjectNodeNum ()
 
const SVFTypeSetgetSVFTypes () const
 Constant reader that won't change the state of the symbol table.
 
const SVFTypegetSVFType (u32_t id) const
 
const Set< const StInfo * > & getStInfos () const
 
virtual APOffset getModulusOffset (const BaseObjVar *baseObj, const APOffset &apOffset)
 Given an offset from a Gep Instruction, return it modulus offset by considering memory layout.
 
const StInfogetTypeInfo (const SVFType *T) const
 Get struct info.
 
bool hasSVFTypeInfo (const SVFType *T)
 
ObjTypeInfocreateObjTypeInfo (const SVFType *type)
 Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
 
const ObjTypeInfocreateDummyObjTypeInfo (NodeID symId, const SVFType *type)
 
u32_t getNumOfFlattenElements (const SVFType *T)
 
u32_t getFlattenedElemIdx (const SVFType *T, u32_t origId)
 Flattened element idx of an array or struct by considering stride.
 
const SVFTypegetFlatternedElemType (const SVFType *baseType, u32_t flatten_idx)
 Return the type of a flattened element given a flattened index.
 
const SVFTypegetOriginalElemType (const SVFType *baseType, u32_t origId) const
 
void printFlattenFields (const SVFType *type)
 Debug method.
 
u32_t getNodeNumAfterPAGBuild () const
 
void setNodeNumAfterPAGBuild (u32_t num)
 
u32_t getSVFVarNum () const
 
u32_t getSVFStmtNum () const
 
u32_t getPTAPAGEdgeNum () const
 
std::string getGraphName () const
 Return graph name.
 
void dumpSymTable ()
 
void dump (std::string name)
 Dump SVFIR.
 
void view ()
 View graph from the debugger.
 
void addTypeInfo (const SVFType *ty)
 
void addStInfo (StInfo *stInfo)
 
- Public Member Functions inherited from SVF::GenericGraph< SVFVar, SVFStmt >
 GenericGraph ()
 Constructor.
 
virtual ~GenericGraph ()
 Destructor.
 
void destroy ()
 Release memory.
 
iterator begin ()
 Iterators.
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node.
 
NodeTypegetGNode (NodeID id) const
 Get a node.
 
bool hasGNode (NodeID id) const
 Has a node.
 
void removeGNode (NodeType *node)
 Delete a node.
 
u32_t getTotalNodeNum () const
 Get total number of node/edge.
 
u32_t getTotalEdgeNum () const
 
void incNodeNum ()
 Increase number of node/edge.
 
void incEdgeNum ()
 

Static Public Member Functions

static SVFIRgetPAG (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.
 
SVFStmthasNonlabeledEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
 
SVFStmthasLabeledEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind, const ICFGNode *cs)
 
SVFStmthasEdge (SVFStmt *edge, SVFStmt::PEDGEK kind)
 
SVFStmthasLabeledEdge (SVFVar *src, SVFVar *op1, SVFStmt::PEDGEK kind, const SVFVar *op2)
 
const std::vector< const SVFType * > & getFlattenFieldTypes (const SVFStructType *T)
 Return the flattened field type for struct type only.
 

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 addConstantAggValNode (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 addConstantAggObjNode (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 addBasicBlockValNode (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.
 
AddrStmtaddAddrStmt (NodeID src, NodeID dst)
 Add an edge into SVFIR.
 
void addAddrStmt (AddrStmt *edge)
 
CopyStmtaddCopyStmt (NodeID src, NodeID dst, CopyStmt::CopyKind type)
 Add Copy edge.
 
void addCopyStmt (CopyStmt *edge)
 
PhiStmtaddPhiStmt (NodeID res, NodeID opnd, const ICFGNode *pred)
 Add phi node information.
 
void addPhiStmt (PhiStmt *edge, SVFVar *src, SVFVar *dst)
 
SelectStmtaddSelectStmt (NodeID res, NodeID op1, NodeID op2, NodeID cond)
 Add SelectStmt.
 
void addSelectStmt (SelectStmt *edge, SVFVar *src, SVFVar *dst)
 
CmpStmtaddCmpStmt (NodeID op1, NodeID op2, NodeID dst, u32_t predict)
 Add Copy edge.
 
void addCmpStmt (CmpStmt *edge, SVFVar *src, SVFVar *dst)
 
BinaryOPStmtaddBinaryOPStmt (NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
 Add Copy edge.
 
void addBinaryOPStmt (BinaryOPStmt *edge, SVFVar *src, SVFVar *dst)
 
UnaryOPStmtaddUnaryOPStmt (NodeID src, NodeID dst, u32_t opcode)
 Add Unary edge.
 
void addUnaryOPStmt (UnaryOPStmt *edge, SVFVar *src, SVFVar *dst)
 
BranchStmtaddBranchStmt (NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
 Add BranchStmt.
 
void addBranchStmt (BranchStmt *edge, SVFVar *src, SVFVar *dst)
 
LoadStmtaddLoadStmt (NodeID src, NodeID dst)
 Add Load edge.
 
void addLoadStmt (LoadStmt *edge)
 
StoreStmtaddStoreStmt (NodeID src, NodeID dst, const ICFGNode *val)
 Add Store edge.
 
void addStoreStmt (StoreStmt *edge, SVFVar *src, SVFVar *dst)
 
CallPEaddCallPE (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)
 
RetPEaddRetPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
 Add Return edge.
 
void addRetPE (RetPE *edge, SVFVar *src, SVFVar *dst)
 
GepStmtaddGepStmt (NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
 Add Gep edge.
 
void addGepStmt (GepStmt *edge)
 
GepStmtaddNormalGepStmt (NodeID src, NodeID dst, const AccessPath &ap)
 Add Offset(Gep) edge.
 
GepStmtaddVariantGepStmt (NodeID src, NodeID dst, const AccessPath &ap)
 Add Variant(Gep) edge.
 
TDForkPEaddThreadForkPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
 Add Thread fork edge for parameter passing.
 
TDJoinPEaddThreadJoinPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
 Add Thread join edge for parameter passing.
 
SVFStmtaddBlackHoleAddrStmt (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.
 
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
 
ICFGicfg
 
CommonCHGraphchgraph
 
CallSiteSet callSiteSet
 
CallGraphcallGraph
 all the callsites of a program
 
std::string moduleIdentifier
 

Static Private Attributes

static std::unique_ptr< SVFIRpag
 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 TypeBasedHeapCloning
 
class BVDataPTAImpl
 
class GraphDBClient
 
class GraphDBSVFIRBuilder
 

Additional Inherited Members

- Public Attributes inherited from SVF::IRGraph
const SVFTypemaxStruct
 The struct type with the most fields.
 
u32_t maxStSize
 The number of fields in max_struct.
 
- Public Attributes inherited from SVF::GenericGraph< SVFVar, SVFStmt >
u32_t edgeNum
 total num of node
 
u32_t nodeNum
 total num of edge
 
- Protected 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 42 of file SVFIR.h.

Member Typedef Documentation

◆ CallSiteSet

Definition at line 53 of file SVFIR.h.

◆ CallSiteToFunPtrMap

Definition at line 54 of file SVFIR.h.

◆ CSToArgsListMap

Definition at line 62 of file SVFIR.h.

◆ CSToRetMap

Definition at line 63 of file SVFIR.h.

◆ FParmToCallPEMap

Definition at line 60 of file SVFIR.h.

◆ FunPtrToCallSitesMap

Definition at line 55 of file SVFIR.h.

◆ FunToArgsListMap

Definition at line 61 of file SVFIR.h.

◆ FunToPAGEdgeSetMap

Definition at line 65 of file SVFIR.h.

◆ FunToRetMap

Definition at line 64 of file SVFIR.h.

◆ GepOffset

Definition at line 68 of file SVFIR.h.

◆ GepValueVarMap

Definition at line 72 of file SVFIR.h.

◆ ICFGNode2SVFStmtsMap

Definition at line 66 of file SVFIR.h.

◆ MemObjToFieldsMap

Definition at line 56 of file SVFIR.h.

◆ NodeAccessPath

Definition at line 69 of file SVFIR.h.

◆ NodeAccessPathMap

Definition at line 71 of file SVFIR.h.

◆ NodePairSetMap

Definition at line 75 of file SVFIR.h.

◆ NodeToNodeMap

Definition at line 67 of file SVFIR.h.

◆ OffsetToGepVarMap

Definition at line 70 of file SVFIR.h.

◆ PHINodeMap

Definition at line 59 of file SVFIR.h.

◆ SVFStmtList

Definition at line 57 of file SVFIR.h.

◆ SVFTypeLocSetsPair

Definition at line 73 of file SVFIR.h.

◆ TypeLocSetsMap

Definition at line 74 of file SVFIR.h.

◆ ValVarList

Definition at line 58 of file SVFIR.h.

Constructor & Destructor Documentation

◆ SVFIR()

SVFIR::SVFIR ( bool  buildFromFile)
private

Constructor.

Definition at line 42 of file SVFIR.cpp.

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

◆ ~SVFIR()

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

Destructor.

Definition at line 214 of file SVFIR.h.

215 {
216 destroy();
217 }
void destroy()
Clean up memory.
Definition SVFIR.cpp:633

Member Function Documentation

◆ addAddrStmt() [1/2]

void SVFIR::addAddrStmt ( AddrStmt edge)
private

Definition at line 76 of file SVFIR.cpp.

77{
79 addEdge(getGNode(edge->getRHSVarID()),getGNode(edge->getLHSVarID()), edge);
80}
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:253
void addToStmt2TypeMap(SVFStmt *edge)
Map a SVFStatement type to a set of corresponding SVF statements.
Definition SVFIR.h:601

◆ addAddrStmt() [2/2]

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

Add an edge into SVFIR.

Add Address edge

Definition at line 63 of file SVFIR.cpp.

64{
65 SVFVar* srcNode = getGNode(src);
66 SVFVar* dstNode = getGNode(dst);
68 return nullptr;
69 else
70 {
73 return addrPE;
74 }
75}
SVFStmt * hasNonlabeledEdge(SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
Definition IRGraph.cpp:268
AddrStmt * addAddrStmt(NodeID src, NodeID dst)
Add an edge into SVFIR.
Definition SVFIR.cpp:63

◆ addArgValNode()

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

Definition at line 675 of file SVFIR.h.

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

◆ addAsmPCValNode()

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

Definition at line 856 of file SVFIR.h.

857 {
858 return addValNode(new AsmPCValVar(i, type));
859 }

◆ addBaseObjNode()

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

Definition at line 583 of file SVFIR.h.

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

◆ addBasicBlockValNode()

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

Definition at line 852 of file SVFIR.h.

853 {
854 return addValNode(new BasicBlockValVar(i, type));
855 }

◆ addBinaryOPStmt() [1/2]

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

Definition at line 209 of file SVFIR.cpp.

210{
212 addEdge(src, dst, edge);
213}

◆ 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 193 of file SVFIR.cpp.

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

◆ addBlackHoleAddrStmt()

SVFStmt * SVFIR::addBlackHoleAddrStmt ( NodeID  node)
private

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

Add blackhole/constant edge

Definition at line 363 of file SVFIR.cpp.

364{
366 return pag->addAddrStmt(pag->getBlackHoleNode(), node);
367 else
368 return pag->addCopyStmt(pag->getNullPtr(), node, CopyStmt::COPYVAL);
369}
static Option< bool > HandBlackHole
Definition Options.h:99
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:103

◆ addBlackholeObjNode()

NodeID SVF::SVFIR::addBlackholeObjNode ( )
inlineprivate

Definition at line 836 of file SVFIR.h.

837 {
838 return addObjNode(new DummyObjVar(getBlackHoleNode(), getObjTypeInfo(getBlackHoleNode()), nullptr));
839 }
NodeID getBlackHoleNode() const
Definition IRGraph.h:247
ObjTypeInfo * getObjTypeInfo(NodeID id) const
Definition IRGraph.h:234

◆ addBlackholePtrNode()

NodeID SVF::SVFIR::addBlackholePtrNode ( )
inlineprivate

Definition at line 844 of file SVFIR.h.

845 {
846 return addDummyValNode(getBlkPtr(), nullptr);
847 }
NodeID getBlkPtr() const
Definition IRGraph.h:255
NodeID addDummyValNode()
Definition SVFIR.h:564

◆ addBranchStmt() [1/2]

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

Definition at line 254 of file SVFIR.cpp.

255{
257 addEdge(src, dst, edge);
258}

◆ addBranchStmt() [2/2]

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

Add BranchStmt.

Definition at line 240 of file SVFIR.cpp.

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

◆ addCallPE() [1/2]

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

Definition at line 330 of file SVFIR.cpp.

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

◆ 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 310 of file SVFIR.cpp.

311{
312 ValVar* opNode = const_cast<ValVar*>(getValVar(src));
313 ValVar* resNode = const_cast<ValVar*>(getValVar(dst));
314 FParmToCallPEMap::iterator it = fParmToCallPEMap.find(resNode);
315 // if first operand, create a new CallPE, otherwise add the operand to the existing CallPE
316 if(it == fParmToCallPEMap.end())
317 {
318 CallPE* callPE = new CallPE(resNode, {opNode}, {cs}, entry);
319 addCallPE(callPE, opNode, resNode);
320 return callPE;
321 }
322 else
323 {
324 it->second->addOpVar(opNode, cs);
326 return nullptr;
327 }
328}
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:310

◆ addCallSite()

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

Add callsites.

Definition at line 883 of file SVFIR.h.

884 {
885 callSiteSet.insert(call);
886 }
CallSiteSet callSiteSet
Definition SVFIR.h:100

◆ addCallSiteArgs()

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

Add callsite arguments.

Definition at line 640 of file SVFIR.h.

641 {
642 callBlockNode->addActualParms(arg);
643 callSiteArgsListMap[callBlockNode].push_back(arg);
644 }
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition SVFIR.h:90

◆ addCallSiteRets()

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

Add callsite returns.

Definition at line 646 of file SVFIR.h.

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

◆ addCmpStmt() [1/2]

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

Definition at line 183 of file SVFIR.cpp.

184{
186 addEdge(src, dst, edge);
187}

◆ 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 167 of file SVFIR.cpp.

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

◆ addConstantAggObjNode()

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

Definition at line 778 of file SVFIR.h.

779 {
780 ConstAggObjVar* conObj = new ConstAggObjVar(i, ti, node);
781 return addBaseObjNode(conObj);
782 }
NodeID addBaseObjNode(BaseObjVar *node)
Definition SVFIR.h:583

◆ addConstantAggValNode()

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

Definition at line 708 of file SVFIR.h.

709 {
710 SVFVar* node = new ConstAggValVar(i, icfgNode, svfType);
711 return addNode(node);
712 }
NodeID addNode(SVFVar *node)
Add a node into the graph.
Definition IRGraph.h:117

◆ addConstantDataObjNode()

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

Definition at line 783 of file SVFIR.h.

784 {
785 ConstDataObjVar* conObj = new ConstDataObjVar(i, ti, node);
786 return addBaseObjNode(conObj);
787 }

◆ addConstantDataValNode()

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

Definition at line 714 of file SVFIR.h.

715 {
716 SVFVar* node = new ConstDataValVar(i, icfgNode, type);
717 return addNode(node);
718 }

◆ addConstantFPObjNode()

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

Definition at line 752 of file SVFIR.h.

753 {
754 ConstFPObjVar* conObj = new ConstFPObjVar(i, dval, ti, node);
755 return addBaseObjNode(conObj);
756 }

◆ addConstantFPValNode()

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

Definition at line 682 of file SVFIR.h.

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

◆ addConstantIntObjNode()

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

Definition at line 759 of file SVFIR.h.

760 {
761 ConstIntObjVar* conObj =
762 new ConstIntObjVar(i, intValue.first, intValue.second, ti, node);
763 return addBaseObjNode(conObj);
764 }

◆ 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 689 of file SVFIR.h.

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

◆ addConstantNullPtrObjNode()

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

Definition at line 767 of file SVFIR.h.

768 {
769 ConstNullPtrObjVar* conObj = new ConstNullPtrObjVar(i, ti, node);
770 return addBaseObjNode(conObj);
771 }

◆ addConstantNullPtrValNode()

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

Definition at line 696 of file SVFIR.h.

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

◆ addConstantObjNode()

NodeID SVF::SVFIR::addConstantObjNode ( )
inlineprivate

Definition at line 840 of file SVFIR.h.

841 {
842 return addObjNode(new DummyObjVar(getConstantNode(), getObjTypeInfo(getConstantNode()), nullptr));
843 }
NodeID getConstantNode() const
Definition IRGraph.h:251

◆ addCopyStmt() [1/2]

void SVFIR::addCopyStmt ( CopyStmt edge)
private

Definition at line 99 of file SVFIR.cpp.

100{
102 addEdge(getGNode(edge->getRHSVarID()),getGNode(edge->getLHSVarID()), edge);
103}

◆ addCopyStmt() [2/2]

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

Add Copy edge.

Add Copy edge

Definition at line 85 of file SVFIR.cpp.

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

◆ addDummyObjNode() [1/3]

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

Definition at line 568 of file SVFIR.h.

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

◆ addDummyObjNode() [2/3]

NodeID SVFIR::addDummyObjNode ( DummyObjVar node)
protected

Definition at line 802 of file SVFIR.cpp.

803{
804 return addObjNode(node);
805}

◆ addDummyObjNode() [3/3]

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

Definition at line 822 of file SVFIR.h.

823 {
824 if (idToObjTypeInfoMap().find(i) == idToObjTypeInfoMap().end())
825 {
826 ObjTypeInfo* ti = createObjTypeInfo(type);
828 return addDummyObjNode(new DummyObjVar(i, ti, nullptr));
829 }
830 else
831 {
832 return addDummyObjNode(new DummyObjVar(i, getObjTypeInfo(i), nullptr));
833 }
834 }
ObjTypeInfo * createObjTypeInfo(const SVFType *type)
Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy ...
Definition IRGraph.cpp:231
IDToTypeInfoMapTy & idToObjTypeInfoMap()
Get different kinds of syms maps.
Definition IRGraph.h:212

◆ addDummyValNode() [1/2]

NodeID SVF::SVFIR::addDummyValNode ( )
inline

Definition at line 564 of file SVFIR.h.

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

◆ 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 818 of file SVFIR.h.

819 {
820 return addValNode(new DummyValVar(i, node));
821 }

◆ 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 807 of file SVFIR.h.

808 {
809 BaseObjVar* baseObj = new BaseObjVar(i, ti, node);
810 return addBaseObjNode(baseObj);
811 }

◆ 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 616 of file SVFIR.h.

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

◆ addFunArgs() [2/2]

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

Definition at line 622 of file SVFIR.h.

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

◆ addFunObjNode()

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

Definition at line 745 of file SVFIR.h.

746 {
747 FunObjVar* funObj = new FunObjVar(id, ti, node);
748 return addBaseObjNode(funObj);
749 }

◆ addFunRet() [1/2]

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

Add function returns.

Definition at line 628 of file SVFIR.h.

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

◆ addFunRet() [2/2]

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

Definition at line 634 of file SVFIR.h.

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

◆ addFunValNode()

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

Definition at line 669 of file SVFIR.h.

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

◆ 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 558 of file SVFIR.cpp.

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

◆ addGepObjNode() [2/2]

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

Definition at line 546 of file SVFIR.cpp.

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

◆ addGepStmt() [1/2]

void SVFIR::addGepStmt ( GepStmt edge)
private

Definition at line 451 of file SVFIR.cpp.

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

◆ 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 418 of file SVFIR.cpp.

419{
420
421 SVFVar* node = getGNode(src);
422 if (!constGep || node->hasIncomingVariantGepEdge())
423 {
426 return addVariantGepStmt(src, dst, ap);
427 }
428 else
429 {
430 return addNormalGepStmt(src, dst, ap);
431 }
432}
GepStmt * addVariantGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
Definition SVFIR.cpp:464
GepStmt * addNormalGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
Definition SVFIR.cpp:437
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 485 of file SVFIR.cpp.

486{
487 NodeID base = baseVar->getId();
488 //assert(findPAGNode(i) == false && "this node should not be created before");
489 assert(0==GepValObjMap[curInst].count(std::make_pair(base, ap))
490 && "this node should not be created before");
491 GepValObjMap[curInst][std::make_pair(base, ap)] = i;
492 GepValVar *node = new GepValVar(baseVar, i, ap, type, icn);
494 return addValNode(node);
495}
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:82

◆ addGepValObjFromDB()

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

Definition at line 593 of file SVFIR.h.

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

◆ addGlobalObjNode()

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

Definition at line 773 of file SVFIR.h.

774 {
775 GlobalObjVar* gObj = new GlobalObjVar(i, ti, node);
776 return addBaseObjNode(gObj);
777 }

◆ addGlobalPAGEdge()

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

Add global PAGEdges (not in a procedure)

Definition at line 878 of file SVFIR.h.

879 {
880 globSVFStmtSet.insert(edge);
881 }
SVFStmtSet globSVFStmtSet
Global PAGEdges without control flow information.
Definition SVFIR.h:86

◆ addGlobalValNode()

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

Definition at line 702 of file SVFIR.h.

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

◆ 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 730 of file SVFIR.h.

731 {
732 HeapObjVar *heapObj = new HeapObjVar(i, ti, node);
733 return addBaseObjNode(heapObj);
734 }

◆ addIndirectCallsites()

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

Add indirect callsites.

Definition at line 652 of file SVFIR.h.

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

◆ addIntrinsicValNode()

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

Definition at line 848 of file SVFIR.h.

849 {
850 return addValNode(new IntrinsicValVar(i, type));
851 }

◆ addLoadStmt() [1/2]

void SVFIR::addLoadStmt ( LoadStmt edge)
private

Definition at line 277 of file SVFIR.cpp.

278{
280 addEdge(getGNode(edge->getRHSVarID()),getGNode(edge->getLHSVarID()), edge);
281}

◆ addLoadStmt() [2/2]

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

Add Load edge.

Add Load edge

Definition at line 263 of file SVFIR.cpp.

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

◆ addNormalGepStmt()

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

Add Offset(Gep) edge.

Add normal (Gep) edge

Definition at line 437 of file SVFIR.cpp.

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

◆ addObjNode() [1/2]

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

Add a memory obj node.

Definition at line 722 of file SVFIR.h.

723 {
724 return addFIObjNode( i, ti, node);
725 }
NodeID addFIObjNode(NodeID i, ObjTypeInfo *ti, const ICFGNode *node)
Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
Definition SVFIR.h:807

◆ addObjNode() [2/2]

NodeID SVFIR::addObjNode ( ObjVar node)
private

Add a memory obj node.

Definition at line 793 of file SVFIR.cpp.

794{
795 assert(node && "node cannot be nullptr.");
796 assert(hasGNode(node->getId()) == false &&
797 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
798 "Strategy::DBUG to SEQ or DENSE");
799 return addNode(node);
800}
bool hasGNode(NodeID id) const
Has a node.
NodeID getId() const
Get ID.
Definition SVFValue.h:163

◆ 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 108 of file SVFIR.cpp.

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

◆ addPhiStmt() [2/2]

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

Definition at line 127 of file SVFIR.cpp.

128{
129 SVFVar* opNode = src;
130 SVFVar* resNode = dst;
131
135
136}

◆ addRetNode() [1/2]

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

Add a unique return node for a procedure.

Definition at line 867 of file SVFIR.h.

868 {
869 return addNode(node);
870 }

◆ 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 790 of file SVFIR.h.

791 {
792 SVFVar *node = new RetValPN(i, callGraphNode, type, icn);
793 return addRetNode(callGraphNode, node);
794 }
NodeID addRetNode(NodeID i, const FunObjVar *callGraphNode, const SVFType *type, const ICFGNode *icn)
Add a unique return node for a procedure.
Definition SVFIR.h:790

◆ 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 340 of file SVFIR.cpp.

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

◆ addRetPE() [2/2]

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

Definition at line 354 of file SVFIR.cpp.

355{
357 addEdge(src, dst, edge);
358}

◆ addSelectStmt() [1/2]

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

Add SelectStmt.

Add Phi statement

Definition at line 141 of file SVFIR.cpp.

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

◆ addSelectStmt() [2/2]

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

Definition at line 158 of file SVFIR.cpp.

159{
161 addEdge(src, dst, edge);
162}

◆ 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 739 of file SVFIR.h.

740 {
741 StackObjVar *stackObj = new StackObjVar(i, ti, node);
742 return addBaseObjNode(stackObj);
743 }

◆ 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 287 of file SVFIR.cpp.

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

◆ addStoreStmt() [2/2]

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

Definition at line 301 of file SVFIR.cpp.

302{
304 addEdge(src,dst, edge);
305}

◆ 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 374 of file SVFIR.cpp.

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

◆ 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 398 of file SVFIR.cpp.

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

◆ 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 601 of file SVFIR.h.

602 {
603 bool added = KindToSVFStmtSetMap[edge->getEdgeKind()].insert(edge).second;
604 (void)added; // Suppress warning of unused variable under release build
605 assert(added && "duplicated edge, not added!!!");
607 if (edge->isPTAEdge() || (SVFUtil::isa<CopyStmt>(edge) && SVFUtil::cast<CopyStmt>(edge)->isInt2Ptr()))
608 {
610 KindToPTASVFStmtSetMap[edge->getEdgeKind()].insert(edge);
611 }
612 }
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
SVFIR edge map containing all PAGEdges.
Definition IRGraph.h:108
u32_t totalPTAPAGEdge
Definition IRGraph.h:112
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
Definition IRGraph.h:109

◆ addToSVFStmtList()

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

Add a SVFStmt into instruction map.

Definition at line 326 of file SVFIR.h.

327 {
328 edge->setICFGNode(inst);
329 icfgNode2SVFStmtsMap[inst].push_back(edge);
330 if (edge->isPTAEdge())
331 icfgNode2PTASVFStmtsMap[inst].push_back(edge);
332 }
ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap
Map an ICFGNode to its SVFStmts.
Definition SVFIR.h:80
ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap
Map an ICFGNode to its PointerAnalysis related SVFStmts.
Definition SVFIR.h:81

◆ 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 334 of file SVFIR.h.

335 {
337 }
TypeLocSetsMap typeLocSetsMap
Map an arg to its base SVFType* and all its field location sets.
Definition SVFIR.h:83

◆ addUnaryOPStmt() [1/2]

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

Add Unary edge.

Add Unary edge

Definition at line 217 of file SVFIR.cpp.

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

◆ addUnaryOPStmt() [2/2]

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

Definition at line 231 of file SVFIR.cpp.

232{
234 addEdge(src, dst, edge);
235}

◆ 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 663 of file SVFIR.h.

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

◆ addValNode() [2/2]

NodeID SVFIR::addValNode ( ValVar node)
private

Add a value (pointer) node.

Definition at line 784 of file SVFIR.cpp.

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

◆ addVarargNode() [1/2]

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

Add a unique vararg node for a procedure.

Definition at line 872 of file SVFIR.h.

873 {
874 return addNode(node);
875 }

◆ 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 796 of file SVFIR.h.

797 {
798 SVFVar *node = new VarArgValPN(i, val, type, n);
799 return addNode(node);
800 }
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 464 of file SVFIR.cpp.

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

◆ callsiteHasRet()

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

Definition at line 411 of file SVFIR.h.

412 {
413 return callSiteRetMap.find(cs) != callSiteRetMap.end();
414 }

◆ destroy()

void SVFIR::destroy ( )
private

Clean up memory.

Clean up memory

Definition at line 633 of file SVFIR.cpp.

634{
635 delete icfg;
636 icfg = nullptr;
637 delete chgraph;
638 chgraph = nullptr;
639 delete callGraph;
640 callGraph = nullptr;
641}
CallGraph * callGraph
all the callsites of a program
Definition SVFIR.h:101

◆ funHasRet()

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

Definition at line 427 of file SVFIR.h.

428 {
429 return funRetMap.find(func) != funRetMap.end();
430 }

◆ 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 572 of file SVFIR.cpp.

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

◆ getAllFieldsObjVars() [2/2]

NodeBS & SVFIR::getAllFieldsObjVars ( NodeID  id)

Get all fields object nodes of an object

Definition at line 581 of file SVFIR.cpp.

582{
583 const SVFVar* node = pag->getSVFVar(id);
584 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
586}
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:496
NodeBS & getAllFieldsObjVars(const BaseObjVar *obj)
Get all fields of an object.
Definition SVFIR.cpp:572

◆ getAllValidPtrs()

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

Return valid pointers.

Definition at line 206 of file SVFIR.h.

207 {
208 return candidatePointers;
209 }
OrderedNodeSet candidatePointers
Definition SVFIR.h:97

◆ 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 496 of file SVFIR.h.

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

◆ getBaseObjVar()

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

Definition at line 157 of file SVFIR.h.

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

◆ 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 552 of file SVFIR.h.

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

◆ getBaseValVar()

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

Definition at line 506 of file SVFIR.h.

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

◆ getCallGraph()

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

Get CG.

Definition at line 246 of file SVFIR.h.

247 {
248 assert(callGraph && "empty CallGraph! Build SVF IR first!");
249 return callGraph;
250 }

◆ 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 359 of file SVFIR.h.

360 {
361 auto it = fParmToCallPEMap.find(param);
362 return it != fParmToCallPEMap.end() ? it->second : nullptr;
363 }

◆ getCallSiteArgsList()

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

Get callsite argument list.

Definition at line 393 of file SVFIR.h.

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

◆ getCallSiteArgsMap()

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

Get callsite argument list.

Definition at line 388 of file SVFIR.h.

389 {
390 return callSiteArgsListMap;
391 }

◆ getCallSiteRet()

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

Get callsite return.

Definition at line 405 of file SVFIR.h.

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

◆ getCallSiteRets()

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

Get callsite return.

Definition at line 400 of file SVFIR.h.

401 {
402 return callSiteRetMap;
403 }

◆ getCallSiteSet()

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

Get all callsites.

Definition at line 349 of file SVFIR.h.

350 {
351 return callSiteSet;
352 }

◆ getCHG()

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

Definition at line 239 of file SVFIR.h.

240 {
241 assert(chgraph && "empty ICFG! Build SVF IR first!");
242 return chgraph;
243 }

◆ getFieldObjNodeNum()

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

Definition at line 439 of file SVFIR.h.

440 {
441 return GepObjVarMap.size();
442 }

◆ 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 593 of file SVFIR.cpp.

594{
595 const SVFVar* node = pag->getSVFVar(id);
596 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
597 const BaseObjVar* obj = getBaseObject(id);
598 if(obj->isFieldInsensitive())
599 {
600 NodeBS bs;
602 return bs;
603 }
604 else
605 return getAllFieldsObjVars(obj);
606}
NodeID getFIObjVar(const BaseObjVar *obj) const
Get a field-insensitive obj SVFIR node according to a mem obj.
Definition SVFIR.h:522
void set(unsigned Idx)

◆ getFieldValNodeNum()

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

Node and edge statistics.

Definition at line 435 of file SVFIR.h.

436 {
437 return GepValObjMap.size();
438 }

◆ 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 522 of file SVFIR.h.

523 {
524 return obj->getId();
525 }

◆ getFIObjVar() [2/2]

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

Definition at line 526 of file SVFIR.h.

527 {
528 return getBaseObjVarID(id);
529 }
NodeID getBaseObjVarID(NodeID id) const
Base and Offset methods for Value and Object node.
Definition SVFIR.h:552

◆ getFunArgsList()

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

Get function arguments list.

Definition at line 376 of file SVFIR.h.

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

◆ getFunArgsMap()

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

Get function arguments list.

Definition at line 371 of file SVFIR.h.

372 {
373 return funArgsListMap;
374 }

◆ getFunObjVar()

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

Definition at line 47 of file SVFIR.cpp.

48{
49 for (const auto &item: *callGraph)
50 {
51 if (item.second->getName() == name)
52 {
53 return item.second->getFunction();
54 }
55 }
56 return nullptr;
57}
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 455 of file SVFIR.h.

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

◆ getFunRet()

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

Get function return list.

Definition at line 421 of file SVFIR.h.

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

◆ getFunRets()

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

Get function return list.

Definition at line 416 of file SVFIR.h.

417 {
418 return funRetMap;
419 }

◆ getGepObjNodeMap()

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

Return GepObjVarMap.

Definition at line 201 of file SVFIR.h.

202 {
203 return GepObjVarMap;
204 }

◆ 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 522 of file SVFIR.cpp.

523{
524 NodeID base = baseObj->getId();
525
527 if (baseObj->isFieldInsensitive())
528 return getFIObjVar(baseObj);
529
530 APOffset newLS = pag->getModulusOffset(baseObj, apOffset);
531
532 // Base and first field are the same memory location.
533 if (Options::FirstFieldEqBase() && newLS == 0) return base;
534
535 OffsetToGepVarMap::iterator iter = GepObjVarMap.find(std::make_pair(base, newLS));
536 if (iter == GepObjVarMap.end())
537 {
540 }
541 else
542 return iter->second;
543
544}
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:35
s64_t APOffset
Definition GeneralType.h:60

◆ getGepObjVar() [2/3]

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

Definition at line 167 of file SVFIR.h.

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

◆ 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 500 of file SVFIR.cpp.

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

◆ 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 611 of file SVFIR.cpp.

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

◆ getGlobalSVFStmtSet()

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

Get global PAGEdges (not in a procedure)

Definition at line 344 of file SVFIR.h.

345 {
346 return globSVFStmtSet;
347 }

◆ getICFG()

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

Definition at line 229 of file SVFIR.h.

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

◆ getIndCallSites()

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

Definition at line 461 of file SVFIR.h.

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

◆ getIndirectCallsites()

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

Add/get indirect callsites.

Definition at line 451 of file SVFIR.h.

452 {
454 }

◆ 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 478 of file SVFIR.h.

479 {
480 return getIntraPAGEdge(getGNode(src), getGNode(dst), kind);
481 }
SVFStmt * getIntraPAGEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind)
Get an edge according to src, dst and kind.
Definition SVFIR.h:478

◆ getIntraPAGEdge() [2/2]

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

Definition at line 482 of file SVFIR.h.

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

◆ getMemToFieldsMap()

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

Return memToFieldsMap.

Definition at line 196 of file SVFIR.h.

197 {
198 return memToFieldsMap;
199 }

◆ getModuleIdentifier()

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

Definition at line 259 of file SVFIR.h.

260 {
261 if (pagReadFromTxt.empty())
262 {
263 assert(!moduleIdentifier.empty() &&
264 "No module found! Reading from a file other than LLVM-IR?");
265 return moduleIdentifier;
266 }
267 else
268 {
269 return pagReadFromTxt;
270 }
271 }
static std::string pagReadFromTxt
Definition SVFIR.h:104
std::string moduleIdentifier
Definition SVFIR.h:106

◆ getObjVar()

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

Definition at line 147 of file SVFIR.h.

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

◆ 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 118 of file SVFIR.h.

119 {
120 if (pag == nullptr)
121 {
122 pag = std::unique_ptr<SVFIR>(new SVFIR(buildFromFile));
123 }
124 return pag.get();
125 }
SVFIR(bool buildFromFile)
Constructor.
Definition SVFIR.cpp:42

◆ getPTASVFStmtList()

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

Given an instruction, get all its PTA PAGEdges.

Definition at line 321 of file SVFIR.h.

322 {
323 return icfgNode2PTASVFStmtsMap[inst];
324 }

◆ getPTASVFStmtSet()

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

Get PTA edges set according to its kind.

Definition at line 301 of file SVFIR.h.

302 {
303 return KindToPTASVFStmtSetMap[kind];
304 }

◆ getSVFStmtList()

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

Given an instruction, get all its PAGEdges.

Definition at line 316 of file SVFIR.h.

317 {
318 return icfgNode2SVFStmtsMap[inst];
319 }

◆ 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 296 of file SVFIR.h.

297 {
298 return KindToSVFStmtSetMap[kind];
299 }

◆ getSVFVar()

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

ObjVar/GepObjVar/BaseObjVar.

Definition at line 133 of file SVFIR.h.

134 {
135 return getGNode(id);
136 }

◆ getSVFVarMap()

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

Return the entire SVFID to SVFVar map.

Definition at line 190 of file SVFIR.h.

191 {
192 return IDToNodeMap;
193 }

◆ 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 339 of file SVFIR.h.

340 {
341 return typeLocSetsMap[argId];
342 }

◆ getValVar()

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

Definition at line 137 of file SVFIR.h.

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

◆ handleBlackHole()

void SVFIR::handleBlackHole ( bool  b)
static

SVFIR build configurations.

Whether to handle blackhole edge

Definition at line 779 of file SVFIR.cpp.

780{
782}
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 383 of file SVFIR.h.

384 {
385 return (callSiteArgsListMap.find(cs) != callSiteArgsListMap.end());
386 }

◆ hasFunArgsList()

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

Function has arguments list.

Definition at line 366 of file SVFIR.h.

367 {
368 return (funArgsListMap.find(func) != funArgsListMap.end());
369 }

◆ hasPTASVFStmtList()

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

Definition at line 310 of file SVFIR.h.

311 {
312 return icfgNode2PTASVFStmtsMap.find(inst) !=
314 }

◆ hasSVFStmtList()

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

Whether this instruction has SVFIR Edge.

Definition at line 306 of file SVFIR.h.

307 {
308 return icfgNode2SVFStmtsMap.find(inst) != icfgNode2SVFStmtsMap.end();
309 }

◆ initialiseCandidatePointers()

void SVFIR::initialiseCandidatePointers ( )

Initialize candidate pointers.

Definition at line 731 of file SVFIR.cpp.

732{
733 // collect candidate pointers for demand-driven analysis
734 for (iterator nIter = begin(); nIter != end(); ++nIter)
735 {
736 NodeID nodeId = nIter->first;
737 // do not compute points-to for isolated node
738 if (isValidPointer(nodeId) == false)
739 continue;
741 }
742}
IDToNodeMapTy::iterator iterator
Node Iterators.
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Definition SVFIR.cpp:747

◆ isBaseObjVar()

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

Definition at line 181 of file SVFIR.h.

182 {
183 return SVFUtil::isa<BaseObjVar>(getSVFVar(id));
184 }

◆ isBlkObjOrConstantObj()

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

Get black hole and constant id.

Definition at line 535 of file SVFIR.h.

536 {
537 return (isBlkObj(id) || isConstantObj(id));
538 }
static bool isBlkObj(NodeID id)
Definition IRGraph.h:165
bool isConstantObj(NodeID id) const
Definition SVFIR.h:540

◆ isConstantObj()

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

Definition at line 540 of file SVFIR.h.

541 {
542 const BaseObjVar* obj = getBaseObject(id);
543 assert(obj && "not an object node?");
544 return isConstantSym(id) ||
545 obj->isConstDataOrConstGlobal();
546 }
static bool isConstantSym(NodeID id)
Definition IRGraph.h:169

◆ isFunPtr()

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

Definition at line 471 of file SVFIR.h.

472 {
473 return (funPtrToCallSitesMap.find(id) != funPtrToCallSitesMap.end());
474 }

◆ isGepObjVar()

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

Definition at line 185 of file SVFIR.h.

186 {
187 return SVFUtil::isa<GepObjVar>(getSVFVar(id));
188 }

◆ isIndirectCallSites()

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

Definition at line 467 of file SVFIR.h.

468 {
469 return (indCallSiteToFunPtrMap.find(cs) != indCallSiteToFunPtrMap.end());
470 }

◆ isObjVar()

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

Definition at line 177 of file SVFIR.h.

178 {
179 return SVFUtil::isa<ObjVar>(getSVFVar(id));
180 }

◆ isPhiNode()

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

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

Definition at line 354 of file SVFIR.h.

355 {
356 return phiNodeMap.find(node) != phiNodeMap.end();
357 }

◆ isValidPointer()

bool SVFIR::isValidPointer ( NodeID  nodeId) const

Whether a node is a valid pointer.

Definition at line 747 of file SVFIR.cpp.

748{
749 const SVFVar* node = pag->getSVFVar(nodeId);
750
751 if(node->isPointer())
752 if (const ValVar* pVar = pag->getBaseValVar(nodeId))
753 if (const ArgValVar* arg = SVFUtil::dyn_cast<ArgValVar>(pVar))
754 if (!(arg->getParent()->isDeclaration()))
755 return true;
756
757 if ((node->getInEdges().empty() && node->getOutEdges().empty()))
758 return false;
759 return node->isPointer();
760}
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 762 of file SVFIR.cpp.

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

◆ pagFileName()

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

Definition at line 273 of file SVFIR.h.

274 {
275 return pagReadFromTxt;
276 }

◆ pagReadFromTXT()

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

Definition at line 278 of file SVFIR.h.

279 {
280 return !pagReadFromTxt.empty();
281 }

◆ print()

void SVFIR::print ( )

Print SVFIR.

Print this SVFIR graph including its nodes and edges

Definition at line 646 of file SVFIR.cpp.

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

◆ releaseSVFIR()

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

Definition at line 126 of file SVFIR.h.

127 {
128 pag = nullptr;
129 }

◆ setCallGraph()

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

Definition at line 252 of file SVFIR.h.

253 {
254 callGraph = cg;
255 }

◆ setCHG()

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

Set/Get CHG.

Definition at line 235 of file SVFIR.h.

236 {
237 chgraph = c;
238 }

◆ setICFG()

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

Set/Get ICFG.

Definition at line 225 of file SVFIR.h.

226 {
227 icfg = i;
228 }

◆ setModuleIdentifier()

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

Definition at line 288 of file SVFIR.h.

289 {
291 }

◆ setPagFromTXT()

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

Definition at line 283 of file SVFIR.h.

284 {
286 }

Friends And Related Symbol Documentation

◆ BVDataPTAImpl

Definition at line 48 of file SVFIR.h.

◆ ExternalPAG

friend class ExternalPAG
friend

Definition at line 45 of file SVFIR.h.

◆ GraphDBClient

friend class GraphDBClient
friend

Definition at line 49 of file SVFIR.h.

◆ GraphDBSVFIRBuilder

friend class GraphDBSVFIRBuilder
friend

Definition at line 50 of file SVFIR.h.

◆ PAGBuilderFromFile

Definition at line 46 of file SVFIR.h.

◆ SVFIRBuilder

Definition at line 44 of file SVFIR.h.

◆ TypeBasedHeapCloning

friend class TypeBasedHeapCloning
friend

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 101 of file SVFIR.h.

◆ callSiteArgsListMap

CSToArgsListMap SVF::SVFIR::callSiteArgsListMap
private

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

Definition at line 90 of file SVFIR.h.

◆ callSiteRetMap

CSToRetMap SVF::SVFIR::callSiteRetMap
private

Map a callsite to its callsite returns PAGNodes.

Definition at line 91 of file SVFIR.h.

◆ callSiteSet

CallSiteSet SVF::SVFIR::callSiteSet
private

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

◆ chgraph

CommonCHGraph* SVF::SVFIR::chgraph
private

Definition at line 99 of file SVFIR.h.

◆ fParmToCallPEMap

FParmToCallPEMap SVF::SVFIR::fParmToCallPEMap
private

Map a formal param to its CallPE.

Definition at line 88 of file SVFIR.h.

◆ funArgsListMap

FunToArgsListMap SVF::SVFIR::funArgsListMap
private

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

Definition at line 89 of file SVFIR.h.

◆ funPtrToCallSitesMap

FunPtrToCallSitesMap SVF::SVFIR::funPtrToCallSitesMap
private

Map a function pointer to the callsites where it is used

Definition at line 94 of file SVFIR.h.

◆ funRetMap

FunToRetMap SVF::SVFIR::funRetMap
private

Map a function to its unique function return PAGNodes.

Definition at line 92 of file SVFIR.h.

◆ GepObjVarMap

OffsetToGepVarMap SVF::SVFIR::GepObjVarMap
private

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

Definition at line 84 of file SVFIR.h.

◆ GepValObjMap

GepValueVarMap SVF::SVFIR::GepValObjMap
private

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

Definition at line 82 of file SVFIR.h.

◆ globSVFStmtSet

SVFStmtSet SVF::SVFIR::globSVFStmtSet
private

Global PAGEdges without control flow information.

Definition at line 86 of file SVFIR.h.

◆ icfg

ICFG* SVF::SVFIR::icfg
private

Definition at line 98 of file SVFIR.h.

◆ icfgNode2PTASVFStmtsMap

ICFGNode2SVFStmtsMap SVF::SVFIR::icfgNode2PTASVFStmtsMap
private

Map an ICFGNode to its PointerAnalysis related SVFStmts.

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

◆ indCallSiteToFunPtrMap

CallSiteToFunPtrMap SVF::SVFIR::indCallSiteToFunPtrMap
private

Map an indirect callsite to its function pointer.

Definition at line 93 of file SVFIR.h.

◆ memToFieldsMap

MemObjToFieldsMap SVF::SVFIR::memToFieldsMap
private

Map a mem object id to all its fields.

Definition at line 85 of file SVFIR.h.

◆ moduleIdentifier

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

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

◆ pagReadFromTxt

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

Definition at line 104 of file SVFIR.h.

◆ phiNodeMap

PHINodeMap SVF::SVFIR::phiNodeMap
private

A set of phi copy edges.

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


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