Static Value-Flow Analysis
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
SVF::PTACallGraphEdge Class Reference

#include <PTACallGraph.h>

Inheritance diagram for SVF::PTACallGraphEdge:
SVF::GenericEdge< NodeTy > SVF::HareParForEdge SVF::ThreadForkEdge SVF::ThreadJoinEdge

Public Types

enum  CEDGEK { CallRetEdge , TDForkEdge , TDJoinEdge , HareParForEdge }
 
typedef Set< const CallICFGNode * > CallInstSet
 
typedef GenericNode< PTACallGraphNode, PTACallGraphEdge >::GEdgeSetTy CallGraphEdgeSet
 
- Public Types inherited from SVF::GenericEdge< NodeTy >
typedef NodeTy NodeType
 Node type. More...
 
typedef u64_t GEdgeFlag
 
typedef s64_t GEdgeKind
 
typedef struct SVF::GenericEdge::equalGEdge equalGEdge
 Add the hash function for std::set (we also can overload operator< to implement this) More...
 

Public Member Functions

 PTACallGraphEdge (PTACallGraphNode *s, PTACallGraphNode *d, CEDGEK kind, CallSiteID cs)
 Constructor. More...
 
virtual ~PTACallGraphEdge ()
 Destructor. More...
 
CallSiteID getCallSiteID () const
 Get direct and indirect calls. More...
 
bool isDirectCallEdge () const
 
bool isIndirectCallEdge () const
 
CallInstSetgetDirectCalls ()
 
CallInstSetgetIndirectCalls ()
 
const CallInstSetgetDirectCalls () const
 
const CallInstSetgetIndirectCalls () const
 
void addDirectCallSite (const CallICFGNode *call)
 Add direct and indirect callsite. More...
 
void addInDirectCallSite (const CallICFGNode *call)
 
CallInstSet::const_iterator directCallsBegin () const
 Iterators for direct and indirect callsites. More...
 
CallInstSet::const_iterator directCallsEnd () const
 
CallInstSet::const_iterator indirectCallsBegin () const
 
CallInstSet::const_iterator indirectCallsEnd () const
 
virtual const std::string toString () const
 
- Public Member Functions inherited from SVF::GenericEdge< NodeTy >
 GenericEdge (NodeTy *s, NodeTy *d, GEdgeFlag k)
 Constructor. More...
 
virtual ~GenericEdge ()
 Destructor. More...
 
NodeID getSrcID () const
 get methods of the components More...
 
NodeID getDstID () const
 
GEdgeKind getEdgeKind () const
 
GEdgeKind getEdgeKindWithoutMask () const
 
NodeTypegetSrcNode () const
 
NodeTypegetDstNode () const
 
virtual bool operator== (const GenericEdge< NodeType > *rhs) const
 

Static Public Member Functions

static GEdgeFlag makeEdgeFlagWithInvokeID (GEdgeKind k, CallSiteID cs)
 Compute the unique edgeFlag value from edge kind and CallSiteID. More...
 
static bool classof (const PTACallGraphEdge *)
 ClassOf. More...
 
static bool classof (const GenericCallGraphEdgeTy *edge)
 

Private Attributes

CallInstSet directCalls
 
CallInstSet indirectCalls
 
CallSiteID csId
 

Friends

OutStreamoperator<< (OutStream &o, const PTACallGraphEdge &edge)
 Overloading operator << for dumping ICFG node ID. More...
 

Additional Inherited Members

- Static Protected Attributes inherited from SVF::GenericEdge< NodeTy >
static constexpr unsigned char EdgeKindMaskBits = 8
 We use the lower 8 bits to denote edge kind. More...
 
static constexpr u64_t EdgeKindMask = (~0ULL) >> (64 - EdgeKindMaskBits)
 

Detailed Description

Definition at line 51 of file PTACallGraph.h.

Member Typedef Documentation

◆ CallGraphEdgeSet

Definition at line 166 of file PTACallGraph.h.

◆ CallInstSet

Definition at line 55 of file PTACallGraph.h.

Member Enumeration Documentation

◆ CEDGEK

Enumerator
CallRetEdge 
TDForkEdge 
TDJoinEdge 
HareParForEdge 

Definition at line 56 of file PTACallGraph.h.

Constructor & Destructor Documentation

◆ PTACallGraphEdge()

SVF::PTACallGraphEdge::PTACallGraphEdge ( PTACallGraphNode s,
PTACallGraphNode d,
CEDGEK  kind,
CallSiteID  cs 
)
inline

Constructor.

Definition at line 68 of file PTACallGraph.h.

68  :
70  {
71  }
static GEdgeFlag makeEdgeFlagWithInvokeID(GEdgeKind k, CallSiteID cs)
Compute the unique edgeFlag value from edge kind and CallSiteID.
Definition: PTACallGraph.h:77
GenericEdge< PTACallGraphNode > GenericCallGraphEdgeTy
Definition: PTACallGraph.h:42

◆ ~PTACallGraphEdge()

virtual SVF::PTACallGraphEdge::~PTACallGraphEdge ( )
inlinevirtual

Destructor.

Definition at line 73 of file PTACallGraph.h.

74  {
75  }

Member Function Documentation

◆ addDirectCallSite()

void PTACallGraphEdge::addDirectCallSite ( const CallICFGNode call)

Add direct and indirect callsite.

Definition at line 47 of file PTACallGraph.cpp.

48 {
49  assert(call->getCalledFunction() && "not a direct callsite??");
50  directCalls.insert(call);
51 }
const SVFFunction * getCalledFunction() const
Definition: ICFGNode.h:518
CallInstSet directCalls
Definition: PTACallGraph.h:63

◆ addInDirectCallSite()

void PTACallGraphEdge::addInDirectCallSite ( const CallICFGNode call)

Definition at line 53 of file PTACallGraph.cpp.

54 {
55  assert((nullptr == call->getCalledFunction() || nullptr == SVFUtil::dyn_cast<SVFFunction> (SVFUtil::getForkedFun(call)->getValue())) && "not an indirect callsite??");
56  indirectCalls.insert(call);
57 }
CallInstSet indirectCalls
Definition: PTACallGraph.h:64
const SVFValue * getValue() const
Get/has methods of the components.
Definition: SVFVariables.h:83
const SVFVar * getForkedFun(const CallICFGNode *inst)
Return thread fork function.
Definition: SVFUtil.h:356

◆ classof() [1/2]

static bool SVF::PTACallGraphEdge::classof ( const GenericCallGraphEdgeTy edge)
inlinestatic

Definition at line 147 of file PTACallGraph.h.

148  {
149  return edge->getEdgeKind() == PTACallGraphEdge::CallRetEdge ||
150  edge->getEdgeKind() == PTACallGraphEdge::TDForkEdge ||
151  edge->getEdgeKind() == PTACallGraphEdge::TDJoinEdge;
152  }

◆ classof() [2/2]

static bool SVF::PTACallGraphEdge::classof ( const PTACallGraphEdge )
inlinestatic

ClassOf.

Definition at line 143 of file PTACallGraph.h.

144  {
145  return true;
146  }

◆ directCallsBegin()

CallInstSet::const_iterator SVF::PTACallGraphEdge::directCallsBegin ( ) const
inline

Iterators for direct and indirect callsites.

Definition at line 122 of file PTACallGraph.h.

123  {
124  return directCalls.begin();
125  }

◆ directCallsEnd()

CallInstSet::const_iterator SVF::PTACallGraphEdge::directCallsEnd ( ) const
inline

Definition at line 126 of file PTACallGraph.h.

127  {
128  return directCalls.end();
129  }

◆ getCallSiteID()

CallSiteID SVF::PTACallGraphEdge::getCallSiteID ( ) const
inline

Get direct and indirect calls.

Definition at line 83 of file PTACallGraph.h.

84  {
85  return csId;
86  }

◆ getDirectCalls() [1/2]

CallInstSet& SVF::PTACallGraphEdge::getDirectCalls ( )
inline

Definition at line 95 of file PTACallGraph.h.

96  {
97  return directCalls;
98  }

◆ getDirectCalls() [2/2]

const CallInstSet& SVF::PTACallGraphEdge::getDirectCalls ( ) const
inline

Definition at line 103 of file PTACallGraph.h.

104  {
105  return directCalls;
106  }

◆ getIndirectCalls() [1/2]

CallInstSet& SVF::PTACallGraphEdge::getIndirectCalls ( )
inline

Definition at line 99 of file PTACallGraph.h.

100  {
101  return indirectCalls;
102  }

◆ getIndirectCalls() [2/2]

const CallInstSet& SVF::PTACallGraphEdge::getIndirectCalls ( ) const
inline

Definition at line 107 of file PTACallGraph.h.

108  {
109  return indirectCalls;
110  }

◆ indirectCallsBegin()

CallInstSet::const_iterator SVF::PTACallGraphEdge::indirectCallsBegin ( ) const
inline

Definition at line 131 of file PTACallGraph.h.

132  {
133  return indirectCalls.begin();
134  }

◆ indirectCallsEnd()

CallInstSet::const_iterator SVF::PTACallGraphEdge::indirectCallsEnd ( ) const
inline

Definition at line 135 of file PTACallGraph.h.

136  {
137  return indirectCalls.end();
138  }

◆ isDirectCallEdge()

bool SVF::PTACallGraphEdge::isDirectCallEdge ( ) const
inline

Definition at line 87 of file PTACallGraph.h.

88  {
89  return !directCalls.empty() && indirectCalls.empty();
90  }

◆ isIndirectCallEdge()

bool SVF::PTACallGraphEdge::isIndirectCallEdge ( ) const
inline

Definition at line 91 of file PTACallGraph.h.

92  {
93  return directCalls.empty() && !indirectCalls.empty();
94  }

◆ makeEdgeFlagWithInvokeID()

static GEdgeFlag SVF::PTACallGraphEdge::makeEdgeFlagWithInvokeID ( GEdgeKind  k,
CallSiteID  cs 
)
inlinestatic

Compute the unique edgeFlag value from edge kind and CallSiteID.

Definition at line 77 of file PTACallGraph.h.

78  {
79  return (cs << EdgeKindMaskBits) | k;
80  }
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
Definition: GenericGraph.h:132

◆ toString()

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

Reimplemented in SVF::ThreadJoinEdge, and SVF::ThreadForkEdge.

Definition at line 60 of file PTACallGraph.cpp.

61 {
62  std::string str;
63  std::stringstream rawstr(str);
64  rawstr << "CallSite ID: " << getCallSiteID();
65  if(isDirectCallEdge())
66  rawstr << "direct call";
67  else
68  rawstr << "indirect call";
69  rawstr << "[" << getDstID() << "<--" << getSrcID() << "]\t";
70  return rawstr.str();
71 }
const char *const string
Definition: cJSON.h:172
NodeID getDstID() const
Definition: GenericGraph.h:85
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:81
bool isDirectCallEdge() const
Definition: PTACallGraph.h:87
CallSiteID getCallSiteID() const
Get direct and indirect calls.
Definition: PTACallGraph.h:83

Friends And Related Function Documentation

◆ operator<<

OutStream& operator<< ( OutStream o,
const PTACallGraphEdge edge 
)
friend

Overloading operator << for dumping ICFG node ID.

Definition at line 157 of file PTACallGraph.h.

158  {
159  o << edge.toString();
160  return o;
161  }

Member Data Documentation

◆ csId

CallSiteID SVF::PTACallGraphEdge::csId
private

Definition at line 65 of file PTACallGraph.h.

◆ directCalls

CallInstSet SVF::PTACallGraphEdge::directCalls
private

Definition at line 63 of file PTACallGraph.h.

◆ indirectCalls

CallInstSet SVF::PTACallGraphEdge::indirectCalls
private

Definition at line 64 of file PTACallGraph.h.


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