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

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

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
 
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 79 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 103 of file BasicBlockG.h.

104 {
105
106 }
const FunObjVar * fun
Definition BasicBlockG.h:85
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 108 of file BasicBlockG.h.

109 {
110
111 }

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 92 of file BasicBlockG.h.

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

◆ addPredBasicBlock()

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

Definition at line 170 of file BasicBlockG.h.

171 {
172 // check if the edge already exists
173 for (auto edge: this->getInEdges())
174 {
175 if (edge->getSrcNode() == pred2)
176 return;
177 }
178 SVFBasicBlock* pred = const_cast<SVFBasicBlock*>(pred2);
179 BasicBlockEdge* edge = new BasicBlockEdge(pred, this);
180 this->addIncomingEdge(edge);
181 pred->addOutgoingEdge(edge);
182 this->predBBs.push_back(pred);
183 pred->succBBs.push_back(this);
184 }
const GEdgeSetTy & getInEdges() const
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
SVFBasicBlock()=delete
std::vector< const SVFBasicBlock * > predBBs
Definition BasicBlockG.h:81

◆ addSuccBasicBlock()

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

Definition at line 153 of file BasicBlockG.h.

154 {
155 // check if the edge already exists
156 for (auto edge: this->getOutEdges())
157 {
158 if (edge->getDstNode() == succ2)
159 return;
160 }
161
162 SVFBasicBlock* succ = const_cast<SVFBasicBlock*>(succ2);
163 BasicBlockEdge* edge = new BasicBlockEdge(this, succ);
164 this->addOutgoingEdge(edge);
165 succ->addIncomingEdge(edge);
166 this->succBBs.push_back(succ);
167 succ->predBBs.push_back(this);
168 }
const GEdgeSetTy & getOutEdges() const
bool addOutgoingEdge(EdgeType *outEdge)
std::vector< const SVFBasicBlock * > succBBs
Definition BasicBlockG.h:80

◆ back()

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

Definition at line 204 of file BasicBlockG.h.

205 {
206 assert(!allICFGNodes.empty() && "bb empty?");
207 return allICFGNodes.back();
208 }

◆ begin()

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

Definition at line 137 of file BasicBlockG.h.

138 {
139 return allICFGNodes.begin();
140 }

◆ classof() [1/2]

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

Definition at line 118 of file BasicBlockG.h.

119 {
120 return true;
121 }

◆ classof() [2/2]

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

Definition at line 113 of file BasicBlockG.h.

114 {
115 return node->getNodeKind() == SVFValue::BasicBlockKd;
116 }

◆ end()

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

Definition at line 142 of file BasicBlockG.h.

143 {
144 return allICFGNodes.end();
145 }

◆ front()

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

Definition at line 198 of file BasicBlockG.h.

199 {
200 assert(!allICFGNodes.empty() && "bb empty?");
201 return allICFGNodes.front();
202 }

◆ getBBPredecessorPos() [1/2]

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

Definition at line 258 of file BasicBlockG.h.

259 {
260 u32_t pos = 0;
262 {
263 if(PredBB == this)
264 return pos;
265 ++pos;
266 }
267 assert(false && "Didn't find predecessor edge?");
268 return pos;
269 }
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 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 }

◆ getBBSuccessorPos() [1/2]

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

Definition at line 233 of file BasicBlockG.h.

234 {
235 u32_t i = 0;
236 for (const SVFBasicBlock* SuccBB: succBBs)
237 {
238 if (SuccBB == Succ)
239 return i;
240 i++;
241 }
242 assert(false && "Didn't find successor edge?");
243 return 0;
244 }

◆ getBBSuccessorPos() [2/2]

u32_t SVF::SVFBasicBlock::getBBSuccessorPos ( const SVFBasicBlock Succ) const
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
257 }

◆ getFunction()

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

Definition at line 192 of file BasicBlockG.h.

193 {
194 assert(fun && "Function is null?");
195 return fun;
196 }

◆ getICFGNodeList()

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

Definition at line 132 of file BasicBlockG.h.

133 {
134 return allICFGNodes;
135 }

◆ getNumSuccessors()

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

Definition at line 229 of file BasicBlockG.h.

230 {
231 return this->getOutEdges().size();
232 }

◆ getParent()

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

Definition at line 186 of file BasicBlockG.h.

187 {
188 assert(fun && "Function is null?");
189 return fun;
190 }

◆ getPredecessors()

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

Definition at line 220 of file BasicBlockG.h.

221 {
222 std::vector<const SVFBasicBlock*> res;
223 for (auto edge : this->getInEdges())
224 {
225 res.push_back(edge->getSrcNode());
226 }
227 return res;
228 }

◆ getSuccessors()

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

Definition at line 210 of file BasicBlockG.h.

211 {
212 std::vector<const SVFBasicBlock*> res;
213 for (auto edge : this->getOutEdges())
214 {
215 res.push_back(edge->getDstNode());
216 }
217 return res;
218 }

◆ setFun()

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

Definition at line 148 of file BasicBlockG.h.

149 {
150 fun = f;
151 }

◆ toString()

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

Definition at line 13 of file BasicBlockG.cpp.

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

Friends And Related Symbol Documentation

◆ FunObjVar

Definition at line 74 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 124 of file BasicBlockG.h.

125 {
126 o << node.toString();
127 return o;
128 }

◆ 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 84 of file BasicBlockG.h.

◆ fun

const FunObjVar* SVF::SVFBasicBlock::fun
private

Definition at line 85 of file BasicBlockG.h.

◆ predBBs

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

Definition at line 81 of file BasicBlockG.h.

◆ succBBs

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

Definition at line 80 of file BasicBlockG.h.


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