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

#include <SVFStatements.h>

Inheritance diagram for SVF::BranchStmt:
SVF::SVFStmt SVF::GenericEdge< NodeTy >

Public Types

typedef std::vector< std::pair< const ICFGNode *, s32_t > > SuccAndCondPairVec
 
- Public Types inherited from SVF::SVFStmt
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, SVFStmtSetTy > PAGEdgeToSetMapTy
 
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

 BranchStmt (ValVar *inst, ValVar *c, const SuccAndCondPairVec &succs)
 constructor
 
bool isUnconditional () const
 The branch is unconditional if cond is a null value.
 
bool isConditional () const
 The branch is conditional if cond is not a null value.
 
const ValVar * getCondition () const
 Return the condition.
 
const ValVar * getBranchInst () const
 
u32_t getNumSuccessors () const
 
const SuccAndCondPairVec & getSuccessors () const
 
const ICFGNode * getSuccessor (u32_t i) const
 
s64_t getSuccessorCondValue (u32_t i) const
 
virtual const std::string toString () const override
 
- Public Member Functions inherited from SVF::SVFStmt
 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 SVFVar * getValue () const
 
void setBB (const SVFBasicBlock *bb)
 
const SVFBasicBlock * getBB () const
 
void setICFGNode (ICFGNode *node)
 
ICFGNode * getICFGNode () 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
 
NodeType * getSrcNode () const
 
NodeType * getDstNode () const
 
virtual bool operator== (const GenericEdge< NodeType > *rhs) const
 

Static Public Member Functions

static bool classof (const BranchStmt *)
 Methods for support type inquiry through isa, cast, and dyn_cast:
 
static bool classof (const SVFStmt *edge)
 
static bool classof (const GenericPAGEdgeTy *edge)
 
- Static Public Member Functions inherited from SVF::SVFStmt
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 Inst2LabelMap * getInst2LabelMap ()
 
static const Var2LabelMap * getVar2LabelMap ()
 
static const u64_t * getCallEdgeLabelCounter ()
 
static const u64_t * getStoreEdgeLabelCounter ()
 
static const u64_t * getMultiOpndLabelCounter ()
 

Private Member Functions

 BranchStmt (const BranchStmt &)
 place holder
 
void operator= (const BranchStmt &)
 place holder
 
SVFVar * getSrcNode ()
 place holder, not allowed
 
SVFVar * getDstNode ()
 place holder, not allowed
 
NodeID getSrcID ()
 place holder, use getOpVarID(pos) instead
 
NodeID getDstID ()
 place holder, use getResID() instead
 

Private Attributes

SuccAndCondPairVec successors
 
const ValVar * cond
 
const ValVar * brInst
 

Friends

class GraphDBClient
 

Additional Inherited Members

- Protected Member Functions inherited from SVF::SVFStmt
 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 inherited from SVF::SVFStmt
static void addInst2Labeled (const ICFGNode *cs, u32_t label)
 
static void addVar2Labeled (const SVFVar *var, u32_t label)
 
- 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

Branch statements including if/else and switch

Definition at line 1246 of file SVFStatements.h.

Member Typedef Documentation

◆ SuccAndCondPairVec

Definition at line 1251 of file SVFStatements.h.

Constructor & Destructor Documentation

◆ BranchStmt() [1/2]

SVF::BranchStmt::BranchStmt ( const BranchStmt &  )
private

place holder

◆ BranchStmt() [2/2]

BranchStmt::BranchStmt ( ValVar *  inst,
ValVar *  c,
const SuccAndCondPairVec &  succs 
)

constructor

Definition at line 492 of file SVFStatements.cpp.

494 brInst(inst)
495{
496}
SuccAndCondPairVec successors
const ValVar * cond
const ValVar * brInst
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

Member Function Documentation

◆ classof() [1/3]

static bool SVF::BranchStmt::classof ( const BranchStmt *  )
inlinestatic

Methods for support type inquiry through isa, cast, and dyn_cast:

Definition at line 1268 of file SVFStatements.h.

1269 {
1270 return true;
1271 }

◆ classof() [2/3]

static bool SVF::BranchStmt::classof ( const GenericPAGEdgeTy *  edge)
inlinestatic

Definition at line 1276 of file SVFStatements.h.

1277 {
1278 return edge->getEdgeKind() == SVFStmt::Branch;
1279 }

◆ classof() [3/3]

static bool SVF::BranchStmt::classof ( const SVFStmt *  edge)
inlinestatic

Definition at line 1272 of file SVFStatements.h.

1273 {
1274 return edge->getEdgeKind() == SVFStmt::Branch;
1275 }

◆ getBranchInst()

const ValVar * SVF::BranchStmt::getBranchInst ( ) const
inline

Definition at line 1291 of file SVFStatements.h.

1292 {
1293 return brInst;
1294 }

◆ getCondition()

const ValVar * BranchStmt::getCondition ( ) const

Return the condition.

Definition at line 481 of file SVFStatements.cpp.

482{
483 //assert(isConditional() && "this is a unconditional branch");
484 return cond;
485}

◆ getDstID()

NodeID SVF::BranchStmt::getDstID ( )
private

place holder, use getResID() instead

◆ getDstNode()

SVFVar * SVF::BranchStmt::getDstNode ( )
private

place holder, not allowed

◆ getNumSuccessors()

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

For example if(c) {stmt1} else {stmt2} successor(0): stmt1, 1 successor(1): stmt2, 0 For example switch(c) case 0: {stmt1; break;} case 1: {stmt2; break;} default {stmt3: break} successor(0): stmt1, 0 successor(1): stmt2, 1 successor(3): stmt3, -1 Successors of this branch statement

Definition at line 1306 of file SVFStatements.h.

1307 {
1308 return successors.size();
1309 }

◆ getSrcID()

NodeID SVF::BranchStmt::getSrcID ( )
private

place holder, use getOpVarID(pos) instead

◆ getSrcNode()

SVFVar * SVF::BranchStmt::getSrcNode ( )
private

place holder, not allowed

◆ getSuccessor()

const ICFGNode * SVF::BranchStmt::getSuccessor ( u32_t  i) const
inline

Definition at line 1314 of file SVFStatements.h.

1315 {
1316 return successors.at(i).first;
1317 }

◆ getSuccessorCondValue()

s64_t SVF::BranchStmt::getSuccessorCondValue ( u32_t  i) const
inline

Definition at line 1318 of file SVFStatements.h.

1319 {
1320 return successors.at(i).second;
1321 }

◆ getSuccessors()

const SuccAndCondPairVec & SVF::BranchStmt::getSuccessors ( ) const
inline

Definition at line 1310 of file SVFStatements.h.

1311 {
1312 return successors;
1313 }

◆ isConditional()

bool BranchStmt::isConditional ( ) const

The branch is conditional if cond is not a null value.

Definition at line 476 of file SVFStatements.cpp.

477{
478 return cond->getId() != PAG::getPAG()->nullPtrSymID();;
479}
NodeID nullPtrSymID() const
Definition IRGraph.h:182
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:120
NodeID getId() const
Get ID.
Definition SVFValue.h:158

◆ isUnconditional()

bool BranchStmt::isUnconditional ( ) const

The branch is unconditional if cond is a null value.

Definition at line 471 of file SVFStatements.cpp.

472{
473 return cond->getId() == PAG::getPAG()->nullPtrSymID();
474}

◆ operator=()

void SVF::BranchStmt::operator= ( const BranchStmt &  )
private

place holder

◆ toString()

const std::string BranchStmt::toString ( ) const
overridevirtual

Reimplemented from SVF::SVFStmt.

Definition at line 181 of file SVFStatements.cpp.

182{
183 std::string str;
184 std::stringstream rawstr(str);
185 if(isConditional())
186 rawstr << "BranchStmt: [Condition Var" << getCondition()->getId() << "]\n";
187 else
188 rawstr << "BranchStmt: [" << " Unconditional branch" << "]\n";
189
190 for(u32_t i = 0; i < getNumSuccessors(); i++)
191 rawstr << "Successor " << i << " ICFGNode" << getSuccessor(i)->getId() << " ";
192
194 {
195 rawstr << "\n";
196 rawstr << getValue()->toString();
197 }
198 return rawstr.str();
199}
unsigned u32_t
Definition CommandLine.h:18
u32_t getNumSuccessors() const
const ICFGNode * getSuccessor(u32_t i) const
const ValVar * getCondition() const
Return the condition.
bool isConditional() const
The branch is conditional if cond is not a null value.
static const Option< bool > ShowSVFIRValue
Definition Options.h:118
const SVFVar * getValue() const
virtual const std::string toString() const
Get string representation.

Friends And Related Symbol Documentation

◆ GraphDBClient

friend class GraphDBClient
friend

Definition at line 1248 of file SVFStatements.h.

Member Data Documentation

◆ brInst

const ValVar* SVF::BranchStmt::brInst
private

Definition at line 1263 of file SVFStatements.h.

◆ cond

const ValVar* SVF::BranchStmt::cond
private

Definition at line 1262 of file SVFStatements.h.

◆ successors

SuccAndCondPairVec SVF::BranchStmt::successors
private

Definition at line 1261 of file SVFStatements.h.


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