Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static 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.
 
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)
 

Public Member Functions

 SVFStmt (SVFVar *s, SVFVar *d, GEdgeFlag k, bool real=true)
 Constructor.
 
 ~SVFStmt ()
 Destructor.
 
EdgeID getEdgeID () const
 Return Edge ID.
 
virtual bool isPTAEdge () const
 Whether src and dst nodes are both of pointer type.
 
void setValue (const SVFVar *val)
 Get/set methods for llvm instruction.
 
const SVFVargetValue () 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.
 
virtual ~GenericEdge ()
 Destructor.
 
NodeID getSrcID () const
 get methods of the components
 
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.
 
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 const Inst2LabelMapgetInst2LabelMap ()
 
static const Var2LabelMapgetVar2LabelMap ()
 
static const u64_tgetCallEdgeLabelCounter ()
 
static const u64_tgetStoreEdgeLabelCounter ()
 
static const u64_tgetMultiOpndLabelCounter ()
 

Protected Member Functions

 SVFStmt (GEdgeFlag k)
 Private constructor for reading SVFIR from file without side-effect.
 
 SVFStmt (SVFVar *s, SVFVar *d, GEdgeFlag k, EdgeID eid, SVFVar *value, ICFGNode *icfgNode, bool real=true)
 
void setBasicBlock (const SVFBasicBlock *bb)
 
void setCallEdgeLabelCounter (u64_t counter)
 
void setStoreEdgeLabelCounter (u64_t counter)
 
void setMultiOpndLabelCounter (u64_t counter)
 

Static Protected Member Functions

static void addInst2Labeled (const ICFGNode *cs, u32_t label)
 
static void addVar2Labeled (const SVFVar *var, u32_t label)
 

Private Types

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

Private Attributes

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

Static Private Attributes

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

Friends

class GraphDBClient
 
OutStreamoperator<< (OutStream &o, const SVFStmt &edge)
 Overloading operator << for dumping SVFVar value.
 

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.
 
static constexpr u64_t EdgeKindMask = (~0ULL) >> (64 - EdgeKindMaskBits)
 

Detailed Description

Definition at line 52 of file SVFStatements.h.

Member Typedef Documentation

◆ Inst2LabelMap

Definition at line 265 of file SVFStatements.h.

◆ KindToSVFStmtMapTy

Definition at line 261 of file SVFStatements.h.

◆ PAGEdgeSetTy

Definition at line 262 of file SVFStatements.h.

◆ PAGEdgeToSetMapTy

Definition at line 260 of file SVFStatements.h.

◆ SVFStmtSetTy

Definition at line 259 of file SVFStatements.h.

◆ Var2LabelMap

Definition at line 266 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/3]

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.
const SVFBasicBlock * basicBlock
LLVM BasicBlock.
const SVFVar * value
LLVM value.
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
GenericEdge< SVFVar > GenericPAGEdgeTy

◆ SVFStmt() [2/3]

SVFStmt::SVFStmt ( SVFVar s,
SVFVar d,
GEdgeFlag  k,
EdgeID  eid,
SVFVar value,
ICFGNode icfgNode,
bool  real = true 
)
protected

Definition at line 58 of file SVFStatements.cpp.

58 :
60{
61 if(real)
62 {
63 edgeId = eid;
65 }
66}
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:116
EdgeID edgeId
Edge ID.

◆ SVFStmt() [3/3]

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

◆ ~SVFStmt()

SVF::SVFStmt::~SVFStmt ( )
inline

Destructor.

Definition at line 145 of file SVFStatements.h.

145{}

Member Function Documentation

◆ addInst2Labeled()

static void SVF::SVFStmt::addInst2Labeled ( const ICFGNode cs,
u32_t  label 
)
inlinestaticprotected

Add a call site Instruction to label mapping, this is used when loading statements from DB

Definition at line 130 of file SVFStatements.h.

131 {
132 inst2LabelMap.emplace(cs, label);
133 }
static Inst2LabelMap inst2LabelMap
Call site Instruction to label map.

◆ addVar2Labeled()

static void SVF::SVFStmt::addVar2Labeled ( const SVFVar var,
u32_t  label 
)
inlinestaticprotected

Definition at line 135 of file SVFStatements.h.

136 {
137 var2LabelMap.emplace(var, label);
138 }
static Var2LabelMap var2LabelMap
Second operand of MultiOpndStmt to label map.

◆ classof() [1/2]

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

Definition at line 153 of file SVFStatements.h.

154 {
155 return edge->getEdgeKind() == SVFStmt::Addr ||
156 edge->getEdgeKind() == SVFStmt::Copy ||
157 edge->getEdgeKind() == SVFStmt::Store ||
158 edge->getEdgeKind() == SVFStmt::Load ||
159 edge->getEdgeKind() == SVFStmt::Call ||
160 edge->getEdgeKind() == SVFStmt::Ret ||
161 edge->getEdgeKind() == SVFStmt::Gep ||
162 edge->getEdgeKind() == SVFStmt::Phi ||
163 edge->getEdgeKind() == SVFStmt::Select ||
164 edge->getEdgeKind() == SVFStmt::Cmp ||
165 edge->getEdgeKind() == SVFStmt::BinaryOp ||
166 edge->getEdgeKind() == SVFStmt::UnaryOp ||
167 edge->getEdgeKind() == SVFStmt::Branch ||
168 edge->getEdgeKind() == SVFStmt::ThreadFork ||
169 edge->getEdgeKind() == SVFStmt::ThreadJoin;
170 }

◆ classof() [2/2]

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

ClassOf.

Definition at line 149 of file SVFStatements.h.

150 {
151 return true;
152 }

◆ getBB()

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

Definition at line 197 of file SVFStatements.h.

198 {
199 return basicBlock;
200 }

◆ getCallEdgeLabelCounter()

static const u64_t * SVF::SVFStmt::getCallEdgeLabelCounter ( )
inlinestatic

Definition at line 284 of file SVFStatements.h.

285 {
286 return &callEdgeLabelCounter;
287 }
static u64_t callEdgeLabelCounter
Call site Instruction counter.

◆ getEdgeID()

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

Return Edge ID.

Definition at line 174 of file SVFStatements.h.

175 {
176 return edgeId;
177 }

◆ getICFGNode()

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

Definition at line 205 of file SVFStatements.h.

206 {
207 return icfgNode;
208 }

◆ getInst2LabelMap()

static const Inst2LabelMap * SVF::SVFStmt::getInst2LabelMap ( )
inlinestatic

Definition at line 274 of file SVFStatements.h.

275 {
276 return &inst2LabelMap;
277 }

◆ getMultiOpndLabelCounter()

static const u64_t * SVF::SVFStmt::getMultiOpndLabelCounter ( )
inlinestatic

Definition at line 294 of file SVFStatements.h.

295 {
296 return &multiOpndLabelCounter;
297 }
static u64_t multiOpndLabelCounter
MultiOpndStmt counter.

◆ getStoreEdgeLabelCounter()

static const u64_t * SVF::SVFStmt::getStoreEdgeLabelCounter ( )
inlinestatic

Definition at line 289 of file SVFStatements.h.

290 {
291 return &storeEdgeLabelCounter;
292 }
static u64_t storeEdgeLabelCounter
Store Instruction counter.

◆ getValue()

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

Definition at line 188 of file SVFStatements.h.

189 {
190 return value;
191 }

◆ getVar2LabelMap()

static const Var2LabelMap * SVF::SVFStmt::getVar2LabelMap ( )
inlinestatic

Definition at line 279 of file SVFStatements.h.

280 {
281 return &var2LabelMap;
282 }

◆ isPTAEdge()

bool SVFStmt::isPTAEdge ( ) const
virtual

Whether src and dst nodes are both of pointer type.

Whether src and dst nodes are both pointer type

Reimplemented in SVF::AddrStmt.

Definition at line 71 of file SVFStatements.cpp.

72{
73 return getSrcNode()->isPointer() && getDstNode()->isPointer();
74}
NodeType * getSrcNode() const
NodeType * getDstNode() const

◆ 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 213 of file SVFStatements.h.

215 {
217 if (it_inserted.second)
219 u64_t label = it_inserted.first->second;
220 return (label << EdgeKindMaskBits) | k;
221 }
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
unsigned long long u64_t
Definition GeneralType.h:49

◆ 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 225 of file SVFStatements.h.

227 {
229 if (it_inserted.second)
231 u64_t label = it_inserted.first->second;
232 return (label << EdgeKindMaskBits) | k;
233 }

◆ 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 237 of file SVFStatements.h.

239 {
240 auto it_inserted = inst2LabelMap.emplace(store, storeEdgeLabelCounter);
241 if (it_inserted.second)
243 u64_t label = it_inserted.first->second;
244 return (label << EdgeKindMaskBits) | k;
245 }

◆ setBasicBlock()

void SVF::SVFStmt::setBasicBlock ( const SVFBasicBlock bb)
inlineprotected

Set the SVF BasicBlock for the new statements, this is used when loading statements from DB

Definition at line 98 of file SVFStatements.h.

99 {
100 basicBlock = bb;
101 }

◆ setBB()

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

Definition at line 193 of file SVFStatements.h.

194 {
195 basicBlock = bb;
196 }

◆ setCallEdgeLabelCounter()

void SVF::SVFStmt::setCallEdgeLabelCounter ( u64_t  counter)
inlineprotected

set the call edge lanbel counter for the new statements, this is used when loading statements from DB

Definition at line 106 of file SVFStatements.h.

107 {
109 }

◆ setICFGNode()

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

Definition at line 201 of file SVFStatements.h.

202 {
203 icfgNode = node;
204 }

◆ setMultiOpndLabelCounter()

void SVF::SVFStmt::setMultiOpndLabelCounter ( u64_t  counter)
inlineprotected

set the multi operand edge lanbel counter for the new statements, this is used when loading statements from DB

Definition at line 122 of file SVFStatements.h.

123 {
125 }

◆ setStoreEdgeLabelCounter()

void SVF::SVFStmt::setStoreEdgeLabelCounter ( u64_t  counter)
inlineprotected

set the store edge lanbel counter for the new statements, this is used when loading statements from DB

Definition at line 114 of file SVFStatements.h.

115 {
117 }

◆ setValue()

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

Get/set methods for llvm instruction.

Definition at line 184 of file SVFStatements.h.

185 {
186 value = val;
187 }

◆ toString()

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

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

Definition at line 76 of file SVFStatements.cpp.

77{
78 std::string str;
79 std::stringstream rawstr(str);
80 rawstr << "SVFStmt: [Var" << getDstID() << " <-- Var" << getSrcID() << "]\t";
81 return rawstr.str();
82}
NodeID getDstID() const
NodeID getSrcID() const
get methods of the components

Friends And Related Symbol Documentation

◆ GraphDBClient

friend class GraphDBClient
friend

Definition at line 54 of file SVFStatements.h.

◆ operator<<

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

Overloading operator << for dumping SVFVar value.

Definition at line 252 of file SVFStatements.h.

253 {
254 o << edge.toString();
255 return o;
256 }

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 269 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 267 of file SVFStatements.h.

◆ multiOpndLabelCounter

u64_t SVFStmt::multiOpndLabelCounter = 0
staticprivate

MultiOpndStmt counter.

Definition at line 271 of file SVFStatements.h.

◆ storeEdgeLabelCounter

u64_t SVFStmt::storeEdgeLabelCounter = 0
staticprivate

Store Instruction counter.

Definition at line 270 of file SVFStatements.h.

◆ value

const SVFVar* 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 268 of file SVFStatements.h.


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