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 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.
 
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 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 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:101
ICFG * icfg
Definition SVFIR.h:100
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~SVFIR()

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

Destructor.

Definition at line 216 of file SVFIR.h.

217 {
218 destroy();
219 }
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:257
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:272
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:295
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:139

◆ 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:105

◆ 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:90

◆ 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:102

◆ 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:92

◆ 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:93

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

806{
807 return addObjNode(node);
808}

◆ 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:235
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:91

◆ 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:94

◆ 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:88

◆ 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:95
FunPtrToCallSitesMap funPtrToCallSitesMap
Definition SVFIR.h:96

◆ 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 return addNode(node);
803}
bool hasGNode(NodeID id) const
Has a node.
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:89
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 328 of file SVFIR.h.

329 {
330 edge->setICFGNode(inst);
331 icfgNode2SVFStmtsMap[inst].push_back(edge);
332 if (edge->isPTAEdge())
333 icfgNode2PTASVFStmtsMap[inst].push_back(edge);
334 }
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 336 of file SVFIR.h.

337 {
339 }
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 413 of file SVFIR.h.

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

◆ 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:103

◆ funHasRet()

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

Definition at line 429 of file SVFIR.h.

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

◆ 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}
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:498
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 208 of file SVFIR.h.

209 {
210 return candidatePointers;
211 }
OrderedNodeSet candidatePointers
Definition SVFIR.h:99

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

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

◆ getBaseObjVar()

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

Definition at line 159 of file SVFIR.h.

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

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

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

◆ getCallGraph()

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

Get CG.

Definition at line 248 of file SVFIR.h.

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

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

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

◆ getCallSiteArgsList()

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

Get callsite argument list.

Definition at line 395 of file SVFIR.h.

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

◆ getCallSiteArgsMap()

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

Get callsite argument list.

Definition at line 390 of file SVFIR.h.

391 {
392 return callSiteArgsListMap;
393 }

◆ getCallSiteRet()

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

Get callsite return.

Definition at line 407 of file SVFIR.h.

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

◆ getCallSiteRets()

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

Get callsite return.

Definition at line 402 of file SVFIR.h.

403 {
404 return callSiteRetMap;
405 }

◆ getCallSiteSet()

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

Get all callsites.

Definition at line 351 of file SVFIR.h.

352 {
353 return callSiteSet;
354 }

◆ getCHG()

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

Definition at line 241 of file SVFIR.h.

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

◆ getFieldObjNodeNum()

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

Definition at line 441 of file SVFIR.h.

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

◆ 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:524
void set(unsigned Idx)

◆ getFieldValNodeNum()

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

Node and edge statistics.

Definition at line 437 of file SVFIR.h.

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

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

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

◆ getFIObjVar() [2/2]

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

Definition at line 528 of file SVFIR.h.

529 {
530 return getBaseObjVarID(id);
531 }
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 378 of file SVFIR.h.

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

◆ getFunArgsMap()

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

Get function arguments list.

Definition at line 373 of file SVFIR.h.

374 {
375 return funArgsListMap;
376 }

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

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

◆ getFunRet()

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

Get function return list.

Definition at line 423 of file SVFIR.h.

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

◆ getFunRets()

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

Get function return list.

Definition at line 418 of file SVFIR.h.

419 {
420 return funRetMap;
421 }

◆ getGepObjNodeMap()

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

Return GepObjVarMap.

Definition at line 203 of file SVFIR.h.

204 {
205 return GepObjVarMap;
206 }

◆ 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:99
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 169 of file SVFIR.h.

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

◆ 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:169

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

347 {
348 return globSVFStmtSet;
349 }

◆ getICFG()

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

Definition at line 231 of file SVFIR.h.

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

◆ getIndCallSites()

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

Definition at line 463 of file SVFIR.h.

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

◆ getIndirectCallsites()

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

Add/get indirect callsites.

Definition at line 453 of file SVFIR.h.

454 {
456 }

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

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

◆ getIntraPAGEdge() [2/2]

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

Definition at line 484 of file SVFIR.h.

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

◆ getMemToFieldsMap()

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

Return memToFieldsMap.

Definition at line 198 of file SVFIR.h.

199 {
200 return memToFieldsMap;
201 }

◆ getModuleIdentifier()

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

Definition at line 261 of file SVFIR.h.

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

◆ getObjVar()

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

Definition at line 149 of file SVFIR.h.

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

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

121 {
122 if (pag == nullptr)
123 {
124 pag = std::unique_ptr<SVFIR>(new SVFIR(buildFromFile));
125 }
126 return pag.get();
127 }
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 323 of file SVFIR.h.

324 {
325 return icfgNode2PTASVFStmtsMap[inst];
326 }

◆ getPTASVFStmtSet()

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

Get PTA edges set according to its kind.

Definition at line 303 of file SVFIR.h.

304 {
305 return KindToPTASVFStmtSetMap[kind];
306 }

◆ getSVFStmtList()

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

Given an instruction, get all its PAGEdges.

Definition at line 318 of file SVFIR.h.

319 {
320 return icfgNode2SVFStmtsMap[inst];
321 }

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

299 {
300 return KindToSVFStmtSetMap[kind];
301 }

◆ getSVFVar()

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

ObjVar/GepObjVar/BaseObjVar.

Definition at line 135 of file SVFIR.h.

136 {
137 return getGNode(id);
138 }

◆ getSVFVarMap()

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

Return the entire SVFID to SVFVar map.

Definition at line 192 of file SVFIR.h.

193 {
194 return IDToNodeMap;
195 }

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

342 {
343 return typeLocSetsMap[argId];
344 }

◆ getValVar()

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

Definition at line 139 of file SVFIR.h.

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

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

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

◆ hasFunArgsList()

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

Function has arguments list.

Definition at line 368 of file SVFIR.h.

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

◆ hasPTASVFStmtList()

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

Definition at line 312 of file SVFIR.h.

313 {
314 return icfgNode2PTASVFStmtsMap.find(inst) !=
316 }

◆ hasSVFStmtList()

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

Whether this instruction has SVFIR Edge.

Definition at line 308 of file SVFIR.h.

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

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

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

◆ isBlkObjOrConstantObj()

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

Get black hole and constant id.

Definition at line 537 of file SVFIR.h.

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

◆ isConstantObj()

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

Definition at line 542 of file SVFIR.h.

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

◆ isFunPtr()

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

Definition at line 473 of file SVFIR.h.

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

◆ isGepObjVar()

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

Definition at line 187 of file SVFIR.h.

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

◆ isIndirectCallSites()

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

Definition at line 469 of file SVFIR.h.

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

◆ isObjVar()

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

Definition at line 179 of file SVFIR.h.

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

◆ isPhiNode()

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

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

Definition at line 356 of file SVFIR.h.

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

◆ 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:426

◆ pagFileName()

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

Definition at line 275 of file SVFIR.h.

276 {
277 return pagReadFromTxt;
278 }

◆ pagReadFromTXT()

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

Definition at line 280 of file SVFIR.h.

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

◆ 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:52

◆ releaseSVFIR()

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

Definition at line 128 of file SVFIR.h.

129 {
130 pag = nullptr;
131 }

◆ setCallGraph()

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

Definition at line 254 of file SVFIR.h.

255 {
256 callGraph = cg;
257 }

◆ setCHG()

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

Set/Get CHG.

Definition at line 237 of file SVFIR.h.

238 {
239 chgraph = c;
240 }

◆ setICFG()

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

Set/Get ICFG.

Definition at line 227 of file SVFIR.h.

228 {
229 icfg = i;
230 }

◆ setModuleIdentifier()

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

Definition at line 290 of file SVFIR.h.

291 {
293 }

◆ setPagFromTXT()

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

Definition at line 285 of file SVFIR.h.

286 {
288 }

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

◆ callSiteArgsListMap

CSToArgsListMap SVF::SVFIR::callSiteArgsListMap
private

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

Definition at line 92 of file SVFIR.h.

◆ callSiteRetMap

CSToRetMap SVF::SVFIR::callSiteRetMap
private

Map a callsite to its callsite returns PAGNodes.

Definition at line 93 of file SVFIR.h.

◆ callSiteSet

CallSiteSet SVF::SVFIR::callSiteSet
private

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

◆ chgraph

CommonCHGraph* SVF::SVFIR::chgraph
private

Definition at line 101 of file SVFIR.h.

◆ fParmToCallPEMap

FParmToCallPEMap SVF::SVFIR::fParmToCallPEMap
private

Map a formal param to its CallPE.

Definition at line 90 of file SVFIR.h.

◆ funArgsListMap

FunToArgsListMap SVF::SVFIR::funArgsListMap
private

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

Definition at line 91 of file SVFIR.h.

◆ funPtrToCallSitesMap

FunPtrToCallSitesMap SVF::SVFIR::funPtrToCallSitesMap
private

Map a function pointer to the callsites where it is used

Definition at line 96 of file SVFIR.h.

◆ funRetMap

FunToRetMap SVF::SVFIR::funRetMap
private

Map a function to its unique function return PAGNodes.

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

◆ icfg

ICFG* SVF::SVFIR::icfg
private

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

◆ pagReadFromTxt

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

Definition at line 106 of file SVFIR.h.

◆ phiNodeMap

PHINodeMap SVF::SVFIR::phiNodeMap
private

A set of phi copy edges.

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