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

#include <SVFStatements.h>

Inheritance diagram for SVF::SVFStmt:
SVF::GenericEdge< NodeTy > SVF::AssignStmt SVF::BranchStmt SVF::MultiOpndStmt SVF::UnaryOPStmt SVF::AddrStmt SVF::CallPE SVF::CopyStmt SVF::GepStmt SVF::LoadStmt SVF::RetPE SVF::StoreStmt SVF::BinaryOPStmt SVF::CmpStmt SVF::PhiStmt SVF::SelectStmt

Public Types

enum  PEDGEK {
  Addr , Copy , Store , Load ,
  Call , Ret , Gep , Phi ,
  Select , Cmp , BinaryOp , UnaryOp ,
  Branch , ThreadFork , ThreadJoin
}
 
typedef GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
 
typedef Map< EdgeID, SVFStmtSetTyPAGEdgeToSetMapTy
 
typedef PAGEdgeToSetMapTy KindToSVFStmtMapTy
 
typedef SVFStmtSetTy PAGEdgeSetTy
 
- 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

 SVFStmt (SVFVar *s, SVFVar *d, GEdgeFlag k, bool real=true)
 Constructor. More...
 
 ~SVFStmt ()
 Destructor. More...
 
EdgeID getEdgeID () const
 Return Edge ID. More...
 
bool isPTAEdge () const
 Whether src and dst nodes are both of pointer type. More...
 
const SVFInstructiongetInst () const
 Get/set methods for llvm instruction. More...
 
void setValue (const SVFValue *val)
 
const SVFValuegetValue () const
 
void setBB (const SVFBasicBlock *bb)
 
const SVFBasicBlockgetBB () const
 
void setICFGNode (ICFGNode *node)
 
ICFGNodegetICFGNode () 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 bool classof (const SVFStmt *)
 ClassOf. More...
 
static bool classof (const GenericPAGEdgeTy *edge)
 
static GEdgeFlag makeEdgeFlagWithAddionalOpnd (GEdgeKind k, const SVFVar *var)
 
static GEdgeFlag makeEdgeFlagWithCallInst (GEdgeKind k, const ICFGNode *cs)
 
static GEdgeFlag makeEdgeFlagWithStoreInst (GEdgeKind k, const ICFGNode *store)
 

Static Public Attributes

static u32_t totalEdgeNum
 Total edge number. More...
 

Protected Member Functions

 SVFStmt (GEdgeFlag k)
 Private constructor for reading SVFIR from file without side-effect. More...
 

Private Types

typedef Map< const ICFGNode *, u32_tInst2LabelMap
 
typedef Map< const SVFVar *, u32_tVar2LabelMap
 

Private Attributes

const SVFValuevalue
 LLVM value. More...
 
const SVFBasicBlockbasicBlock
 LLVM BasicBlock. More...
 
ICFGNodeicfgNode
 ICFGNode. More...
 
EdgeID edgeId
 Edge ID. More...
 

Static Private Attributes

static Inst2LabelMap inst2LabelMap
 Call site Instruction to label map. More...
 
static Var2LabelMap var2LabelMap
 Second operand of MultiOpndStmt to label map. More...
 
static u64_t callEdgeLabelCounter = 0
 Call site Instruction counter. More...
 
static u64_t storeEdgeLabelCounter = 0
 Store Instruction counter. More...
 
static u64_t multiOpndLabelCounter = 0
 MultiOpndStmt counter. More...
 

Friends

class SVFIRWriter
 
class SVFIRReader
 
OutStreamoperator<< (OutStream &o, const SVFStmt &edge)
 Overloading operator << for dumping SVFVar value. 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 SVFStatements.h.

Member Typedef Documentation

◆ Inst2LabelMap

typedef Map<const ICFGNode*, u32_t> SVF::SVFStmt::Inst2LabelMap
private

Definition at line 223 of file SVFStatements.h.

◆ KindToSVFStmtMapTy

Definition at line 219 of file SVFStatements.h.

◆ PAGEdgeSetTy

Definition at line 220 of file SVFStatements.h.

◆ PAGEdgeToSetMapTy

Definition at line 218 of file SVFStatements.h.

◆ SVFStmtSetTy

Definition at line 217 of file SVFStatements.h.

◆ Var2LabelMap

typedef Map<const SVFVar*, u32_t> SVF::SVFStmt::Var2LabelMap
private

Definition at line 224 of file SVFStatements.h.

Member Enumeration Documentation

◆ PEDGEK

Types of SVFIR statements Gep represents (base + offset) for field sensitivity ThreadFork/ThreadJoin is to model parameter passings between thread spawners and spawnees.

Enumerator
Addr 
Copy 
Store 
Load 
Call 
Ret 
Gep 
Phi 
Select 
Cmp 
BinaryOp 
UnaryOp 
Branch 
ThreadFork 
ThreadJoin 

Definition at line 61 of file SVFStatements.h.

Constructor & Destructor Documentation

◆ SVFStmt() [1/2]

SVF::SVFStmt::SVFStmt ( GEdgeFlag  k)
inlineprotected

Private constructor for reading SVFIR from file without side-effect.

Definition at line 88 of file SVFStatements.h.

89  : GenericPAGEdgeTy({}, {}, k), value{}, basicBlock{}, icfgNode{}
90  {
91  }
ICFGNode * icfgNode
ICFGNode.
Definition: SVFStatements.h:83
const SVFValue * value
LLVM value.
Definition: SVFStatements.h:81
const SVFBasicBlock * basicBlock
LLVM BasicBlock.
Definition: SVFStatements.h:82
GenericEdge< SVFVar > GenericPAGEdgeTy
Definition: SVFStatements.h:45

◆ SVFStmt() [2/2]

SVFStmt::SVFStmt ( SVFVar s,
SVFVar d,
GEdgeFlag  k,
bool  real = true 
)

Constructor.

SVFStmt constructor

Definition at line 48 of file SVFStatements.cpp.

48  :
49  GenericPAGEdgeTy(s,d,k),value(nullptr),basicBlock(nullptr),icfgNode(nullptr),edgeId(UINT_MAX)
50 {
51  if(real)
52  {
55  }
56 }
u32_t getTotalEdgeNum() const
Definition: GenericGraph.h:684
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition: SVFIR.h:115
EdgeID edgeId
Edge ID.
Definition: SVFStatements.h:84

◆ ~SVFStmt()

SVF::SVFStmt::~SVFStmt ( )
inline

Destructor.

Definition at line 99 of file SVFStatements.h.

99 {}

Member Function Documentation

◆ classof() [1/2]

static bool SVF::SVFStmt::classof ( const GenericPAGEdgeTy edge)
inlinestatic

Definition at line 107 of file SVFStatements.h.

108  {
109  return edge->getEdgeKind() == SVFStmt::Addr ||
110  edge->getEdgeKind() == SVFStmt::Copy ||
111  edge->getEdgeKind() == SVFStmt::Store ||
112  edge->getEdgeKind() == SVFStmt::Load ||
113  edge->getEdgeKind() == SVFStmt::Call ||
114  edge->getEdgeKind() == SVFStmt::Ret ||
115  edge->getEdgeKind() == SVFStmt::Gep ||
116  edge->getEdgeKind() == SVFStmt::Phi ||
117  edge->getEdgeKind() == SVFStmt::Select ||
118  edge->getEdgeKind() == SVFStmt::Cmp ||
119  edge->getEdgeKind() == SVFStmt::BinaryOp ||
120  edge->getEdgeKind() == SVFStmt::UnaryOp ||
121  edge->getEdgeKind() == SVFStmt::Branch ||
122  edge->getEdgeKind() == SVFStmt::ThreadFork ||
123  edge->getEdgeKind() == SVFStmt::ThreadJoin;
124  }

◆ classof() [2/2]

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

ClassOf.

Definition at line 103 of file SVFStatements.h.

104  {
105  return true;
106  }

◆ getBB()

const SVFBasicBlock* SVF::SVFStmt::getBB ( ) const
inline

Definition at line 155 of file SVFStatements.h.

156  {
157  return basicBlock;
158  }

◆ getEdgeID()

EdgeID SVF::SVFStmt::getEdgeID ( ) const
inline

Return Edge ID.

Definition at line 128 of file SVFStatements.h.

129  {
130  return edgeId;
131  }

◆ getICFGNode()

ICFGNode* SVF::SVFStmt::getICFGNode ( ) const
inline

Definition at line 163 of file SVFStatements.h.

164  {
165  return icfgNode;
166  }

◆ getInst()

const SVFInstruction* SVF::SVFStmt::getInst ( ) const
inline

Get/set methods for llvm instruction.

Definition at line 137 of file SVFStatements.h.

138  {
139  if (const SVFInstruction* i = SVFUtil::dyn_cast<SVFInstruction>(value))
140  return i;
141  return nullptr;
142  }

◆ getValue()

const SVFValue* SVF::SVFStmt::getValue ( ) const
inline

Definition at line 147 of file SVFStatements.h.

148  {
149  return value;
150  }

◆ isPTAEdge()

bool SVFStmt::isPTAEdge ( ) const

Whether src and dst nodes are both of pointer type.

Whether src and dst nodes are both pointer type

Definition at line 61 of file SVFStatements.cpp.

62 {
63  return getSrcNode()->isPointer() && getDstNode()->isPointer();
64 }
NodeType * getSrcNode() const
Definition: GenericGraph.h:97
NodeType * getDstNode() const
Definition: GenericGraph.h:101

◆ makeEdgeFlagWithAddionalOpnd()

static GEdgeFlag SVF::SVFStmt::makeEdgeFlagWithAddionalOpnd ( GEdgeKind  k,
const SVFVar var 
)
inlinestatic

Compute the unique edgeFlag value from edge kind and second variable operand for MultiOpndStmt.

Definition at line 171 of file SVFStatements.h.

173  {
174  auto it_inserted = var2LabelMap.emplace(var, multiOpndLabelCounter);
175  if (it_inserted.second)
177  u64_t label = it_inserted.first->second;
178  return (label << EdgeKindMaskBits) | k;
179  }
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
Definition: GenericGraph.h:132
static Var2LabelMap var2LabelMap
Second operand of MultiOpndStmt to label map.
static u64_t multiOpndLabelCounter
MultiOpndStmt counter.
unsigned long long u64_t
Definition: GeneralType.h:48

◆ makeEdgeFlagWithCallInst()

static GEdgeFlag SVF::SVFStmt::makeEdgeFlagWithCallInst ( GEdgeKind  k,
const ICFGNode cs 
)
inlinestatic

Compute the unique edgeFlag value from edge kind and call site Instruction.

Definition at line 183 of file SVFStatements.h.

185  {
186  auto it_inserted = inst2LabelMap.emplace(cs, callEdgeLabelCounter);
187  if (it_inserted.second)
189  u64_t label = it_inserted.first->second;
190  return (label << EdgeKindMaskBits) | k;
191  }
static u64_t callEdgeLabelCounter
Call site Instruction counter.
static Inst2LabelMap inst2LabelMap
Call site Instruction to label map.

◆ makeEdgeFlagWithStoreInst()

static GEdgeFlag SVF::SVFStmt::makeEdgeFlagWithStoreInst ( GEdgeKind  k,
const ICFGNode store 
)
inlinestatic

Compute the unique edgeFlag value from edge kind and store Instruction. Two store instructions may share the same StorePAGEdge

Definition at line 195 of file SVFStatements.h.

197  {
198  auto it_inserted = inst2LabelMap.emplace(store, storeEdgeLabelCounter);
199  if (it_inserted.second)
201  u64_t label = it_inserted.first->second;
202  return (label << EdgeKindMaskBits) | k;
203  }
static u64_t storeEdgeLabelCounter
Store Instruction counter.

◆ setBB()

void SVF::SVFStmt::setBB ( const SVFBasicBlock bb)
inline

Definition at line 151 of file SVFStatements.h.

152  {
153  basicBlock = bb;
154  }

◆ setICFGNode()

void SVF::SVFStmt::setICFGNode ( ICFGNode node)
inline

Definition at line 159 of file SVFStatements.h.

160  {
161  icfgNode = node;
162  }

◆ setValue()

void SVF::SVFStmt::setValue ( const SVFValue val)
inline

Definition at line 143 of file SVFStatements.h.

144  {
145  value = val;
146  }

◆ toString()

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

Reimplemented in SVF::BranchStmt, SVF::UnaryOPStmt, SVF::BinaryOPStmt, SVF::CmpStmt, SVF::SelectStmt, SVF::PhiStmt, SVF::RetPE, SVF::CallPE, SVF::LoadStmt, SVF::StoreStmt, SVF::CopyStmt, SVF::AddrStmt, SVF::AssignStmt, SVF::TDJoinPE, SVF::TDForkPE, and SVF::GepStmt.

Definition at line 66 of file SVFStatements.cpp.

67 {
68  std::string str;
69  std::stringstream rawstr(str);
70  rawstr << "SVFStmt: [Var" << getDstID() << " <-- Var" << getSrcID() << "]\t";
71  return rawstr.str();
72 }
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

Friends And Related Function Documentation

◆ operator<<

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

Overloading operator << for dumping SVFVar value.

Definition at line 210 of file SVFStatements.h.

211  {
212  o << edge.toString();
213  return o;
214  }

◆ SVFIRReader

friend class SVFIRReader
friend

Definition at line 54 of file SVFStatements.h.

◆ SVFIRWriter

friend class SVFIRWriter
friend

Definition at line 53 of file SVFStatements.h.

Member Data Documentation

◆ basicBlock

const SVFBasicBlock* SVF::SVFStmt::basicBlock
private

LLVM BasicBlock.

Definition at line 82 of file SVFStatements.h.

◆ callEdgeLabelCounter

u64_t SVFStmt::callEdgeLabelCounter = 0
staticprivate

Call site Instruction counter.

Definition at line 227 of file SVFStatements.h.

◆ edgeId

EdgeID SVF::SVFStmt::edgeId
private

Edge ID.

Definition at line 84 of file SVFStatements.h.

◆ icfgNode

ICFGNode* SVF::SVFStmt::icfgNode
private

ICFGNode.

Definition at line 83 of file SVFStatements.h.

◆ inst2LabelMap

SVFStmt::Inst2LabelMap SVFStmt::inst2LabelMap
staticprivate

Call site Instruction to label map.

Definition at line 225 of file SVFStatements.h.

◆ multiOpndLabelCounter

u64_t SVFStmt::multiOpndLabelCounter = 0
staticprivate

MultiOpndStmt counter.

Definition at line 229 of file SVFStatements.h.

◆ storeEdgeLabelCounter

u64_t SVFStmt::storeEdgeLabelCounter = 0
staticprivate

Store Instruction counter.

Definition at line 228 of file SVFStatements.h.

◆ totalEdgeNum

u32_t SVF::SVFStmt::totalEdgeNum
static

Total edge number.

Definition at line 94 of file SVFStatements.h.

◆ value

const SVFValue* SVF::SVFStmt::value
private

LLVM value.

Definition at line 81 of file SVFStatements.h.

◆ var2LabelMap

SVFStmt::Var2LabelMap SVFStmt::var2LabelMap
staticprivate

Second operand of MultiOpndStmt to label map.

Definition at line 226 of file SVFStatements.h.


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