Static Value-Flow Analysis
Loading...
Searching...
No Matches
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.
 
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.
 
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 Public Attributes

static u32_t totalEdgeNum
 Total edge number.
 

Protected Member Functions

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

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

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

◆ KindToSVFStmtMapTy

Definition at line 214 of file SVFStatements.h.

◆ PAGEdgeSetTy

Definition at line 215 of file SVFStatements.h.

◆ PAGEdgeToSetMapTy

Definition at line 213 of file SVFStatements.h.

◆ SVFStmtSetTy

Definition at line 212 of file SVFStatements.h.

◆ Var2LabelMap

Definition at line 219 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 60 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 87 of file SVFStatements.h.

88 : GenericPAGEdgeTy({}, {}, k), value{}, basicBlock{}, icfgNode{}
89 {
90 }
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/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
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:114
EdgeID edgeId
Edge ID.

◆ ~SVFStmt()

SVF::SVFStmt::~SVFStmt ( )
inline

Destructor.

Definition at line 98 of file SVFStatements.h.

98{}

Member Function Documentation

◆ classof() [1/2]

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

Definition at line 106 of file SVFStatements.h.

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

◆ classof() [2/2]

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

ClassOf.

Definition at line 102 of file SVFStatements.h.

103 {
104 return true;
105 }

◆ getBB()

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

Definition at line 150 of file SVFStatements.h.

151 {
152 return basicBlock;
153 }

◆ getEdgeID()

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

Return Edge ID.

Definition at line 127 of file SVFStatements.h.

128 {
129 return edgeId;
130 }

◆ getICFGNode()

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

Definition at line 158 of file SVFStatements.h.

159 {
160 return icfgNode;
161 }

◆ getValue()

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

Definition at line 141 of file SVFStatements.h.

142 {
143 return value;
144 }

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

168 {
170 if (it_inserted.second)
172 u64_t label = it_inserted.first->second;
173 return (label << EdgeKindMaskBits) | k;
174 }
static constexpr unsigned char EdgeKindMaskBits
We use the lower 8 bits to denote edge kind.
static Var2LabelMap var2LabelMap
Second operand of MultiOpndStmt to label map.
static u64_t multiOpndLabelCounter
MultiOpndStmt counter.
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 178 of file SVFStatements.h.

180 {
182 if (it_inserted.second)
184 u64_t label = it_inserted.first->second;
185 return (label << EdgeKindMaskBits) | k;
186 }
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 190 of file SVFStatements.h.

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

◆ setBB()

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

Definition at line 146 of file SVFStatements.h.

147 {
148 basicBlock = bb;
149 }

◆ setICFGNode()

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

Definition at line 154 of file SVFStatements.h.

155 {
156 icfgNode = node;
157 }

◆ setValue()

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

Get/set methods for llvm instruction.

Definition at line 137 of file SVFStatements.h.

138 {
139 value = val;
140 }

◆ 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 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}
NodeID getDstID() const
NodeID getSrcID() const
get methods of the components

Friends And Related Symbol Documentation

◆ operator<<

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

Overloading operator << for dumping SVFVar value.

Definition at line 205 of file SVFStatements.h.

206 {
207 o << edge.toString();
208 return o;
209 }

Member Data Documentation

◆ basicBlock

const SVFBasicBlock* SVF::SVFStmt::basicBlock
private

LLVM BasicBlock.

Definition at line 81 of file SVFStatements.h.

◆ callEdgeLabelCounter

u64_t SVFStmt::callEdgeLabelCounter = 0
staticprivate

Call site Instruction counter.

Definition at line 222 of file SVFStatements.h.

◆ edgeId

EdgeID SVF::SVFStmt::edgeId
private

Edge ID.

Definition at line 83 of file SVFStatements.h.

◆ icfgNode

ICFGNode* SVF::SVFStmt::icfgNode
private

ICFGNode.

Definition at line 82 of file SVFStatements.h.

◆ inst2LabelMap

SVFStmt::Inst2LabelMap SVFStmt::inst2LabelMap
staticprivate

Call site Instruction to label map.

Definition at line 220 of file SVFStatements.h.

◆ multiOpndLabelCounter

u64_t SVFStmt::multiOpndLabelCounter = 0
staticprivate

MultiOpndStmt counter.

Definition at line 224 of file SVFStatements.h.

◆ storeEdgeLabelCounter

u64_t SVFStmt::storeEdgeLabelCounter = 0
staticprivate

Store Instruction counter.

Definition at line 223 of file SVFStatements.h.

◆ totalEdgeNum

u32_t SVF::SVFStmt::totalEdgeNum
static

Total edge number.

Definition at line 93 of file SVFStatements.h.

◆ value

const SVFVar* SVF::SVFStmt::value
private

LLVM value.

Definition at line 80 of file SVFStatements.h.

◆ var2LabelMap

SVFStmt::Var2LabelMap SVFStmt::var2LabelMap
staticprivate

Second operand of MultiOpndStmt to label map.

Definition at line 221 of file SVFStatements.h.


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