Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | Friends | List of all members
SVF::SVFBasicBlock Class Reference

#include <BasicBlockG.h>

Inheritance diagram for SVF::SVFBasicBlock:
SVF::GenericNode< NodeTy, EdgeTy > SVF::SVFValue

Public Types

typedef std::vector< constICFGNode * >::const_iterator const_iterator
 
- Public Types inherited from SVF::GenericNode< NodeTy, EdgeTy >
typedef NodeTy NodeType
 
typedef EdgeTy 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 , ConstAggValNode , ConstDataValNode , BlackHoleValNode ,
  ConstFPValNode , ConstIntValNode , ConstNullptrValNode , DummyValNode ,
  ObjNode , GepObjNode , BaseObjNode , FunObjNode ,
  HeapObjNode , StackObjNode , GlobalObjNode , ConstAggObjNode ,
  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 ,
  DCHNodeKd , BasicBlockKd , OtherKd
}
 

Public Member Functions

 SVFBasicBlock (NodeID id, const FunObjVar *f)
 Constructor without name.
 
 SVFBasicBlock ()=delete
 
 ~SVFBasicBlock ()
 
const std::vector< const ICFGNode * > & getICFGNodeList () const
 
const_iterator begin () const
 
const_iterator end () const
 
void setFun (const FunObjVar *f)
 
void addSuccBasicBlock (const SVFBasicBlock *succ2)
 
void addPredBasicBlock (const SVFBasicBlock *pred2)
 
const FunObjVargetParent () const
 
const FunObjVargetFunction () const
 
const ICFGNodefront () const
 
const ICFGNodeback () const
 
std::vector< const SVFBasicBlock * > getSuccessors () const
 
std::vector< const SVFBasicBlock * > getPredecessors () const
 
u32_t getNumSuccessors () const
 
u32_t getBBSuccessorPos (const SVFBasicBlock *Succ)
 
u32_t getBBSuccessorPos (const SVFBasicBlock *Succ) const
 
u32_t getBBPredecessorPos (const SVFBasicBlock *succbb)
 
u32_t getBBPredecessorPos (const SVFBasicBlock *succbb) const
 
const std::string toString () const
 
- Public Member Functions inherited from SVF::GenericNode< NodeTy, EdgeTy >
 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)
 
EdgeTypehasIncomingEdge (EdgeType *edge) const
 Find incoming and outgoing edges.
 
EdgeTypehasOutgoingEdge (EdgeType *edge) const
 
const GEdgeSetTygetOutEdges () const
 
const GEdgeSetTygetInEdges () 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 SVFTypegetType () const
 
virtual void setName (const std::string &nameInfo)
 
virtual void setName (std::string &&nameInfo)
 
virtual const std::string & getName () const
 
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 SVFValue *node)
 
static bool classof (const SVFBasicBlock *node)
 
- Static Public Member Functions inherited from SVF::GenericNode< NodeTy, EdgeTy >
static bool classof (const GenericNode< NodeTy, EdgeTy > *)
 
static bool classof (const SVFValue *)
 

Public Attributes

std::vector< const SVFBasicBlock * > succBBs
 
std::vector< const SVFBasicBlock * > predBBs
 

Protected Member Functions

const std::vector< const SVFBasicBlock * > getSuccBBs () const
 
const std::vector< const SVFBasicBlock * > getPredBBs () const
 
void addICFGNode (const ICFGNode *icfgNode)
 Function where this BasicBlock is.
 

Private Attributes

std::vector< const ICFGNode * > allICFGNodes
 all ICFGNodes in this BasicBlock
 
const FunObjVarfun
 

Friends

class LLVMModuleSet
 
class SVFIRBuilder
 
class FunObjVar
 
class ICFGBuilder
 
class ICFG
 
class GraphDBClient
 
OutStreamoperator<< (OutStream &o, const SVFBasicBlock &node)
 

Additional Inherited Members

- 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 SVFTypetype
 SVF type.
 
std::string name
 
std::string sourceLoc
 Source code information of this value.
 

Detailed Description

Definition at line 70 of file BasicBlockG.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 80 of file BasicBlockG.h.

Constructor & Destructor Documentation

◆ SVFBasicBlock() [1/2]

SVF::SVFBasicBlock::SVFBasicBlock ( NodeID  id,
const FunObjVar f 
)
inline

Constructor without name.

Definition at line 115 of file BasicBlockG.h.

116 {
117
118 }
const FunObjVar * fun
Definition BasicBlockG.h:86
GenericNode< SVFBasicBlock, BasicBlockEdge > GenericBasicBlockNodeTy
Definition BasicBlockG.h:69
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ SVFBasicBlock() [2/2]

SVF::SVFBasicBlock::SVFBasicBlock ( )
delete

◆ ~SVFBasicBlock()

SVF::SVFBasicBlock::~SVFBasicBlock ( )
inline

Definition at line 120 of file BasicBlockG.h.

121 {
122
123 }

Member Function Documentation

◆ addICFGNode()

void SVF::SVFBasicBlock::addICFGNode ( const ICFGNode icfgNode)
inlineprotected

Function where this BasicBlock is.

attributes to be set only through Module builders e.g., LLVMModule

Definition at line 93 of file BasicBlockG.h.

94 {
96 icfgNode) == getICFGNodeList().end() && "duplicated icfgnode");
97 allICFGNodes.push_back(icfgNode);
98 }
const std::vector< const ICFGNode * > & getICFGNodeList() const
std::vector< const ICFGNode * > allICFGNodes
all ICFGNodes in this BasicBlock
Definition BasicBlockG.h:85
const_iterator end() const
const_iterator begin() const

◆ addPredBasicBlock()

void SVF::SVFBasicBlock::addPredBasicBlock ( const SVFBasicBlock pred2)
inline

Definition at line 182 of file BasicBlockG.h.

183 {
184 // check if the edge already exists
185 for (auto edge: this->getInEdges())
186 {
187 if (edge->getSrcNode() == pred2)
188 return;
189 }
190 SVFBasicBlock* pred = const_cast<SVFBasicBlock*>(pred2);
191 BasicBlockEdge* edge = new BasicBlockEdge(pred, this);
192 this->addIncomingEdge(edge);
193 pred->addOutgoingEdge(edge);
194 this->predBBs.push_back(pred);
195 pred->succBBs.push_back(this);
196 }
const GEdgeSetTy & getInEdges() const
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
SVFBasicBlock()=delete
std::vector< const SVFBasicBlock * > predBBs
Definition BasicBlockG.h:82

◆ addSuccBasicBlock()

void SVF::SVFBasicBlock::addSuccBasicBlock ( const SVFBasicBlock succ2)
inline

Definition at line 165 of file BasicBlockG.h.

166 {
167 // check if the edge already exists
168 for (auto edge: this->getOutEdges())
169 {
170 if (edge->getDstNode() == succ2)
171 return;
172 }
173
174 SVFBasicBlock* succ = const_cast<SVFBasicBlock*>(succ2);
175 BasicBlockEdge* edge = new BasicBlockEdge(this, succ);
176 this->addOutgoingEdge(edge);
177 succ->addIncomingEdge(edge);
178 this->succBBs.push_back(succ);
179 succ->predBBs.push_back(this);
180 }
const GEdgeSetTy & getOutEdges() const
bool addOutgoingEdge(EdgeType *outEdge)
std::vector< const SVFBasicBlock * > succBBs
Definition BasicBlockG.h:81

◆ back()

const ICFGNode * SVF::SVFBasicBlock::back ( ) const
inline

Definition at line 216 of file BasicBlockG.h.

217 {
218 assert(!allICFGNodes.empty() && "bb empty?");
219 return allICFGNodes.back();
220 }

◆ begin()

const_iterator SVF::SVFBasicBlock::begin ( ) const
inline

Definition at line 149 of file BasicBlockG.h.

150 {
151 return allICFGNodes.begin();
152 }

◆ classof() [1/2]

static bool SVF::SVFBasicBlock::classof ( const SVFBasicBlock node)
inlinestatic

Definition at line 130 of file BasicBlockG.h.

131 {
132 return true;
133 }

◆ classof() [2/2]

static bool SVF::SVFBasicBlock::classof ( const SVFValue node)
inlinestatic

Definition at line 125 of file BasicBlockG.h.

126 {
127 return node->getNodeKind() == SVFValue::BasicBlockKd;
128 }

◆ end()

const_iterator SVF::SVFBasicBlock::end ( ) const
inline

Definition at line 154 of file BasicBlockG.h.

155 {
156 return allICFGNodes.end();
157 }

◆ front()

const ICFGNode * SVF::SVFBasicBlock::front ( ) const
inline

Definition at line 210 of file BasicBlockG.h.

211 {
212 assert(!allICFGNodes.empty() && "bb empty?");
213 return allICFGNodes.front();
214 }

◆ getBBPredecessorPos() [1/2]

u32_t SVF::SVFBasicBlock::getBBPredecessorPos ( const SVFBasicBlock succbb)
inline

Definition at line 270 of file BasicBlockG.h.

271 {
272 u32_t pos = 0;
274 {
275 if(PredBB == this)
276 return pos;
277 ++pos;
278 }
279 assert(false && "Didn't find predecessor edge?");
280 return pos;
281 }
unsigned u32_t
Definition CommandLine.h:18
std::vector< const SVFBasicBlock * > getPredecessors() const

◆ getBBPredecessorPos() [2/2]

u32_t SVF::SVFBasicBlock::getBBPredecessorPos ( const SVFBasicBlock succbb) const
inline

Definition at line 282 of file BasicBlockG.h.

283 {
284 u32_t pos = 0;
286 {
287 if(PredBB == this)
288 return pos;
289 ++pos;
290 }
291 assert(false && "Didn't find predecessor edge?");
292 return pos;
293 }

◆ getBBSuccessorPos() [1/2]

u32_t SVF::SVFBasicBlock::getBBSuccessorPos ( const SVFBasicBlock Succ)
inline

Definition at line 245 of file BasicBlockG.h.

246 {
247 u32_t i = 0;
248 for (const SVFBasicBlock* SuccBB: succBBs)
249 {
250 if (SuccBB == Succ)
251 return i;
252 i++;
253 }
254 assert(false && "Didn't find successor edge?");
255 return 0;
256 }

◆ getBBSuccessorPos() [2/2]

u32_t SVF::SVFBasicBlock::getBBSuccessorPos ( const SVFBasicBlock Succ) const
inline

Definition at line 257 of file BasicBlockG.h.

258 {
259 u32_t i = 0;
260 for (const SVFBasicBlock* SuccBB: succBBs)
261 {
262 if (SuccBB == Succ)
263 return i;
264 i++;
265 }
266 assert(false && "Didn't find successor edge?");
267 return 0;
268
269 }

◆ getFunction()

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

Definition at line 204 of file BasicBlockG.h.

205 {
206 assert(fun && "Function is null?");
207 return fun;
208 }

◆ getICFGNodeList()

const std::vector< const ICFGNode * > & SVF::SVFBasicBlock::getICFGNodeList ( ) const
inline

Definition at line 144 of file BasicBlockG.h.

145 {
146 return allICFGNodes;
147 }

◆ getNumSuccessors()

u32_t SVF::SVFBasicBlock::getNumSuccessors ( ) const
inline

Definition at line 241 of file BasicBlockG.h.

242 {
243 return this->getOutEdges().size();
244 }

◆ getParent()

const FunObjVar * SVF::SVFBasicBlock::getParent ( ) const
inline

Definition at line 198 of file BasicBlockG.h.

199 {
200 assert(fun && "Function is null?");
201 return fun;
202 }

◆ getPredBBs()

const std::vector< const SVFBasicBlock * > SVF::SVFBasicBlock::getPredBBs ( ) const
inlineprotected

Definition at line 108 of file BasicBlockG.h.

109 {
110 return predBBs;
111 }

◆ getPredecessors()

std::vector< const SVFBasicBlock * > SVF::SVFBasicBlock::getPredecessors ( ) const
inline

Definition at line 232 of file BasicBlockG.h.

233 {
234 std::vector<const SVFBasicBlock*> res;
235 for (auto edge : this->getInEdges())
236 {
237 res.push_back(edge->getSrcNode());
238 }
239 return res;
240 }

◆ getSuccBBs()

const std::vector< const SVFBasicBlock * > SVF::SVFBasicBlock::getSuccBBs ( ) const
inlineprotected

Definition at line 103 of file BasicBlockG.h.

104 {
105 return succBBs;
106 }

◆ getSuccessors()

std::vector< const SVFBasicBlock * > SVF::SVFBasicBlock::getSuccessors ( ) const
inline

Definition at line 222 of file BasicBlockG.h.

223 {
224 std::vector<const SVFBasicBlock*> res;
225 for (auto edge : this->getOutEdges())
226 {
227 res.push_back(edge->getDstNode());
228 }
229 return res;
230 }

◆ setFun()

void SVF::SVFBasicBlock::setFun ( const FunObjVar f)
inline

Definition at line 160 of file BasicBlockG.h.

161 {
162 fun = f;
163 }

◆ toString()

const std::string SVFBasicBlock::toString ( ) const

Definition at line 14 of file BasicBlockG.cpp.

15{
16 std::string str;
17 std::stringstream rawstr(str);
18 rawstr << "----------"<< "SVFBasicBlock: " << getName() <<"----------\n";
19 for (const ICFGNode* icfgNode : allICFGNodes)
20 {
21 rawstr << icfgNode->toString();
22 }
23 rawstr << "\n----------------------------------------\n";
24 return rawstr.str();
25}
virtual const std::string & getName() const
Definition SVFValue.h:186

Friends And Related Symbol Documentation

◆ FunObjVar

Definition at line 74 of file BasicBlockG.h.

◆ GraphDBClient

friend class GraphDBClient
friend

Definition at line 77 of file BasicBlockG.h.

◆ ICFG

friend class ICFG
friend

Definition at line 76 of file BasicBlockG.h.

◆ ICFGBuilder

Definition at line 75 of file BasicBlockG.h.

◆ LLVMModuleSet

Definition at line 72 of file BasicBlockG.h.

◆ operator<<

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

Definition at line 136 of file BasicBlockG.h.

137 {
138 o << node.toString();
139 return o;
140 }

◆ SVFIRBuilder

Definition at line 73 of file BasicBlockG.h.

Member Data Documentation

◆ allICFGNodes

std::vector<const ICFGNode*> SVF::SVFBasicBlock::allICFGNodes
private

all ICFGNodes in this BasicBlock

Definition at line 85 of file BasicBlockG.h.

◆ fun

const FunObjVar* SVF::SVFBasicBlock::fun
private

Definition at line 86 of file BasicBlockG.h.

◆ predBBs

std::vector<const SVFBasicBlock*> SVF::SVFBasicBlock::predBBs

Definition at line 82 of file BasicBlockG.h.

◆ succBBs

std::vector<const SVFBasicBlock*> SVF::SVFBasicBlock::succBBs

Definition at line 81 of file BasicBlockG.h.


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