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::SVFBaseNode SVF::ObjVar SVF::ValVar SVF::BaseObjVar SVF::GepObjVar SVF::ConstantDataValVar SVF::DummyValVar SVF::FunValVar SVF::GepValVar SVF::GlobalValVar SVF::RetPN SVF::VarArgPN

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::SVFBaseNode
enum  GNodeK {
  IntraBlock , GlobalBlock , FunEntryBlock , FunExitBlock ,
  FunCallBlock , FunRetBlock , ValNode , FunValNode ,
  GepValNode , RetNode , VarargNode , GlobalValNode ,
  ConstantDataValNode , BlackHoleNode , ConstantFPValNode , ConstantIntValNode ,
  ConstantNullptrValNode , DummyValNode , ObjNode , GepObjNode ,
  BaseObjNode , FunObjNode , HeapObjNode , StackObjNode ,
  GlobalObjNode , ConstantDataObjNode , ConstantFPObjNode , ConstantIntObjNode ,
  ConstantNullptrObjNode , 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 , OtherKd
}
 

Public Member Functions

 SVFVar (const SVFValue *val, NodeID i, PNODEK k)
 Constructor.
 
virtual ~SVFVar ()
 Destructor.
 
const SVFValuegetValue () const
 Get/has methods of the components.
 
virtual const SVFTypegetType () const
 Return type of the value.
 
bool hasValue () const
 
virtual bool isPointer () const
 Whether it is a pointer.
 
bool isConstDataOrAggDataButNotNullPtr () const
 
virtual bool isIsolatedNode () const
 Whether this is an isolated node on the SVFIR graph.
 
virtual const std::string getValueName () const =0
 Get name of the LLVM value.
 
virtual const SVFFunctiongetFunction () const
 
SVFStmt::SVFStmtSetTygetIncomingEdges (SVFStmt::PEDGEK kind)
 Get incoming SVFIR statements (edges)
 
SVFStmt::SVFStmtSetTygetOutgoingEdges (SVFStmt::PEDGEK kind)
 Get outgoing SVFIR statements (edges)
 
bool hasIncomingEdges (SVFStmt::PEDGEK kind) const
 Has incoming SVFIR statements (edges)
 
bool hasOutgoingEdges (SVFStmt::PEDGEK kind) const
 Has outgoing SVFIR statements (edges)
 
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesBegin (SVFStmt::PEDGEK kind) const
 Get incoming SVFStmt iterator.
 
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesEnd (SVFStmt::PEDGEK kind) const
 Get incoming SVFStmt iterator.
 
SVFStmt::SVFStmtSetTy::iterator getOutgoingEdgesBegin (SVFStmt::PEDGEK kind) const
 Get outgoing SVFStmt iterator.
 
SVFStmt::SVFStmtSetTy::iterator getOutgoingEdgesEnd (SVFStmt::PEDGEK kind) const
 Get outgoing SVFStmt iterator.
 
virtual const std::string toString () const
 
void dump () const
 Dump to console for debugging.
 
- Public Member Functions inherited from SVF::GenericNode< NodeTy, EdgeTy >
 GenericNode (NodeID i, GNodeK k)
 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::SVFBaseNode
 SVFBaseNode (NodeID i, GNodeK k, SVFType *ty=nullptr)
 
NodeID getId () const
 Get ID.
 
GNodeK getNodeKind () const
 Get node kind.
 
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 *)
 
static bool classof (const GenericPAGNodeTy *node)
 
static bool classof (const SVFBaseNode *node)
 
- Static Public Member Functions inherited from SVF::GenericNode< NodeTy, EdgeTy >
static bool classof (const GenericNode< NodeTy, EdgeTy > *)
 
static bool classof (const SVFBaseNode *)
 

Protected Member Functions

 SVFVar (NodeID i, PNODEK k)
 function containing this variable
 

Protected Attributes

const SVFValuevalue
 value of this SVFIR node
 
SVFStmt::KindToSVFStmtMapTy InEdgeKindToSetMap
 
SVFStmt::KindToSVFStmtMapTy OutEdgeKindToSetMap
 
bool isPtr
 
const SVFFunctionfunc
 whether it is a pointer (top-level or address-taken)
 
- Protected Attributes inherited from SVF::SVFBaseNode
NodeID id
 Node ID.
 
GNodeK nodeKind
 Node kind.
 
const SVFTypetype
 SVF type.
 
std::string sourceLoc
 Source code information of this value.
 

Private Member Functions

void addInEdge (SVFStmt *inEdge)
 add methods of the components
 
void addOutEdge (SVFStmt *outEdge)
 
bool hasIncomingVariantGepEdge () const
 Has incoming VariantGepEdges.
 

Friends

class SVFIRWriter
 
class SVFIRReader
 
class IRGraph
 
class SVFIR
 
class VFG
 
OutStreamoperator<< (OutStream &o, const SVFVar &node)
 Overloading operator << for dumping SVFVar value.
 

Additional Inherited Members

- Static Protected Member Functions inherited from SVF::SVFBaseNode
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 45 of file SVFVariables.h.

Member Typedef Documentation

◆ GEdgeKind

Definition at line 64 of file SVFVariables.h.

◆ PNODEK

Nine kinds of SVFIR variables ValNode: llvm pointer value ObjNode: memory object RetNode: unique return node Vararg: unique node for vararg parameter GepValNode: temporary gep value node for field sensitivity GepValNode: temporary gep obj node for field sensitivity BaseObjNode: for field insensitive analysis DummyValNode and DummyObjNode: for non-llvm-value node

Definition at line 63 of file SVFVariables.h.

Constructor & Destructor Documentation

◆ SVFVar() [1/2]

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

function containing this variable

Constructor to create an empty object (for deserialization)

Definition at line 74 of file SVFVariables.h.

74: GenericPAGNodeTy(i, k), value{} {}
const SVFValue * value
value of this SVFIR node
GenericNode< SVFVar, SVFStmt > GenericPAGNodeTy
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ SVFVar() [2/2]

SVFVar::SVFVar ( const SVFValue val,
NodeID  i,
PNODEK  k 
)

Constructor.

SVFVar constructor

Definition at line 42 of file SVFVariables.cpp.

42 :
43 GenericPAGNodeTy(i,k), value(val), func(nullptr)
44{
45 assert( ValNode <= k && k <= DummyObjNode && "new SVFIR node kind?");
46 switch (k)
47 {
48 case ValNode:
50 case GlobalValNode:
51 case BlackHoleNode:
55 case GepValNode:
56 {
57 assert(val != nullptr && "value is nullptr for ValVar or GepValNode");
58 isPtr = val->getType()->isPointerTy();
59 break;
60 }
61 case FunValNode:
62 case VarargNode:
63 case DummyValNode:
64 {
65 isPtr = true;
66 break;
67 }
68 case ObjNode:
69 case GepObjNode:
70 case BaseObjNode:
72 case GlobalObjNode:
76 case DummyObjNode:
77 {
78 isPtr = true;
79 if(val)
80 isPtr = val->getType()->isPointerTy();
81 break;
82 }
83 case RetNode:
84 case FunObjNode:
85 case HeapObjNode:
86 case StackObjNode:
87 {
88 // to be completed in derived class
89 break;
90 }
91 default:
92 assert(false && "var not handled");
93 break;
94 }
95}
const SVFFunction * func
whether it is a pointer (top-level or address-taken)

◆ ~SVFVar()

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

Destructor.

Definition at line 80 of file SVFVariables.h.

80{}

Member Function Documentation

◆ addInEdge()

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

add methods of the components

Definition at line 227 of file SVFVariables.h.

228 {
229 GEdgeKind kind = inEdge->getEdgeKind();
230 InEdgeKindToSetMap[kind].insert(inEdge);
232 }
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
SVFStmt::KindToSVFStmtMapTy InEdgeKindToSetMap
s64_t GEdgeKind

◆ addOutEdge()

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

Definition at line 234 of file SVFVariables.h.

235 {
236 GEdgeKind kind = outEdge->getEdgeKind();
237 OutEdgeKindToSetMap[kind].insert(outEdge);
239 }
bool addOutgoingEdge(EdgeType *outEdge)
SVFStmt::KindToSVFStmtMapTy OutEdgeKindToSetMap

◆ classof() [1/3]

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

Definition at line 214 of file SVFVariables.h.

215 {
216 return isSVFVarKind(node->getNodeKind());
217 }
static bool isSVFVarKind(GNodeK n)

◆ classof() [2/3]

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

Definition at line 219 of file SVFVariables.h.

220 {
221 return isSVFVarKind(node->getNodeKind());
222 }

◆ classof() [3/3]

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

Definition at line 209 of file SVFVariables.h.

210 {
211 return true;
212 }

◆ dump()

void SVFVar::dump ( ) const

Dump to console for debugging.

Definition at line 116 of file SVFVariables.cpp.

117{
118 outs() << this->toString() << "\n";
119}
virtual const std::string toString() const
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50

◆ getFunction()

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

Return the function containing this SVFVar

Returns
The SVFFunction containing this variable, or nullptr if it's a global/constant expression

Reimplemented in SVF::RetPN, and SVF::VarArgPN.

Definition at line 123 of file SVFVariables.h.

124 {
125 // Return cached function if available
126 if(func) return func;
127
128 // If we have an associated LLVM value, check its parent function
129 if (value)
130 {
131 // For instructions, return the function containing the parent basic block
132 if (auto inst = SVFUtil::dyn_cast<SVFInstruction>(value))
133 {
134 return inst->getParent()->getParent();
135 }
136 // For function arguments, return their parent function
137 else if (auto arg = SVFUtil::dyn_cast<SVFArgument>(value))
138 {
139 return arg->getParent();
140 }
141 }
142
143 // Return nullptr for globals/constants with no parent function
144 return nullptr;
145 }

◆ getIncomingEdges()

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

Get incoming SVFIR statements (edges)

Definition at line 148 of file SVFVariables.h.

149 {
150 return InEdgeKindToSetMap[kind];
151 }

◆ getIncomingEdgesBegin()

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

Get incoming SVFStmt iterator.

Definition at line 177 of file SVFVariables.h.

178 {
179 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
180 assert(it!=InEdgeKindToSetMap.end() && "The node does not have such kind of edge");
181 return it->second.begin();
182 }

◆ getIncomingEdgesEnd()

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

Get incoming SVFStmt iterator.

Definition at line 185 of file SVFVariables.h.

186 {
187 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
188 assert(it!=InEdgeKindToSetMap.end() && "The node does not have such kind of edge");
189 return it->second.end();
190 }

◆ getOutgoingEdges()

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

Get outgoing SVFIR statements (edges)

Definition at line 153 of file SVFVariables.h.

154 {
155 return OutEdgeKindToSetMap[kind];
156 }

◆ getOutgoingEdgesBegin()

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

Get outgoing SVFStmt iterator.

Definition at line 193 of file SVFVariables.h.

194 {
195 SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
196 assert(it!=OutEdgeKindToSetMap.end() && "The node does not have such kind of edge");
197 return it->second.begin();
198 }

◆ getOutgoingEdgesEnd()

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

Get outgoing SVFStmt iterator.

Definition at line 201 of file SVFVariables.h.

202 {
203 SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
204 assert(it!=OutEdgeKindToSetMap.end() && "The node does not have such kind of edge");
205 return it->second.end();
206 }

◆ getType()

virtual const SVFType * SVF::SVFVar::getType ( ) const
inlinevirtual

Return type of the value.

Reimplemented from SVF::SVFBaseNode.

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

Definition at line 96 of file SVFVariables.h.

97 {
98 return value ? value->getType() : nullptr;
99 }
virtual const SVFType * getType() const
Definition SVFValue.h:256

◆ getValue()

const SVFValue * SVF::SVFVar::getValue ( ) const
inline

Get/has methods of the components.

Definition at line 84 of file SVFVariables.h.

85 {
86 assert(this->getNodeKind() != DummyValNode &&
87 this->getNodeKind() != DummyObjNode &&
88 "dummy node do not have value!");
90 "blackhole and constant obj do not have value");
91 assert(value && "value is null (GepObjNode whose basenode is a DummyObj?)");
92 return value;
93 }
GNodeK getNodeKind() const
Get node kind.
NodeID getId() const
Get ID.
static bool isBlkObjOrConstantObj(NodeID id)

◆ getValueName()

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

◆ hasIncomingEdges()

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

Has incoming SVFIR statements (edges)

Definition at line 158 of file SVFVariables.h.

159 {
160 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
161 if (it != InEdgeKindToSetMap.end())
162 return (!it->second.empty());
163 else
164 return false;
165 }

◆ hasIncomingVariantGepEdge()

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

Has incoming VariantGepEdges.

Definition at line 241 of file SVFVariables.h.

242 {
243 SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::Gep);
244 if (it != InEdgeKindToSetMap.end())
245 {
246 for(auto gep : it->second)
247 {
248 if(SVFUtil::cast<GepStmt>(gep)->isVariantFieldGep())
249 return true;
250 }
251 }
252 return false;
253 }

◆ hasOutgoingEdges()

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

Has outgoing SVFIR statements (edges)

Definition at line 167 of file SVFVariables.h.

168 {
169 SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
170 if (it != OutEdgeKindToSetMap.end())
171 return (!it->second.empty());
172 else
173 return false;
174 }

◆ hasValue()

bool SVF::SVFVar::hasValue ( ) const
inline

Definition at line 101 of file SVFVariables.h.

102 {
103 return value != nullptr;
104 }

◆ isConstDataOrAggDataButNotNullPtr()

bool SVFVar::isConstDataOrAggDataButNotNullPtr ( ) const

Whether it is constant data, i.e., "0", "1.001", "str" or llvm's metadata, i.e., metadata !4087

Definition at line 464 of file SVFVariables.cpp.

465{
466 if (hasValue())
467 return value->isConstDataOrAggData() && (!SVFUtil::isa<SVFConstantNullPtr>(value)) && (!SVFUtil::isa<SVFBlackHoleValue>(value));
468 else
469 return false;
470}
bool isConstDataOrAggData() const
Definition SVFValue.h:260
bool hasValue() const

◆ isIsolatedNode()

bool SVFVar::isIsolatedNode ( ) const
virtual

Whether this is an isolated node on the SVFIR graph.

Reimplemented in SVF::FunObjVar.

Definition at line 97 of file SVFVariables.cpp.

98{
99 if (getInEdges().empty() && getOutEdges().empty())
100 return true;
102 return true;
103 else
104 return false;
105}
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
bool isConstDataOrAggDataButNotNullPtr() const

◆ isPointer()

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

Whether it is a pointer.

Definition at line 106 of file SVFVariables.h.

107 {
108 return isPtr;
109 }

◆ toString()

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

Friends And Related Symbol Documentation

◆ IRGraph

Definition at line 49 of file SVFVariables.h.

◆ operator<<

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

Overloading operator << for dumping SVFVar value.

Definition at line 264 of file SVFVariables.h.

265 {
266 o << node.toString();
267 return o;
268 }

◆ SVFIR

friend class SVFIR
friend

Definition at line 50 of file SVFVariables.h.

◆ SVFIRReader

Definition at line 48 of file SVFVariables.h.

◆ SVFIRWriter

Definition at line 47 of file SVFVariables.h.

◆ VFG

friend class VFG
friend

Definition at line 51 of file SVFVariables.h.

Member Data Documentation

◆ func

const SVFFunction* SVF::SVFVar::func
protected

whether it is a pointer (top-level or address-taken)

Definition at line 71 of file SVFVariables.h.

◆ InEdgeKindToSetMap

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

Definition at line 68 of file SVFVariables.h.

◆ isPtr

bool SVF::SVFVar::isPtr
protected

Definition at line 70 of file SVFVariables.h.

◆ OutEdgeKindToSetMap

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

Definition at line 69 of file SVFVariables.h.

◆ value

const SVFValue* SVF::SVFVar::value
protected

value of this SVFIR node

Definition at line 67 of file SVFVariables.h.


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