Static Value-Flow Analysis
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::DummyObjVar SVF::FIObjVar SVF::GepObjVar SVF::DummyValVar SVF::GepValVar 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. More...
 
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 , GepValNode ,
  RetNode , VarargNode , DummyValNode , ObjNode ,
  GepObjNode , FIObjNode , 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. More...
 
virtual ~SVFVar ()
 Destructor. More...
 
const SVFValuegetValue () const
 Get/has methods of the components. More...
 
virtual const SVFTypegetType () const
 Return type of the value. More...
 
bool hasValue () const
 
virtual bool isPointer () const
 Whether it is a pointer. More...
 
bool isConstDataOrAggDataButNotNullPtr () const
 
bool isIsolatedNode () const
 Whether this is an isolated node on the SVFIR graph. More...
 
virtual const std::string getValueName () const =0
 Get name of the LLVM value. More...
 
virtual const SVFFunctiongetFunction () const
 Return the function that this SVFVar resides in. Return nullptr if it is a global or constantexpr node. More...
 
SVFStmt::SVFStmtSetTygetIncomingEdges (SVFStmt::PEDGEK kind)
 Get incoming SVFIR statements (edges) More...
 
SVFStmt::SVFStmtSetTygetOutgoingEdges (SVFStmt::PEDGEK kind)
 Get outgoing SVFIR statements (edges) More...
 
bool hasIncomingEdges (SVFStmt::PEDGEK kind) const
 Has incoming SVFIR statements (edges) More...
 
bool hasOutgoingEdges (SVFStmt::PEDGEK kind) const
 Has outgoing SVFIR statements (edges) More...
 
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesBegin (SVFStmt::PEDGEK kind) const
 Get incoming SVFStmt iterator. More...
 
SVFStmt::SVFStmtSetTy::iterator getIncomingEdgesEnd (SVFStmt::PEDGEK kind) const
 Get incoming SVFStmt iterator. More...
 
SVFStmt::SVFStmtSetTy::iterator getOutgoingEdgesBegin (SVFStmt::PEDGEK kind) const
 Get outgoing SVFStmt iterator. More...
 
SVFStmt::SVFStmtSetTy::iterator getOutgoingEdgesEnd (SVFStmt::PEDGEK kind) const
 Get outgoing SVFStmt iterator. More...
 
virtual const std::string toString () const
 
void dump () const
 Dump to console for debugging. More...
 
- Public Member Functions inherited from SVF::GenericNode< NodeTy, EdgeTy >
 GenericNode (NodeID i, GNodeK k)
 Constructor. More...
 
virtual ~GenericNode ()
 Destructor. More...
 
bool hasIncomingEdge () const
 Has incoming/outgoing edge set. More...
 
bool hasOutgoingEdge () const
 
iterator OutEdgeBegin ()
 iterators More...
 
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. More...
 
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. More...
 
bool addOutgoingEdge (EdgeType *outEdge)
 
EdgeTypehasIncomingEdge (EdgeType *edge) const
 Find incoming and outgoing edges. More...
 
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. More...
 
GNodeK getNodeKind () const
 Get node kind. More...
 
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)
 whether it is a pointer (top-level or address-taken) More...
 

Protected Attributes

const SVFValuevalue
 value of this SVFIR node More...
 
SVFStmt::KindToSVFStmtMapTy InEdgeKindToSetMap
 
SVFStmt::KindToSVFStmtMapTy OutEdgeKindToSetMap
 
bool isPtr
 
- Protected Attributes inherited from SVF::SVFBaseNode
NodeID id
 Node ID. More...
 
GNodeK nodeKind
 Node kind. More...
 
const SVFTypetype
 SVF type. More...
 
std::string sourceLoc
 Source code information of this value. More...
 

Private Member Functions

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

Friends

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

Additional Inherited Members

- Static Protected Member Functions inherited from SVF::SVFBaseNode
static bool isICFGNodeKinds (GNodeK n)
 Helper functions to check node kinds. More...
 
static bool isInterICFGNodeKind (GNodeK n)
 
static bool isSVFVarKind (GNodeK n)
 
static bool isValVarKinds (GNodeK n)
 
static bool isObjVarKinds (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 FIObjNode: 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

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

Constructor to create an empty object (for deserialization)

Definition at line 73 of file SVFVariables.h.

73 : GenericPAGNodeTy(i, k), value{} {}
const SVFValue * value
value of this SVFIR node
Definition: SVFVariables.h:67
GenericNode< SVFVar, SVFStmt > GenericPAGNodeTy
Definition: SVFVariables.h:40

◆ SVFVar() [2/2]

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

Constructor.

SVFVar constructor

Definition at line 41 of file SVFVariables.cpp.

41  :
42  GenericPAGNodeTy(i,k), value(val)
43 {
44  assert( ValNode <= k && k <= DummyObjNode && "new SVFIR node kind?");
45  switch (k)
46  {
47  case ValNode:
48  case GepValNode:
49  {
50  assert(val != nullptr && "value is nullptr for ValVar or GepValNode");
51  isPtr = val->getType()->isPointerTy();
52  break;
53  }
54  case RetNode:
55  {
56  assert(val != nullptr && "value is nullptr for RetNode");
57  isPtr = SVFUtil::cast<SVFFunction>(val)->getReturnType()->isPointerTy();
58  break;
59  }
60  case VarargNode:
61  case DummyValNode:
62  {
63  isPtr = true;
64  break;
65  }
66  case ObjNode:
67  case GepObjNode:
68  case FIObjNode:
69  case DummyObjNode:
70  {
71  isPtr = true;
72  if(val)
73  isPtr = val->getType()->isPointerTy();
74  break;
75  }
76  default:
77  assert(false && "var not handled");
78  break;
79  }
80 }
bool isPointerTy() const
Definition: SVFType.h:249
virtual const SVFType * getType() const
Definition: SVFValue.h:256

◆ ~SVFVar()

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

Destructor.

Definition at line 79 of file SVFVariables.h.

79 {}

Member Function Documentation

◆ addInEdge()

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

add methods of the components

Definition at line 216 of file SVFVariables.h.

217  {
218  GEdgeKind kind = inEdge->getEdgeKind();
219  InEdgeKindToSetMap[kind].insert(inEdge);
220  addIncomingEdge(inEdge);
221  }
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
Definition: GenericGraph.h:527
SVFStmt::KindToSVFStmtMapTy InEdgeKindToSetMap
Definition: SVFVariables.h:68
s64_t GEdgeKind
Definition: SVFVariables.h:64

◆ addOutEdge()

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

Definition at line 223 of file SVFVariables.h.

224  {
225  GEdgeKind kind = outEdge->getEdgeKind();
226  OutEdgeKindToSetMap[kind].insert(outEdge);
227  addOutgoingEdge(outEdge);
228  }
bool addOutgoingEdge(EdgeType *outEdge)
Definition: GenericGraph.h:531
SVFStmt::KindToSVFStmtMapTy OutEdgeKindToSetMap
Definition: SVFVariables.h:69

◆ classof() [1/3]

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

Definition at line 203 of file SVFVariables.h.

204  {
205  return isSVFVarKind(node->getNodeKind());
206  }
static bool isSVFVarKind(GNodeK n)
Definition: GenericGraph.h:314

◆ classof() [2/3]

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

Definition at line 208 of file SVFVariables.h.

209  {
210  return isSVFVarKind(node->getNodeKind());
211  }

◆ classof() [3/3]

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

Definition at line 198 of file SVFVariables.h.

199  {
200  return true;
201  }

◆ dump()

void SVFVar::dump ( ) const

Dump to console for debugging.

Definition at line 103 of file SVFVariables.cpp.

104 {
105  outs() << this->toString() << "\n";
106 }
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 that this SVFVar resides in. Return nullptr if it is a global or constantexpr node.

Definition at line 122 of file SVFVariables.h.

123  {
124  if (value)
125  {
126  if (auto inst = SVFUtil::dyn_cast<SVFInstruction>(value))
127  return inst->getParent()->getParent();
128  else if (auto arg = SVFUtil::dyn_cast<SVFArgument>(value))
129  return arg->getParent();
130  else if (auto fun = SVFUtil::dyn_cast<SVFFunction>(value))
131  return fun;
132  }
133  return nullptr;
134  }

◆ getIncomingEdges()

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

Get incoming SVFIR statements (edges)

Definition at line 137 of file SVFVariables.h.

138  {
139  return InEdgeKindToSetMap[kind];
140  }

◆ getIncomingEdgesBegin()

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

Get incoming SVFStmt iterator.

Definition at line 166 of file SVFVariables.h.

167  {
168  SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
169  assert(it!=InEdgeKindToSetMap.end() && "The node does not have such kind of edge");
170  return it->second.begin();
171  }

◆ getIncomingEdgesEnd()

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

Get incoming SVFStmt iterator.

Definition at line 174 of file SVFVariables.h.

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

◆ getOutgoingEdges()

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

Get outgoing SVFIR statements (edges)

Definition at line 142 of file SVFVariables.h.

143  {
144  return OutEdgeKindToSetMap[kind];
145  }

◆ getOutgoingEdgesBegin()

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

Get outgoing SVFStmt iterator.

Definition at line 182 of file SVFVariables.h.

183  {
184  SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
185  assert(it!=OutEdgeKindToSetMap.end() && "The node does not have such kind of edge");
186  return it->second.begin();
187  }

◆ getOutgoingEdgesEnd()

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

Get outgoing SVFStmt iterator.

Definition at line 190 of file SVFVariables.h.

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

◆ getType()

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

Return type of the value.

Reimplemented from SVF::SVFBaseNode.

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

Definition at line 96 of file SVFVariables.h.

97  {
98  return value ? value->getType() : nullptr;
99  }

◆ getValue()

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

Get/has methods of the components.

Definition at line 83 of file SVFVariables.h.

84  {
85  assert(this->getNodeKind() != DummyValNode &&
86  this->getNodeKind() != DummyObjNode &&
87  "dummy node do not have value!");
89  "blackhole and constant obj do not have value");
90  assert(value &&
91  "value is null (GepObjNode whose basenode is a DummyObj?)");
92  return value;
93  }
GNodeK getNodeKind() const
Get node kind.
Definition: GenericGraph.h:266
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
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 147 of file SVFVariables.h.

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

◆ hasIncomingVariantGepEdge()

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

Has incoming VariantGepEdges.

Definition at line 230 of file SVFVariables.h.

231  {
232  SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::Gep);
233  if (it != InEdgeKindToSetMap.end())
234  {
235  for(auto gep : it->second)
236  {
237  if(SVFUtil::cast<GepStmt>(gep)->isVariantFieldGep())
238  return true;
239  }
240  }
241  return false;
242  }

◆ hasOutgoingEdges()

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

Has outgoing SVFIR statements (edges)

Definition at line 156 of file SVFVariables.h.

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

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

208 {
209  if (hasValue())
210  return value->isConstDataOrAggData() && (!SVFUtil::isa<SVFConstantNullPtr>(value)) && (!SVFUtil::isa<SVFBlackHoleValue>(value));
211  else
212  return false;
213 }
bool isConstDataOrAggData() const
Definition: SVFValue.h:260
bool hasValue() const
Definition: SVFVariables.h:101

◆ isIsolatedNode()

bool SVFVar::isIsolatedNode ( ) const

Whether this is an isolated node on the SVFIR graph.

Definition at line 82 of file SVFVariables.cpp.

83 {
84  if (getInEdges().empty() && getOutEdges().empty())
85  return true;
87  return true;
88  else if (value && SVFUtil::isa<SVFFunction>(value))
89  return SVFUtil::cast<SVFFunction>(value)->isIntrinsic();
90  else
91  return false;
92 }
const GEdgeSetTy & getOutEdges() const
Definition: GenericGraph.h:430
const GEdgeSetTy & getInEdges() const
Definition: GenericGraph.h:434
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

Reimplemented in SVF::DummyObjVar, SVF::DummyValVar, SVF::VarArgPN, SVF::RetPN, SVF::FIObjVar, SVF::GepObjVar, SVF::GepValVar, SVF::ObjVar, and SVF::ValVar.

Definition at line 95 of file SVFVariables.cpp.

96 {
97  std::string str;
98  std::stringstream rawstr(str);
99  rawstr << "SVFVar ID: " << getId();
100  return rawstr.str();
101 }
const char *const string
Definition: cJSON.h:172

Friends And Related Function Documentation

◆ IRGraph

friend class IRGraph
friend

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 253 of file SVFVariables.h.

254  {
255  o << node.toString();
256  return o;
257  }

◆ SVFIR

friend class SVFIR
friend

Definition at line 50 of file SVFVariables.h.

◆ SVFIRReader

friend class SVFIRReader
friend

Definition at line 48 of file SVFVariables.h.

◆ SVFIRWriter

friend class SVFIRWriter
friend

Definition at line 47 of file SVFVariables.h.

◆ VFG

friend class VFG
friend

Definition at line 51 of file SVFVariables.h.

Member Data Documentation

◆ 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: