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

#include <SVFVariables.h>

Inheritance diagram for SVF::SVFVar:
SVF::GenericNode< NodeTy, EdgeTy > SVF::SVFValue SVF::ObjVar SVF::ValVar SVF::BaseObjVar SVF::GepObjVar SVF::ArgValVar SVF::ConstAggValVar SVF::ConstDataValVar SVF::DummyValVar SVF::FunValVar SVF::GepValVar SVF::GlobalValVar SVF::RetValPN SVF::VarArgValPN

Public Types

typedef GNodeK PNODEK
 
typedef s64_t GEdgeKind
 
- 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

 SVFVar (NodeID i, const SVFType *svfType, PNODEK k)
 Standard constructor with ID, type and kind.
 
virtual ~SVFVar ()
 Virtual destructor.
 
virtual bool isPointer () const
 Check if this variable represents a pointer.
 
virtual bool isConstDataOrAggDataButNotNullPtr () const
 Check if this variable represents constant data/metadata but not null pointer.
 
virtual bool isIsolatedNode () const
 Check if this node is isolated (no edges) in the SVFIR graph.
 
virtual const std::string getValueName () const =0
 Get string name of the represented LLVM value.
 
virtual const FunObjVargetFunction () const
 Get containing function, or null for globals/constants.
 
SVFStmt::SVFStmtSetTygetIncomingEdges (SVFStmt::PEDGEK kind)
 Edge accessors and checkers.
 
SVFStmt::SVFStmtSetTygetOutgoingEdges (SVFStmt::PEDGEK kind)
 
bool hasIncomingEdges (SVFStmt::PEDGEK kind) const
 
bool hasOutgoingEdges (SVFStmt::PEDGEK kind) const
 
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesBegin (SVFStmt::PEDGEK kind) const
 Edge iterators.
 
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesEnd (SVFStmt::PEDGEK kind) const
 
SVFStmt::SVFStmtSetTy::iterator getOutgoingEdgesBegin (SVFStmt::PEDGEK kind) const
 
SVFStmt::SVFStmtSetTy::iterator getOutgoingEdgesEnd (SVFStmt::PEDGEK kind) const
 
virtual bool ptrInUncalledFunction () const
 Check if this pointer is in an uncalled function.
 
virtual bool isConstDataOrAggData () const
 Check if this variable represents constant/aggregate data.
 
virtual const std::string toString () const
 Get string representation.
 
void dump () const
 Debug dump to console.
 
- 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 SVFVar *)
 Type checking support for LLVM-style RTTI.
 
static bool classof (const GenericPAGNodeTy *node)
 
static bool classof (const SVFValue *node)
 
- Static Public Member Functions inherited from SVF::GenericNode< NodeTy, EdgeTy >
static bool classof (const GenericNode< NodeTy, EdgeTy > *)
 
static bool classof (const SVFValue *)
 

Protected Member Functions

 SVFVar (NodeID i, PNODEK k)
 Empty constructor for deserialization.
 

Protected Attributes

SVFStmt::KindToSVFStmtMapTy InEdgeKindToSetMap
 Maps tracking incoming and outgoing edges by kind.
 
SVFStmt::KindToSVFStmtMapTy OutEdgeKindToSetMap
 
- 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.
 

Private Member Functions

void addInEdge (SVFStmt *inEdge)
 Edge management methods.
 
void addOutEdge (SVFStmt *outEdge)
 
bool hasIncomingVariantGepEdge () const
 Check for incoming variable field GEP edges.
 

Friends

class SVFIRBuilder
 
class IRGraph
 
class SVFIR
 
class VFG
 
OutStreamoperator<< (OutStream &o, const SVFVar &node)
 Stream operator overload for output.
 

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)
 

Detailed Description

Definition at line 48 of file SVFVariables.h.

Member Typedef Documentation

◆ GEdgeKind

Definition at line 67 of file SVFVariables.h.

◆ PNODEK

Node kinds for SVFIR variables: ValNode - LLVM pointer value ObjNode - Memory object RetValNode - Function return value VarargNode - Variable argument parameter GepValNode - Temporary value for field-sensitive analysis GepObjNode - Temporary object for field-sensitive analysis BaseObjNode - Base object for field-insensitive analysis DummyValNode/DummyObjNode - Nodes for non-LLVM values

Definition at line 66 of file SVFVariables.h.

Constructor & Destructor Documentation

◆ SVFVar() [1/2]

SVF::SVFVar::SVFVar ( NodeID  i,
PNODEK  k 
)
inlineprotected

Empty constructor for deserialization.

Definition at line 75 of file SVFVariables.h.

75: GenericPAGNodeTy(i, k) {}
GenericNode< SVFVar, SVFStmt > GenericPAGNodeTy
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ SVFVar() [2/2]

SVFVar::SVFVar ( NodeID  i,
const SVFType svfType,
PNODEK  k 
)

Standard constructor with ID, type and kind.

SVFVar constructor

Definition at line 44 of file SVFVariables.cpp.

44 :
46{
47}

◆ ~SVFVar()

virtual SVF::SVFVar::~SVFVar ( )
inlinevirtual

Virtual destructor.

Definition at line 83 of file SVFVariables.h.

83{}

Member Function Documentation

◆ addInEdge()

void SVF::SVFVar::addInEdge ( SVFStmt inEdge)
inlineprivate

Edge management methods.

Definition at line 199 of file SVFVariables.h.

200 {
201 GEdgeKind kind = inEdge->getEdgeKind();
202 InEdgeKindToSetMap[kind].insert(inEdge);
204 }
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
SVFStmt::KindToSVFStmtMapTy InEdgeKindToSetMap
Maps tracking incoming and outgoing edges by kind.
s64_t GEdgeKind

◆ addOutEdge()

void SVF::SVFVar::addOutEdge ( SVFStmt outEdge)
inlineprivate

Definition at line 206 of file SVFVariables.h.

207 {
208 GEdgeKind kind = outEdge->getEdgeKind();
209 OutEdgeKindToSetMap[kind].insert(outEdge);
211 }
bool addOutgoingEdge(EdgeType *outEdge)
SVFStmt::KindToSVFStmtMapTy OutEdgeKindToSetMap

◆ classof() [1/3]

static bool SVF::SVFVar::classof ( const GenericPAGNodeTy node)
inlinestatic

Definition at line 176 of file SVFVariables.h.

177 {
178 return isSVFVarKind(node->getNodeKind());
179 }
static bool isSVFVarKind(GNodeK n)
Definition SVFValue.h:230

◆ classof() [2/3]

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

Definition at line 181 of file SVFVariables.h.

182 {
183 return isSVFVarKind(node->getNodeKind());
184 }

◆ classof() [3/3]

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

Type checking support for LLVM-style RTTI.

Definition at line 171 of file SVFVariables.h.

172 {
173 return true;
174 }

◆ dump()

void SVFVar::dump ( ) const

Debug dump to console.

Definition at line 80 of file SVFVariables.cpp.

81{
82 outs() << this->toString() << "\n";
83}
virtual const std::string toString() const
Get string representation.
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52

◆ getFunction()

virtual const FunObjVar * SVF::SVFVar::getFunction ( ) const
inlinevirtual

Get containing function, or null for globals/constants.

Reimplemented in SVF::ValVar, SVF::ArgValVar, SVF::GepValVar, SVF::BaseObjVar, SVF::GepObjVar, SVF::FunObjVar, SVF::FunValVar, SVF::RetValPN, and SVF::VarArgValPN.

Definition at line 105 of file SVFVariables.h.

106 {
107 return nullptr;
108 }

◆ getIncomingEdges()

SVFStmt::SVFStmtSetTy & SVF::SVFVar::getIncomingEdges ( SVFStmt::PEDGEK  kind)
inline

Edge accessors and checkers.

Definition at line 112 of file SVFVariables.h.

113 {
114 return InEdgeKindToSetMap[kind];
115 }

◆ getIncomingEdgesBegin()

SVFStmt::SVFStmtSetTy::iterator SVF::SVFVar::getIncomingEdgesBegin ( SVFStmt::PEDGEK  kind) const
inline

Edge iterators.

Definition at line 141 of file SVFVariables.h.

142 {
143 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
144 assert(it!=InEdgeKindToSetMap.end() && "Edge kind not found");
145 return it->second.begin();
146 }

◆ getIncomingEdgesEnd()

SVFStmt::SVFStmtSetTy::iterator SVF::SVFVar::getIncomingEdgesEnd ( SVFStmt::PEDGEK  kind) const
inline

Definition at line 148 of file SVFVariables.h.

149 {
150 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
151 assert(it!=InEdgeKindToSetMap.end() && "Edge kind not found");
152 return it->second.end();
153 }

◆ getOutgoingEdges()

SVFStmt::SVFStmtSetTy & SVF::SVFVar::getOutgoingEdges ( SVFStmt::PEDGEK  kind)
inline

Definition at line 117 of file SVFVariables.h.

118 {
119 return OutEdgeKindToSetMap[kind];
120 }

◆ getOutgoingEdgesBegin()

SVFStmt::SVFStmtSetTy::iterator SVF::SVFVar::getOutgoingEdgesBegin ( SVFStmt::PEDGEK  kind) const
inline

Definition at line 155 of file SVFVariables.h.

156 {
157 SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
158 assert(it!=OutEdgeKindToSetMap.end() && "Edge kind not found");
159 return it->second.begin();
160 }

◆ getOutgoingEdgesEnd()

SVFStmt::SVFStmtSetTy::iterator SVF::SVFVar::getOutgoingEdgesEnd ( SVFStmt::PEDGEK  kind) const
inline

Definition at line 162 of file SVFVariables.h.

163 {
164 SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
165 assert(it!=OutEdgeKindToSetMap.end() && "Edge kind not found");
166 return it->second.end();
167 }

◆ getValueName()

virtual const std::string SVF::SVFVar::getValueName ( ) const
pure virtual

◆ hasIncomingEdges()

bool SVF::SVFVar::hasIncomingEdges ( SVFStmt::PEDGEK  kind) const
inline

Definition at line 122 of file SVFVariables.h.

123 {
124 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
125 if (it != InEdgeKindToSetMap.end())
126 return (!it->second.empty());
127 else
128 return false;
129 }

◆ hasIncomingVariantGepEdge()

bool SVF::SVFVar::hasIncomingVariantGepEdge ( ) const
inlineprivate

Check for incoming variable field GEP edges.

Definition at line 214 of file SVFVariables.h.

215 {
216 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::Gep);
217 if (it != InEdgeKindToSetMap.end())
218 {
219 for(auto gep : it->second)
220 {
221 if(SVFUtil::cast<GepStmt>(gep)->isVariantFieldGep())
222 return true;
223 }
224 }
225 return false;
226 }

◆ hasOutgoingEdges()

bool SVF::SVFVar::hasOutgoingEdges ( SVFStmt::PEDGEK  kind) const
inline

Definition at line 131 of file SVFVariables.h.

132 {
133 SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
134 if (it != OutEdgeKindToSetMap.end())
135 return (!it->second.empty());
136 else
137 return false;
138 }

◆ isConstDataOrAggData()

virtual bool SVF::SVFVar::isConstDataOrAggData ( ) const
inlinevirtual

Check if this variable represents constant/aggregate data.

Reimplemented in SVF::GepValVar, SVF::BaseObjVar, SVF::GepObjVar, SVF::ConstAggValVar, SVF::ConstDataValVar, SVF::ConstAggObjVar, and SVF::ConstDataObjVar.

Definition at line 190 of file SVFVariables.h.

191 {
192 return false;
193 }

◆ isConstDataOrAggDataButNotNullPtr()

virtual bool SVF::SVFVar::isConstDataOrAggDataButNotNullPtr ( ) const
inlinevirtual

Check if this variable represents constant data/metadata but not null pointer.

Reimplemented in SVF::GepValVar, SVF::GepObjVar, SVF::ConstAggValVar, SVF::ConstDataValVar, SVF::BlackHoleValVar, SVF::ConstNullPtrValVar, SVF::ConstAggObjVar, SVF::ConstDataObjVar, and SVF::ConstNullPtrObjVar.

Definition at line 93 of file SVFVariables.h.

94 {
95 return false;
96 }

◆ isIsolatedNode()

bool SVFVar::isIsolatedNode ( ) const
virtual

Check if this node is isolated (no edges) in the SVFIR graph.

Reimplemented in SVF::FunObjVar.

Definition at line 61 of file SVFVariables.cpp.

62{
63 if (getInEdges().empty() && getOutEdges().empty())
64 return true;
66 return true;
67 else
68 return false;
69}
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
virtual bool isConstDataOrAggDataButNotNullPtr() const
Check if this variable represents constant data/metadata but not null pointer.

◆ isPointer()

virtual bool SVF::SVFVar::isPointer ( ) const
inlinevirtual

Check if this variable represents a pointer.

Reimplemented in SVF::ArgValVar, SVF::GepValVar, SVF::GepObjVar, SVF::FunValVar, SVF::RetValPN, SVF::VarArgValPN, SVF::DummyValVar, and SVF::DummyObjVar.

Definition at line 86 of file SVFVariables.h.

87 {
88 assert(type && "type is null?");
89 return type->isPointerTy();
90 }
bool isPointerTy() const
Definition SVFType.h:251
const SVFType * type
SVF type.
Definition SVFValue.h:207

◆ ptrInUncalledFunction()

bool SVFVar::ptrInUncalledFunction ( ) const
virtual

Check if this pointer is in an uncalled function.

Reimplemented in SVF::GepValVar, and SVF::GepObjVar.

Definition at line 49 of file SVFVariables.cpp.

50{
51 if (const FunObjVar* fun = getFunction())
52 {
53 return fun->isUncalledFunction();
54 }
55 else
56 {
57 return false;
58 }
59}
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.

◆ toString()

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

Friends And Related Symbol Documentation

◆ IRGraph

Definition at line 52 of file SVFVariables.h.

◆ operator<<

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

Stream operator overload for output.

Definition at line 236 of file SVFVariables.h.

237 {
238 o << node.toString();
239 return o;
240 }

◆ SVFIR

friend class SVFIR
friend

Definition at line 53 of file SVFVariables.h.

◆ SVFIRBuilder

Definition at line 51 of file SVFVariables.h.

◆ VFG

friend class VFG
friend

Definition at line 54 of file SVFVariables.h.

Member Data Documentation

◆ InEdgeKindToSetMap

SVFStmt::KindToSVFStmtMapTy SVF::SVFVar::InEdgeKindToSetMap
protected

Maps tracking incoming and outgoing edges by kind.

Definition at line 71 of file SVFVariables.h.

◆ OutEdgeKindToSetMap

SVFStmt::KindToSVFStmtMapTy SVF::SVFVar::OutEdgeKindToSetMap
protected

Definition at line 72 of file SVFVariables.h.


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