Static Value-Flow Analysis
Public Types | Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
SVF::SVFBaseNode Class Reference

#include <GenericGraph.h>

Inheritance diagram for SVF::SVFBaseNode:
SVF::GenericNode< DCHNode, DCHEdge > SVF::GenericNode< ConstraintNode, ConstraintEdge > SVF::GenericNode< CFLNode, CFLEdge > SVF::GenericNode< NodeTy, EdgeTy > SVF::DCHNode SVF::ConstraintNode SVF::CFLNode SVF::CDGNode SVF::CHNode SVF::ICFGNode SVF::PTACallGraphNode SVF::SVFVar SVF::TCTNode SVF::VFGNode

Public Types

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

 SVFBaseNode (NodeID i, GNodeK k, SVFType *ty=nullptr)
 
NodeID getId () const
 Get ID. More...
 
GNodeK getNodeKind () const
 Get node kind. More...
 
virtual const SVFTypegetType () const
 
virtual void setSourceLoc (const std::string &sourceCodeInfo)
 
virtual const std::string getSourceLoc () const
 
const std::string valueOnlyToString () const
 

Static Protected Member Functions

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)
 

Protected Attributes

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...
 

Detailed Description

Definition at line 137 of file GenericGraph.h.

Member Enumeration Documentation

◆ GNodeK

Enumerator
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 

Definition at line 142 of file GenericGraph.h.

143  {
144  // ┌── ICFGNodeKinds: Combines inter-procedural and intra-procedural control flow graph nodes
145  // │ ├── Represents a node within a single procedure
146  IntraBlock,
147  // │ └── Represents a global-level block
148  GlobalBlock,
149  // │ └─ InterICFGNodeKinds: Types of inter-procedural control flow graph nodes
150  // │ ├── Entry point of a function
152  // │ ├── Exit point of a function
153  FunExitBlock,
154  // │ ├── Call site in the function
155  FunCallBlock,
156  // │ └── Return site in the function
157  FunRetBlock,
158  // └────────
159 
160  // ┌── SVFVarKinds: Combines ValVarKinds and ObjVarKinds for variable nodes
161  // │ ┌── ValVarKinds: Types of value variable nodes
162  // │ │ ├── Represents a standard value variable
163  ValNode,
164  // │ │ ├── Represents a GEP value variable
165  GepValNode,
166  // │ │ ├── Represents a return value node
167  RetNode,
168  // │ │ ├── Represents a variadic argument node
169  VarargNode,
170  // │ │ └── Dummy node for uninitialized values
171  DummyValNode,
172  // │ └── ObjVarKinds: Types of object variable nodes
173  // │ ├── Represents an object variable
174  ObjNode,
175  // │ ├── GepObjNode: Represents a GEP object variable
176  GepObjNode,
177  // │ ├── FIObjNode: Represents a flow-insensitive object node
178  FIObjNode,
179  // │ └── DummyObjNode: Dummy node for uninitialized objects
180  DummyObjNode,
181  // └────────
182 
183  // ┌── VFGNodeKinds: Various Value Flow Graph (VFG) node kinds with operations
184  // │ ├── Represents a comparison operation
185  Cmp,
186  // │ ├── Represents a binary operation
187  BinaryOp,
188  // │ ├── Represents a unary operation
189  UnaryOp,
190  // │ ├── Represents a branch operation
191  Branch,
192  // │ ├── Dummy node for value propagation
193  DummyVProp,
194  // │ └── Represents a null pointer operation
195  NPtr,
196  // │ └── ArgumentVFGNodeKinds: Types of argument nodes in VFG
197  // │ ├── Represents a function return value
198  FRet,
199  // │ ├── Represents an argument return value
200  ARet,
201  // │ ├── Represents an argument parameter
202  AParm,
203  // │ └── FParm: Represents a function parameter
204  FParm,
205  // │ └── StmtVFGNodeKinds: Types of statement nodes in VFG
206  // │ ├── Represents an address operation
207  Addr,
208  // │ ├── Represents a copy operation
209  Copy,
210  // │ ├── Represents a GEP operation
211  Gep,
212  // │ ├── Represents a store operation
213  Store,
214  // │ └── Represents a load operation
215  Load,
216  // │ └── PHIVFGNodeKinds: Types of PHI nodes in VFG
217  // │ ├── Represents a type-based PHI node
218  TPhi,
219  // │ ├── Represents an intra-procedural PHI node
220  TIntraPhi,
221  // │ └── Represents an inter-procedural PHI node
222  TInterPhi,
223  // │ └── MRSVFGNodeKinds: Memory-related SVFG nodes
224  // │ ├── Function parameter input
225  FPIN,
226  // │ ├── Function parameter output
227  FPOUT,
228  // │ ├── Argument parameter input
229  APIN,
230  // │ └── Argument parameter output
231  APOUT,
232  // │ └── MSSAPHISVFGNodeKinds: Mem SSA PHI nodes for SVFG
233  // │ ├── Memory PHI node
234  MPhi,
235  // │ ├── Intra-procedural memory PHI node
236  MIntraPhi,
237  // │ └── MInterPhi: Inter-procedural memory PHI node
238  MInterPhi,
239  // └────────
240 
241  // Additional specific graph node types
242  CallNodeKd, // Callgraph node
243  CDNodeKd, // Control dependence graph node
244  CFLNodeKd, // CFL graph node
245  CHNodeKd, // Class hierarchy graph node
246  ConstraintNodeKd, // Constraint graph node
247  TCTNodeKd, // Thread creation tree node
248  DCHNodeKd, // DCHG node
249  OtherKd // Other node kind
250  };

Constructor & Destructor Documentation

◆ SVFBaseNode()

SVF::SVFBaseNode::SVFBaseNode ( NodeID  i,
GNodeK  k,
SVFType ty = nullptr 
)
inline

Definition at line 254 of file GenericGraph.h.

254  : id(i),nodeKind(k), type(ty)
255  {
256 
257  }
NodeID id
Node ID.
Definition: GenericGraph.h:290
const SVFType * type
SVF type.
Definition: GenericGraph.h:292
GNodeK nodeKind
Node kind.
Definition: GenericGraph.h:291

Member Function Documentation

◆ getId()

NodeID SVF::SVFBaseNode::getId ( ) const
inline

Get ID.

Definition at line 260 of file GenericGraph.h.

261  {
262  return id;
263  }

◆ getNodeKind()

GNodeK SVF::SVFBaseNode::getNodeKind ( ) const
inline

Get node kind.

Definition at line 266 of file GenericGraph.h.

267  {
268  return nodeKind;
269  }

◆ getSourceLoc()

virtual const std::string SVF::SVFBaseNode::getSourceLoc ( ) const
inlinevirtual

Reimplemented in SVF::RetICFGNode, SVF::CallICFGNode, SVF::FunExitICFGNode, SVF::FunEntryICFGNode, and SVF::GlobalICFGNode.

Definition at line 281 of file GenericGraph.h.

282  {
283  return sourceLoc;
284  }
std::string sourceLoc
Source code information of this value.
Definition: GenericGraph.h:294

◆ getType()

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

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

Definition at line 271 of file GenericGraph.h.

272  {
273  return type;
274  }

◆ isArgumentVFGNodeKinds()

static bool SVF::SVFBaseNode::isArgumentVFGNodeKinds ( GNodeK  n)
inlinestaticprotected

Definition at line 347 of file GenericGraph.h.

348  {
349  static_assert(FParm - FRet == 3,
350  "The number of ArgumentVFGNodeKinds has changed, make "
351  "sure the range is correct");
352  return n <= FParm && n >= FRet;
353  }

◆ isICFGNodeKinds()

static bool SVF::SVFBaseNode::isICFGNodeKinds ( GNodeK  n)
inlinestaticprotected

Helper functions to check node kinds.

Definition at line 298 of file GenericGraph.h.

299  {
300  static_assert(FunRetBlock - IntraBlock == 5,
301  "the number of ICFGNodeKinds has changed, make sure "
302  "the range is correct");
303  return n <= FunRetBlock && n >= IntraBlock;
304  }

◆ isInterICFGNodeKind()

static bool SVF::SVFBaseNode::isInterICFGNodeKind ( GNodeK  n)
inlinestaticprotected

Definition at line 306 of file GenericGraph.h.

307  {
308  static_assert(FunRetBlock - FunEntryBlock == 3,
309  "the number of InterICFGNodeKind has changed, make sure "
310  "the range is correct");
311  return n <= FunRetBlock && n >= FunEntryBlock;
312  }

◆ isMRSVFGNodeKinds()

static bool SVF::SVFBaseNode::isMRSVFGNodeKinds ( GNodeK  n)
inlinestaticprotected

Definition at line 371 of file GenericGraph.h.

372  {
373  static_assert(MInterPhi - FPIN == 6,
374  "The number of MRSVFGNodeKinds has changed, make sure "
375  "the range is correct");
376  return n <= MInterPhi && n >= FPIN;
377  }

◆ isMSSAPHISVFGNodeKinds()

static bool SVF::SVFBaseNode::isMSSAPHISVFGNodeKinds ( GNodeK  n)
inlinestaticprotected

Definition at line 379 of file GenericGraph.h.

380  {
381  static_assert(MInterPhi - MPhi == 2,
382  "The number of MSSAPHISVFGNodeKinds has changed, make "
383  "sure the range is correct");
384  return n <= MInterPhi && n >= MPhi;
385  }

◆ isObjVarKinds()

static bool SVF::SVFBaseNode::isObjVarKinds ( GNodeK  n)
inlinestaticprotected

Definition at line 331 of file GenericGraph.h.

332  {
333  static_assert(DummyObjNode - ObjNode == 3,
334  "The number of ObjVarKinds has changed, make sure the "
335  "range is correct");
336  return n <= DummyObjNode && n >= ObjNode;
337  }

◆ isPHIVFGNodeKinds()

static bool SVF::SVFBaseNode::isPHIVFGNodeKinds ( GNodeK  n)
inlinestaticprotected

Definition at line 363 of file GenericGraph.h.

364  {
365  static_assert(TInterPhi - TPhi == 2,
366  "The number of PHIVFGNodeKinds has changed, make sure "
367  "the range is correct");
368  return n <= TInterPhi && n >= TPhi;
369  }

◆ isStmtVFGNodeKinds()

static bool SVF::SVFBaseNode::isStmtVFGNodeKinds ( GNodeK  n)
inlinestaticprotected

Definition at line 355 of file GenericGraph.h.

356  {
357  static_assert(Load - Addr == 4,
358  "The number of StmtVFGNodeKinds has changed, make sure "
359  "the range is correct");
360  return n <= Load && n >= Addr;
361  }

◆ isSVFVarKind()

static bool SVF::SVFBaseNode::isSVFVarKind ( GNodeK  n)
inlinestaticprotected

Definition at line 314 of file GenericGraph.h.

315  {
316  static_assert(DummyObjNode - ValNode == 8,
317  "The number of SVFVarKinds has changed, make sure the "
318  "range is correct");
319 
320  return n <= DummyObjNode && n >= ValNode;
321  }

◆ isValVarKinds()

static bool SVF::SVFBaseNode::isValVarKinds ( GNodeK  n)
inlinestaticprotected

Definition at line 323 of file GenericGraph.h.

324  {
325  static_assert(DummyValNode - ValNode == 4,
326  "The number of ValVarKinds has changed, make sure the "
327  "range is correct");
328  return n <= DummyValNode && n >= ValNode;
329  }

◆ isVFGNodeKinds()

static bool SVF::SVFBaseNode::isVFGNodeKinds ( GNodeK  n)
inlinestaticprotected

Definition at line 339 of file GenericGraph.h.

340  {
341  static_assert(MInterPhi - Cmp == 24,
342  "The number of VFGNodeKinds has changed, make sure the "
343  "range is correct");
344  return n <= MInterPhi && n >= Cmp;
345  }

◆ setSourceLoc()

virtual void SVF::SVFBaseNode::setSourceLoc ( const std::string sourceCodeInfo)
inlinevirtual

Definition at line 276 of file GenericGraph.h.

277  {
278  sourceLoc = sourceCodeInfo;
279  }

◆ valueOnlyToString()

const std::string SVF::SVFBaseNode::valueOnlyToString ( ) const

Definition at line 688 of file LLVMUtil.cpp.

689 {
690  std::string str;
691  llvm::raw_string_ostream rawstr(str);
692  if (const SVF::PTACallGraphNode* fun = SVFUtil::dyn_cast<PTACallGraphNode>(this))
693  {
694  rawstr << "Function: " << fun->getFunction()->getName() << " ";
695  }
696  else
697  {
698  auto llvmVal = LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(this);
699  if (llvmVal)
700  rawstr << " " << *llvmVal << " ";
701  else
702  rawstr << " No llvmVal found";
703  }
704  rawstr << getSourceLoc();
705  return rawstr.str();
706 }
const char *const string
Definition: cJSON.h:172
const Value * getLLVMValue(const SVFValue *value) const
Definition: LLVMModule.h:216
static LLVMModuleSet * getLLVMModuleSet()
Definition: LLVMModule.h:118
virtual const std::string getSourceLoc() const
Definition: GenericGraph.h:281

Member Data Documentation

◆ id

NodeID SVF::SVFBaseNode::id
protected

Node ID.

Definition at line 290 of file GenericGraph.h.

◆ nodeKind

GNodeK SVF::SVFBaseNode::nodeKind
protected

Node kind.

Definition at line 291 of file GenericGraph.h.

◆ sourceLoc

std::string SVF::SVFBaseNode::sourceLoc
protected

Source code information of this value.

Definition at line 294 of file GenericGraph.h.

◆ type

const SVFType* SVF::SVFBaseNode::type
protected

SVF type.

Definition at line 292 of file GenericGraph.h.


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