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

#include <CallGraph.h>

Inheritance diagram for SVF::CallGraphNode:
SVF::GenericNode< CallGraphNode, CallGraphEdge > SVF::SVFValue

Public Member Functions

 CallGraphNode (NodeID i, const FunObjVar *f)
 Constructor.
const std::string & getName () const
const FunObjVar * getFunction () const
 Get function of this call node.
bool isReachableFromProgEntry (Map< NodeID, bool > &reachableFromEntry, NodeBS &visitedNodes) const
 Return TRUE if this function can be reached from main.
virtual const std::string toString () const
Public Member Functions inherited from SVF::GenericNode< CallGraphNode, CallGraphEdge >
 GenericNode (NodeID i, GNodeK k, const SVFType *svfType=nullptr)
 Constructor.
virtual ~GenericNode ()
 Destructor.
bool hasIncomingEdge () const
 Has incoming/outgoing edge set.
bool hasOutgoingEdge () const
iterator OutEdgeBegin ()
 iterators
iterator OutEdgeEnd ()
iterator InEdgeBegin ()
iterator InEdgeEnd ()
const_iterator OutEdgeBegin () const
const_iterator OutEdgeEnd () const
const_iterator InEdgeBegin () const
const_iterator InEdgeEnd () const
virtual iterator directOutEdgeBegin ()
 Iterators used for SCC detection, overwrite it in child class if necessary.
virtual iterator directOutEdgeEnd ()
virtual iterator directInEdgeBegin ()
virtual iterator directInEdgeEnd ()
virtual const_iterator directOutEdgeBegin () const
virtual const_iterator directOutEdgeEnd () const
virtual const_iterator directInEdgeBegin () const
virtual const_iterator directInEdgeEnd () const
bool addIncomingEdge (EdgeType *inEdge)
 Add incoming and outgoing edges.
bool addOutgoingEdge (EdgeType *outEdge)
EdgeType * hasIncomingEdge (EdgeType *edge) const
 Find incoming and outgoing edges.
EdgeType * hasOutgoingEdge (EdgeType *edge) const
const GEdgeSetTy & getOutEdges () const
const GEdgeSetTy & getInEdges () const
u32_t removeIncomingEdge (EdgeType *edge)
u32_t removeOutgoingEdge (EdgeType *edge)
Public Member Functions inherited from SVF::SVFValue
 SVFValue (NodeID i, GNodeK k, const SVFType *ty=nullptr)
NodeID getId () const
 Get ID.
GNodeK getNodeKind () const
 Get node kind.
virtual const SVFType * getType () const
virtual void setName (const std::string &nameInfo)
virtual void setName (std::string &&nameInfo)
virtual void setSourceLoc (const std::string &sourceCodeInfo)
virtual const std::string getSourceLoc () const
const std::string valueOnlyToString () const
const bool hasLLVMValue () const

Static Public Member Functions

static bool classof (const CallGraphNode *)
 Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof (const GenericICFGNodeTy *node)
static bool classof (const SVFValue *node)
Static Public Member Functions inherited from SVF::GenericNode< CallGraphNode, CallGraphEdge >
static bool classof (const GenericNode< CallGraphNode, CallGraphEdge > *)
static bool classof (const SVFValue *)

Private Attributes

const FunObjVar * fun

Friends

OutStream & operator<< (OutStream &o, const CallGraphNode &node)
 Overloading operator << for dumping ICFG node ID.

Additional Inherited Members

Public Types inherited from SVF::GenericNode< CallGraphNode, CallGraphEdge >
typedef CallGraphNode NodeType
typedef CallGraphEdge EdgeType
typedef OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
 Edge kind.
typedef GEdgeSetTy::iterator iterator
typedef GEdgeSetTy::const_iterator const_iterator
Public Types inherited from SVF::SVFValue
enum  GNodeK {
  IntraBlock , GlobalBlock , FunEntryBlock , FunExitBlock ,
  FunCallBlock , FunRetBlock , ValNode , ArgValNode ,
  FunValNode , GepValNode , RetValNode , VarargValNode ,
  GlobalValNode , ConstDataValNode , BlackHoleValNode , ConstFPValNode ,
  ConstIntValNode , ConstNullptrValNode , DummyValNode , IntrinsicValNode ,
  AsmPCValNode , ObjNode , GepObjNode , BaseObjNode ,
  FunObjNode , HeapObjNode , StackObjNode , GlobalObjNode ,
  ConstDataObjNode , ConstFPObjNode , ConstIntObjNode , ConstNullptrObjNode ,
  DummyObjNode , Cmp , BinaryOp , UnaryOp ,
  Branch , DummyVProp , NPtr , FRet ,
  ARet , AParm , FParm , Addr ,
  Copy , Gep , Store , Load ,
  TPhi , TIntraPhi , TInterPhi , FPIN ,
  FPOUT , APIN , APOUT , MPhi ,
  MIntraPhi , MInterPhi , CallNodeKd , CDNodeKd ,
  CFLNodeKd , CHNodeKd , ConstraintNodeKd , TCTNodeKd ,
  BasicBlockKd , OtherKd
}
Static Protected Member Functions inherited from SVF::SVFValue
static bool isICFGNodeKinds (GNodeK n)
 Helper functions to check node kinds.
static bool isInterICFGNodeKind (GNodeK n)
static bool isSVFVarKind (GNodeK n)
static bool isValVarKinds (GNodeK n)
static bool isConstantDataValVar (GNodeK n)
static bool isObjVarKinds (GNodeK n)
static bool isBaseObjVarKinds (GNodeK n)
static bool isConstantDataObjVarKinds (GNodeK n)
static bool isVFGNodeKinds (GNodeK n)
static bool isArgumentVFGNodeKinds (GNodeK n)
static bool isStmtVFGNodeKinds (GNodeK n)
static bool isPHIVFGNodeKinds (GNodeK n)
static bool isMRSVFGNodeKinds (GNodeK n)
static bool isMSSAPHISVFGNodeKinds (GNodeK n)
Protected Attributes inherited from SVF::SVFValue
NodeID id
 Node ID.
GNodeK nodeKind
 Node kind.
const SVFType * type
 SVF type.
std::string name
std::string sourceLoc
 Source code information of this value.

Detailed Description

Definition at line 176 of file CallGraph.h.

Constructor & Destructor Documentation

◆ CallGraphNode()

SVF::CallGraphNode::CallGraphNode ( NodeID i,
const FunObjVar * f )
inline

Constructor.

Definition at line 183 of file CallGraph.h.

184 {
185
186 }
const FunObjVar * fun
Definition CallGraph.h:179
GenericNode< CallGraphNode, CallGraphEdge > GenericPTACallGraphNodeTy
Definition CallGraph.h:175

Member Function Documentation

◆ classof() [1/3]

bool SVF::CallGraphNode::classof ( const CallGraphNode * )
inlinestatic

Methods for support type inquiry through isa, cast, and dyn_cast:

Definition at line 213 of file CallGraph.h.

214 {
215 return true;
216 }

◆ classof() [2/3]

bool SVF::CallGraphNode::classof ( const GenericICFGNodeTy * node)
inlinestatic

Definition at line 218 of file CallGraph.h.

219 {
220 return node->getNodeKind() == CallNodeKd;
221 }

◆ classof() [3/3]

bool SVF::CallGraphNode::classof ( const SVFValue * node)
inlinestatic

Definition at line 223 of file CallGraph.h.

224 {
225 return node->getNodeKind() == CallNodeKd;
226 }

◆ getFunction()

const FunObjVar * SVF::CallGraphNode::getFunction ( ) const
inline

Get function of this call node.

Definition at line 191 of file CallGraph.h.

192 {
193 return fun;
194 }

◆ getName()

const std::string & CallGraphNode::getName ( ) const
virtual

Reimplemented from SVF::SVFValue.

Definition at line 47 of file CallGraph.cpp.

48{
49 return fun->getName();
50}

◆ isReachableFromProgEntry()

bool CallGraphNode::isReachableFromProgEntry ( Map< NodeID, bool > & reachableFromEntry,
NodeBS & visitedNodes ) const

Return TRUE if this function can be reached from main.

Definition at line 95 of file CallGraph.cpp.

96{
97 std::function<bool(const CallGraphNode*)> dfs =
98 [&reachableFromEntry, &visitedNodes, &dfs](const CallGraphNode *v)
99 {
100 NodeID id = v->getId();
101 if (!visitedNodes.test_and_set(id))
102 return reachableFromEntry[id];
103
104 if (SVFUtil::isProgEntryFunction(v->getFunction()))
105 return reachableFromEntry[id] = true;
106
107 bool result = false;
108 for (const_iterator it = v->InEdgeBegin(), eit = v->InEdgeEnd(); it != eit; ++it)
109 {
110 CallGraphEdge* edge = *it;
111 result |= dfs(edge->getSrcNode());
112 if (result)
113 break;
114 }
115 return reachableFromEntry[id] = result;
116 };
117
118 return dfs(this);
119}
CallGraphNode(NodeID i, const FunObjVar *f)
Constructor.
Definition CallGraph.h:183
NodeType * getSrcNode() const
NodeID id
Node ID.
Definition SVFValue.h:204
bool isProgEntryFunction(const FunObjVar *)
Program entry function e.g. main.
Definition SVFUtil.cpp:531
u32_t NodeID
Definition GeneralType.h:76

◆ toString()

const std::string CallGraphNode::toString ( ) const
virtual

Definition at line 82 of file CallGraph.cpp.

83{
84 std::string str;
85 std::stringstream rawstr(str);
86 rawstr << "CallGraphNode ID: " << getId() << " {fun: " << fun->getName() << "}";
87 return rawstr.str();
88}
NodeID getId() const
Get ID.
Definition SVFValue.h:158

◆ operator<<

OutStream & operator<< ( OutStream & o,
const CallGraphNode & node )
friend

Overloading operator << for dumping ICFG node ID.

Definition at line 202 of file CallGraph.h.

203 {
204 o << node.toString();
205 return o;
206 }

Member Data Documentation

◆ fun

const FunObjVar* SVF::CallGraphNode::fun
private

Definition at line 179 of file CallGraph.h.


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