Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVF::SVFVar Class Referenceabstract

#include <SVFVariables.h>

Inheritance diagram for SVF::SVFVar:
SVF::GenericNode< SVFVar, SVFStmt > SVF::SVFValue SVF::ObjVar SVF::ValVar SVF::BaseObjVar SVF::GepObjVar SVF::ArgValVar SVF::AsmPCValVar SVF::ConstDataValVar SVF::DummyValVar SVF::FunValVar SVF::GepValVar SVF::GlobalValVar SVF::IntrinsicValVar SVF::RetValPN SVF::VarArgValPN

Public Types

typedef GNodeK PNODEK
typedef s64_t GEdgeKind
Public Types inherited from SVF::GenericNode< SVFVar, SVFStmt >
typedef SVFVar NodeType
typedef SVFStmt 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 , ConstDataValNode , BlackHoleValNode , ConstFPValNode ,
  ConstIntValNode , ConstNullptrValNode , DummyValNode , IntrinsicValNode ,
  AsmPCValNode , ObjNode , GepObjNode , BaseObjNode ,
  FunObjNode , HeapObjNode , StackObjNode , GlobalObjNode ,
  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 ,
  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 FunObjVar * getFunction () const
 Get containing function, or null for globals/constants.
SVFStmt::SVFStmtSetTy & getIncomingEdges (SVFStmt::PEDGEK kind)
 Edge accessors and checkers.
SVFStmt::SVFStmtSetTy & getOutgoingEdges (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< SVFVar, SVFStmt >
 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)
EdgeType * hasIncomingEdge (EdgeType *edge) const
 Find incoming and outgoing edges.
EdgeType * hasOutgoingEdge (EdgeType *edge) const
const GEdgeSetTy & getOutEdges () const
const GEdgeSetTy & getInEdges () 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 SVFType * getType () 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 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< SVFVar, SVFStmt >
static bool classof (const GenericNode< SVFVar, SVFStmt > *)
static bool classof (const SVFValue *)

Protected Member Functions

const SVFStmt::KindToSVFStmtMapTy & getInEdgeKindToSetMap () const
const SVFStmt::KindToSVFStmtMapTy & getOutEdgeKindToSetMap () const

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 SVFType * type
 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
class GraphDBClient
OutStream & operator<< (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 54 of file SVFVariables.h.

Member Typedef Documentation

◆ GEdgeKind

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

Constructor & Destructor Documentation

◆ SVFVar()

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

Standard constructor with ID, type and kind.

SVFVar constructor

Definition at line 45 of file SVFVariables.cpp.

45 :
46 GenericPAGNodeTy(i,k, svfType)
47{
48}
GenericNode< SVFVar, SVFStmt > GenericPAGNodeTy

◆ ~SVFVar()

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

Virtual destructor.

Definition at line 98 of file SVFVariables.h.

98{}

Member Function Documentation

◆ addInEdge()

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

Edge management methods.

Definition at line 214 of file SVFVariables.h.

215 {
216 GEdgeKind kind = inEdge->getEdgeKind();
217 InEdgeKindToSetMap[kind].insert(inEdge);
218 addIncomingEdge(inEdge);
219 }
bool addIncomingEdge(EdgeType *inEdge)
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 221 of file SVFVariables.h.

222 {
223 GEdgeKind kind = outEdge->getEdgeKind();
224 OutEdgeKindToSetMap[kind].insert(outEdge);
225 addOutgoingEdge(outEdge);
226 }
bool addOutgoingEdge(EdgeType *outEdge)
SVFStmt::KindToSVFStmtMapTy OutEdgeKindToSetMap

◆ classof() [1/3]

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

Definition at line 191 of file SVFVariables.h.

192 {
193 return isSVFVarKind(node->getNodeKind());
194 }
static bool isSVFVarKind(GNodeK n)
Definition SVFValue.h:229

◆ classof() [2/3]

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

Definition at line 196 of file SVFVariables.h.

197 {
198 return isSVFVarKind(node->getNodeKind());
199 }

◆ classof() [3/3]

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

Type checking support for LLVM-style RTTI.

Definition at line 186 of file SVFVariables.h.

187 {
188 return true;
189 }

◆ dump()

void SVFVar::dump ( ) const

Debug dump to console.

Definition at line 81 of file SVFVariables.cpp.

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

◆ getFunction()

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

Get containing function, or null for globals/constants.

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

Definition at line 120 of file SVFVariables.h.

121 {
122 return nullptr;
123 }

◆ getIncomingEdges()

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

Edge accessors and checkers.

Definition at line 127 of file SVFVariables.h.

128 {
129 return InEdgeKindToSetMap[kind];
130 }

◆ getIncomingEdgesBegin()

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

Edge iterators.

Definition at line 156 of file SVFVariables.h.

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

◆ getIncomingEdgesEnd()

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

Definition at line 163 of file SVFVariables.h.

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

◆ getInEdgeKindToSetMap()

const SVFStmt::KindToSVFStmtMapTy & SVF::SVFVar::getInEdgeKindToSetMap ( ) const
inlineprotected

Definition at line 81 of file SVFVariables.h.

82 {
83 return InEdgeKindToSetMap;
84 }

◆ getOutEdgeKindToSetMap()

const SVFStmt::KindToSVFStmtMapTy & SVF::SVFVar::getOutEdgeKindToSetMap ( ) const
inlineprotected

Definition at line 87 of file SVFVariables.h.

88 {
90 }

◆ getOutgoingEdges()

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

Definition at line 132 of file SVFVariables.h.

133 {
134 return OutEdgeKindToSetMap[kind];
135 }

◆ getOutgoingEdgesBegin()

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

Definition at line 170 of file SVFVariables.h.

171 {
172 SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
173 assert(it!=OutEdgeKindToSetMap.end() && "Edge kind not found");
174 return it->second.begin();
175 }

◆ getOutgoingEdgesEnd()

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

Definition at line 177 of file SVFVariables.h.

178 {
179 SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
180 assert(it!=OutEdgeKindToSetMap.end() && "Edge kind not found");
181 return it->second.end();
182 }

◆ getValueName()

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

◆ hasIncomingEdges()

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

Definition at line 137 of file SVFVariables.h.

138 {
139 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
140 if (it != InEdgeKindToSetMap.end())
141 return (!it->second.empty());
142 else
143 return false;
144 }

◆ hasIncomingVariantGepEdge()

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

Check for incoming variable field GEP edges.

Definition at line 229 of file SVFVariables.h.

230 {
231 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::Gep);
232 if (it != InEdgeKindToSetMap.end())
233 {
234 for(auto gep : it->second)
235 {
236 if(SVFUtil::cast<GepStmt>(gep)->isVariantFieldGep())
237 return true;
238 }
239 }
240 return false;
241 }
std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > cast(const Y &Val)
Definition Casting.h:360

◆ hasOutgoingEdges()

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

Definition at line 146 of file SVFVariables.h.

147 {
148 SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
149 if (it != OutEdgeKindToSetMap.end())
150 return (!it->second.empty());
151 else
152 return false;
153 }

◆ isConstDataOrAggData()

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

Check if this variable represents constant/aggregate data.

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

Definition at line 205 of file SVFVariables.h.

206 {
207 return false;
208 }

◆ isConstDataOrAggDataButNotNullPtr()

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

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

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

Definition at line 108 of file SVFVariables.h.

109 {
110 return false;
111 }

◆ 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 62 of file SVFVariables.cpp.

63{
64 if (getInEdges().empty() && getOutEdges().empty())
65 return true;
67 return true;
68 else
69 return false;
70}
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::DummyObjVar, SVF::DummyValVar, SVF::FunValVar, SVF::GepObjVar, SVF::GepValVar, SVF::RetValPN, and SVF::VarArgValPN.

Definition at line 101 of file SVFVariables.h.

102 {
103 assert(type && "type is null?");
104 return type->isPointerTy();
105 }
const SVFType * type
SVF type.
Definition SVFValue.h:206

◆ ptrInUncalledFunction()

bool SVFVar::ptrInUncalledFunction ( ) const
virtual

Check if this pointer is in an uncalled function.

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

Definition at line 50 of file SVFVariables.cpp.

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

◆ toString()

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

◆ GraphDBClient

friend class GraphDBClient
friend

Definition at line 61 of file SVFVariables.h.

◆ IRGraph

friend class IRGraph
friend

Definition at line 58 of file SVFVariables.h.

◆ operator<<

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

Stream operator overload for output.

Definition at line 251 of file SVFVariables.h.

252 {
253 o << node.toString();
254 return o;
255 }

◆ SVFIR

friend class SVFIR
friend

Definition at line 59 of file SVFVariables.h.

◆ SVFIRBuilder

friend class SVFIRBuilder
friend

Definition at line 57 of file SVFVariables.h.

◆ VFG

friend class VFG
friend

Definition at line 60 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 78 of file SVFVariables.h.

◆ OutEdgeKindToSetMap

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

Definition at line 79 of file SVFVariables.h.


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