SVF
Public Types | Public Member Functions | Protected Attributes | List of all members
SVF::PAGNode Class Referenceabstract

#include <PAGNode.h>

Inheritance diagram for SVF::PAGNode:
SVF::GenericNode< NodeTy, EdgeTy > SVF::ObjPN SVF::RetPN SVF::ValPN SVF::VarArgPN SVF::DummyObjPN SVF::FIObjPN SVF::GepObjPN SVF::DummyValPN SVF::GepValPN SVF::CloneDummyObjPN SVF::CloneFIObjPN SVF::CloneGepObjPN

Public Types

enum  PNODEK {
  ValNode, ObjNode, RetNode, VarargNode,
  GepValNode, GepObjNode, FIObjNode, DummyValNode,
  DummyObjNode, CloneGepObjNode, CloneFIObjNode, CloneDummyObjNode
}
 
- Public Types inherited from SVF::GenericNode< NodeTy, EdgeTy >
typedef NodeTy NodeType
 
typedef EdgeTy EdgeType
 
typedef s32_t GNodeK
 Edge kind. More...
 
typedef OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
 
typedef GEdgeSetTy::iterator iterator
 
typedef GEdgeSetTy::const_iterator const_iterator
 

Public Member Functions

 PAGNode (const Value *val, NodeID i, PNODEK k)
 address-taken pointer More...
 
virtual ~PAGNode ()
 Destructor. More...
 
const ValuegetValue () const
 Get/has methods of the components. More...
 
virtual const TypegetType () const
 Return type of the value. More...
 
bool hasValue () const
 
virtual bool isPointer () const
 Whether it is a pointer. More...
 
bool isTopLevelPtr () const
 Whether it is a top-level pointer. More...
 
bool isAddressTakenPtr () const
 Whether it is an address-taken pointer. More...
 
bool isConstantData () const
 
bool isIsolatedNode () const
 Whether this is an isoloated node on the PAG graph. More...
 
virtual const std::string getValueName () const =0
 Get name of the LLVM value. More...
 
virtual const FunctiongetFunction () const
 Return the function that this PAGNode resides in. Return nullptr if it is a global or constantexpr node. More...
 
PAGEdge::PAGEdgeSetTygetIncomingEdges (PAGEdge::PEDGEK kind)
 Get incoming PAG edges. More...
 
PAGEdge::PAGEdgeSetTygetOutgoingEdges (PAGEdge::PEDGEK kind)
 Get outgoing PAG edges. More...
 
bool hasIncomingEdges (PAGEdge::PEDGEK kind) const
 Has incoming PAG edges. More...
 
bool hasIncomingVariantGepEdge () const
 Has incoming VariantGepEdges. More...
 
PAGEdge::PAGEdgeSetTy::iterator getIncomingEdgesBegin (PAGEdge::PEDGEK kind) const
 Get incoming PAGEdge iterator. More...
 
PAGEdge::PAGEdgeSetTy::iterator getIncomingEdgesEnd (PAGEdge::PEDGEK kind) const
 Get incoming PAGEdge iterator. More...
 
bool hasOutgoingEdges (PAGEdge::PEDGEK kind) const
 Has outgoing PAG edges. More...
 
PAGEdge::PAGEdgeSetTy::iterator getOutgoingEdgesBegin (PAGEdge::PEDGEK kind) const
 Get outgoing PAGEdge iterator. More...
 
PAGEdge::PAGEdgeSetTy::iterator getOutgoingEdgesEnd (PAGEdge::PEDGEK kind) const
 Get outgoing PAGEdge iterator. More...
 
void addInEdge (PAGEdge *inEdge)
 add methods of the components More...
 
void addOutEdge (PAGEdge *outEdge)
 
virtual const std::string toString () const
 
virtual const std::string getNodeAttrForDotDisplay () const
 Get shape and/or color of node for .dot display. More...
 
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...
 
NodeID getId () const
 Get ID. More...
 
GNodeK getNodeKind () const
 Get node kind. More...
 
const GEdgeSetTygetOutEdges () const
 
const GEdgeSetTygetInEdges () const
 
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 necessory. 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)
 
Size_t removeIncomingEdge (EdgeType *edge)
 
Size_t removeOutgoingEdge (EdgeType *edge)
 
EdgeTypehasIncomingEdge (EdgeType *edge) const
 Find incoming and outgoing edges. More...
 
EdgeTypehasOutgoingEdge (EdgeType *edge) const
 

Protected Attributes

const Valuevalue
 value of this PAG node More...
 
PAGEdge::PAGKindToEdgeSetMapTy InEdgeKindToSetMap
 
PAGEdge::PAGKindToEdgeSetMapTy OutEdgeKindToSetMap
 
bool isTLPointer
 
bool isATPointer
 top-level pointer More...
 

Friends

raw_ostreamoperator<< (raw_ostream &o, const PAGNode &node)
 Overloading operator << for dumping PAGNode value. More...
 

Detailed Description

Definition at line 45 of file PAGNode.h.

Member Enumeration Documentation

◆ PNODEK

Nine kinds of PAG nodes ValNode: llvm pointer value ObjNode: memory object RetNode: unique return node Vararg: unique node for vararg parameter GepValNode: tempory gep value node for field sensitivity GepValNode: tempory gep obj node for field sensitivity FIObjNode: for field insensitive analysis DummyValNode and DummyObjNode: for non-llvm-value node Clone*Node: objects created by TBHC.

Enumerator
ValNode 
ObjNode 
RetNode 
VarargNode 
GepValNode 
GepObjNode 
FIObjNode 
DummyValNode 
DummyObjNode 
CloneGepObjNode 
CloneFIObjNode 
CloneDummyObjNode 

Definition at line 59 of file PAGNode.h.

Constructor & Destructor Documentation

◆ PAGNode()

PAGNode::PAGNode ( const Value val,
NodeID  i,
PNODEK  k 
)

address-taken pointer

Constructor

PAGNode constructor

Definition at line 1018 of file PAG.cpp.

1018  :
1019  GenericPAGNodeTy(i,k), value(val)
1020 {
1021 
1022  assert( ValNode <= k && k <= CloneDummyObjNode && "new PAG node kind?");
1023 
1024  switch (k)
1025  {
1026  case ValNode:
1027  case GepValNode:
1028  {
1029  assert(val != nullptr && "value is nullptr for ValPN or GepValNode");
1030  isTLPointer = val->getType()->isPointerTy();
1031  isATPointer = false;
1032  break;
1033  }
1034 
1035  case RetNode:
1036  {
1037  assert(val != nullptr && "value is nullptr for RetNode");
1038  isTLPointer = SVFUtil::cast<Function>(val)->getReturnType()->isPointerTy();
1039  isATPointer = false;
1040  break;
1041  }
1042 
1043  case VarargNode:
1044  case DummyValNode:
1045  {
1046  isTLPointer = true;
1047  isATPointer = false;
1048  break;
1049  }
1050 
1051  case ObjNode:
1052  case GepObjNode:
1053  case FIObjNode:
1054  case DummyObjNode:
1055  case CloneGepObjNode:
1056  case CloneFIObjNode:
1057  case CloneDummyObjNode:
1058  {
1059  isTLPointer = false;
1060  isATPointer = true;
1061  break;
1062  }
1063  }
1064 }
GenericNode< PAGNode, PAGEdge > GenericPAGNodeTy
Definition: PAGNode.h:44
bool isTLPointer
Definition: PAGNode.h:80
#define assert(ex)
Definition: util.h:141
const Value * value
value of this PAG node
Definition: PAGNode.h:77
bool isATPointer
top-level pointer
Definition: PAGNode.h:81

◆ ~PAGNode()

virtual SVF::PAGNode::~PAGNode ( )
inlinevirtual

Destructor.

Definition at line 87 of file PAGNode.h.

88  {
89  }

Member Function Documentation

◆ addInEdge()

void SVF::PAGNode::addInEdge ( PAGEdge inEdge)
inline

add methods of the components

Definition at line 237 of file PAGNode.h.

238  {
239  GNodeK kind = inEdge->getEdgeKind();
240  InEdgeKindToSetMap[kind].insert(inEdge);
241  addIncomingEdge(inEdge);
242  }
s32_t GNodeK
Edge kind.
Definition: GenericGraph.h:135
PAGEdge::PAGKindToEdgeSetMapTy InEdgeKindToSetMap
Definition: PAGNode.h:78
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
Definition: GenericGraph.h:274

◆ addOutEdge()

void SVF::PAGNode::addOutEdge ( PAGEdge outEdge)
inline

Definition at line 244 of file PAGNode.h.

245  {
246  GNodeK kind = outEdge->getEdgeKind();
247  OutEdgeKindToSetMap[kind].insert(outEdge);
248  addOutgoingEdge(outEdge);
249  }
s32_t GNodeK
Edge kind.
Definition: GenericGraph.h:135
bool addOutgoingEdge(EdgeType *outEdge)
Definition: GenericGraph.h:278
PAGEdge::PAGKindToEdgeSetMapTy OutEdgeKindToSetMap
Definition: PAGNode.h:79

◆ dump()

void PAGNode::dump ( ) const

Dump to console for debugging.

Definition at line 92 of file PAG.cpp.

92  {
93  outs() << this->toString() << "\n";
94 }
virtual const std::string toString() const
Definition: PAG.cpp:46
raw_ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:47

◆ getFunction()

virtual const Function* SVF::PAGNode::getFunction ( ) const
inlinevirtual

Return the function that this PAGNode resides in. Return nullptr if it is a global or constantexpr node.

Definition at line 145 of file PAGNode.h.

146  {
147  if(value)
148  {
149  if(const Instruction* inst = SVFUtil::dyn_cast<Instruction>(value))
150  return inst->getParent()->getParent();
151  else if (const Argument* arg = SVFUtil::dyn_cast<Argument>(value))
152  return arg->getParent();
153  else if (const Function* fun = SVFUtil::dyn_cast<Function>(value))
154  return fun;
155  }
156  return nullptr;
157  }
const Value * value
value of this PAG node
Definition: PAGNode.h:77
llvm::Function Function
Definition: BasicTypes.h:76
llvm::Instruction Instruction
Definition: BasicTypes.h:79
llvm::Argument Argument
LLVM Aliases and constants.
Definition: BasicTypes.h:122

◆ getIncomingEdges()

PAGEdge::PAGEdgeSetTy& SVF::PAGNode::getIncomingEdges ( PAGEdge::PEDGEK  kind)
inline

Get incoming PAG edges.

Definition at line 160 of file PAGNode.h.

161  {
162  return InEdgeKindToSetMap[kind];
163  }
PAGEdge::PAGKindToEdgeSetMapTy InEdgeKindToSetMap
Definition: PAGNode.h:78

◆ getIncomingEdgesBegin()

PAGEdge::PAGEdgeSetTy::iterator SVF::PAGNode::getIncomingEdgesBegin ( PAGEdge::PEDGEK  kind) const
inline

Get incoming PAGEdge iterator.

Definition at line 193 of file PAGNode.h.

194  {
195  PAGEdge::PAGKindToEdgeSetMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
196  assert(it!=InEdgeKindToSetMap.end() && "The node does not have such kind of edge");
197  return it->second.begin();
198  }
#define assert(ex)
Definition: util.h:141
PAGEdge::PAGKindToEdgeSetMapTy InEdgeKindToSetMap
Definition: PAGNode.h:78

◆ getIncomingEdgesEnd()

PAGEdge::PAGEdgeSetTy::iterator SVF::PAGNode::getIncomingEdgesEnd ( PAGEdge::PEDGEK  kind) const
inline

Get incoming PAGEdge iterator.

Definition at line 201 of file PAGNode.h.

202  {
203  PAGEdge::PAGKindToEdgeSetMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
204  assert(it!=InEdgeKindToSetMap.end() && "The node does not have such kind of edge");
205  return it->second.end();
206  }
#define assert(ex)
Definition: util.h:141
PAGEdge::PAGKindToEdgeSetMapTy InEdgeKindToSetMap
Definition: PAGNode.h:78

◆ getNodeAttrForDotDisplay()

const std::string PAGNode::getNodeAttrForDotDisplay ( ) const
virtual

Get shape and/or color of node for .dot display.

Definition at line 54 of file PAG.cpp.

54  {
55  // TODO: Maybe use over-rides instead of these ifs,
56  // But this puts them conveniently together.
57  if (SVFUtil::isa<ValPN>(this))
58  {
59  if(SVFUtil::isa<GepValPN>(this))
60  return "shape=hexagon";
61  else if (SVFUtil::isa<DummyValPN>(this))
62  return "shape=diamond";
63  else
64  return "shape=box";
65  }
66  else if (SVFUtil::isa<ObjPN>(this))
67  {
68  if(SVFUtil::isa<GepObjPN>(this))
69  return "shape=doubleoctagon";
70  else if(SVFUtil::isa<FIObjPN>(this))
71  return "shape=box3d";
72  else if (SVFUtil::isa<DummyObjPN>(this))
73  return "shape=tab";
74  else
75  return "shape=component";
76  }
77  else if (SVFUtil::isa<RetPN>(this))
78  {
79  return "shape=Mrecord";
80  }
81  else if (SVFUtil::isa<VarArgPN>(this))
82  {
83  return "shape=octagon";
84  }
85  else
86  {
87  assert(0 && "no such kind!!");
88  }
89  return "";
90 }
#define assert(ex)
Definition: util.h:141

◆ getOutgoingEdges()

PAGEdge::PAGEdgeSetTy& SVF::PAGNode::getOutgoingEdges ( PAGEdge::PEDGEK  kind)
inline

Get outgoing PAG edges.

Definition at line 166 of file PAGNode.h.

167  {
168  return OutEdgeKindToSetMap[kind];
169  }
PAGEdge::PAGKindToEdgeSetMapTy OutEdgeKindToSetMap
Definition: PAGNode.h:79

◆ getOutgoingEdgesBegin()

PAGEdge::PAGEdgeSetTy::iterator SVF::PAGNode::getOutgoingEdgesBegin ( PAGEdge::PEDGEK  kind) const
inline

Get outgoing PAGEdge iterator.

Definition at line 219 of file PAGNode.h.

220  {
221  PAGEdge::PAGKindToEdgeSetMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
222  assert(it!=OutEdgeKindToSetMap.end() && "The node does not have such kind of edge");
223  return it->second.begin();
224  }
#define assert(ex)
Definition: util.h:141
PAGEdge::PAGKindToEdgeSetMapTy OutEdgeKindToSetMap
Definition: PAGNode.h:79

◆ getOutgoingEdgesEnd()

PAGEdge::PAGEdgeSetTy::iterator SVF::PAGNode::getOutgoingEdgesEnd ( PAGEdge::PEDGEK  kind) const
inline

Get outgoing PAGEdge iterator.

Definition at line 227 of file PAGNode.h.

228  {
229  PAGEdge::PAGKindToEdgeSetMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
230  assert(it!=OutEdgeKindToSetMap.end() && "The node does not have such kind of edge");
231  return it->second.end();
232  }
#define assert(ex)
Definition: util.h:141
PAGEdge::PAGKindToEdgeSetMapTy OutEdgeKindToSetMap
Definition: PAGNode.h:79

◆ getType()

virtual const Type* SVF::PAGNode::getType ( ) const
inlinevirtual

Return type of the value.

Reimplemented in SVF::GepObjPN, SVF::GepValPN, and SVF::ObjPN.

Definition at line 102 of file PAGNode.h.

103  {
104  if (value)
105  return value->getType();
106  return nullptr;
107  }
const Value * value
value of this PAG node
Definition: PAGNode.h:77

◆ getValue()

const Value* SVF::PAGNode::getValue ( ) const
inline

Get/has methods of the components.

Definition at line 93 of file PAGNode.h.

94  {
95  assert((this->getNodeKind() != DummyValNode && this->getNodeKind() != DummyObjNode) && "dummy node do not have value!");
96  assert((this->getId()!=SYMTYPE::BlackHole && this->getId() != SYMTYPE::ConstantObj) && "blackhole and constant obj do not have value");
97  assert(value && "value is null (GepObjNode whose basenode is a DummyObj?)");
98  return value;
99  }
#define assert(ex)
Definition: util.h:141
GNodeK getNodeKind() const
Get node kind.
Definition: GenericGraph.h:170
const Value * value
value of this PAG node
Definition: PAGNode.h:77
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164

◆ getValueName()

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

◆ hasIncomingEdges()

bool SVF::PAGNode::hasIncomingEdges ( PAGEdge::PEDGEK  kind) const
inline

Has incoming PAG edges.

Definition at line 172 of file PAGNode.h.

173  {
174  PAGEdge::PAGKindToEdgeSetMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
175  if (it != InEdgeKindToSetMap.end())
176  return (!it->second.empty());
177  else
178  return false;
179  }
PAGEdge::PAGKindToEdgeSetMapTy InEdgeKindToSetMap
Definition: PAGNode.h:78

◆ hasIncomingVariantGepEdge()

bool SVF::PAGNode::hasIncomingVariantGepEdge ( ) const
inline

Has incoming VariantGepEdges.

Definition at line 182 of file PAGNode.h.

183  {
184  PAGEdge::PAGKindToEdgeSetMapTy::const_iterator it = InEdgeKindToSetMap.find(PAGEdge::VariantGep);
185  if (it != InEdgeKindToSetMap.end())
186  {
187  return (!it->second.empty());
188  }
189  return false;
190  }
PAGEdge::PAGKindToEdgeSetMapTy InEdgeKindToSetMap
Definition: PAGNode.h:78

◆ hasOutgoingEdges()

bool SVF::PAGNode::hasOutgoingEdges ( PAGEdge::PEDGEK  kind) const
inline

Has outgoing PAG edges.

Definition at line 209 of file PAGNode.h.

210  {
211  PAGEdge::PAGKindToEdgeSetMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
212  if (it != OutEdgeKindToSetMap.end())
213  return (!it->second.empty());
214  else
215  return false;
216  }
PAGEdge::PAGKindToEdgeSetMapTy OutEdgeKindToSetMap
Definition: PAGNode.h:79

◆ hasValue()

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

Definition at line 109 of file PAGNode.h.

110  {
111  return value!=nullptr;
112  }
const Value * value
value of this PAG node
Definition: PAGNode.h:77

◆ isAddressTakenPtr()

bool SVF::PAGNode::isAddressTakenPtr ( ) const
inline

Whether it is an address-taken pointer.

Definition at line 124 of file PAGNode.h.

125  {
126  return isATPointer;
127  }
bool isATPointer
top-level pointer
Definition: PAGNode.h:81

◆ isConstantData()

bool SVF::PAGNode::isConstantData ( ) const
inline

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

Definition at line 130 of file PAGNode.h.

131  {
132  if (hasValue())
134  else
135  return false;
136  }
const Value * value
value of this PAG node
Definition: PAGNode.h:77
bool hasValue() const
Definition: PAGNode.h:109
bool isConstantData(const Value *val)
Return true if the value refers to constant data, e.g., i32 0.
Definition: LLVMUtil.h:393

◆ isIsolatedNode()

bool PAGNode::isIsolatedNode ( ) const

Whether this is an isoloated node on the PAG graph.

Definition at line 1066 of file PAG.cpp.

1066  {
1067  if (getInEdges().empty() && getOutEdges().empty())
1068  return true;
1069  else if (isConstantData())
1070  return true;
1071  else if (value && SVFUtil::isa<Function>(value))
1072  return SVFUtil::isIntrinsicFun(SVFUtil::cast<Function>(value));
1073  else
1074  return false;
1075 }
const GEdgeSetTy & getInEdges() const
Definition: GenericGraph.h:181
const Value * value
value of this PAG node
Definition: PAGNode.h:77
bool isIntrinsicFun(const Function *func)
Definition: SVFUtil.h:131
bool isConstantData() const
Definition: PAGNode.h:130
const GEdgeSetTy & getOutEdges() const
Definition: GenericGraph.h:177
static DdNode * empty
Definition: cuddZddLin.c:94

◆ isPointer()

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

Whether it is a pointer.

Definition at line 114 of file PAGNode.h.

115  {
116  return isTopLevelPtr() || isAddressTakenPtr();
117  }
bool isTopLevelPtr() const
Whether it is a top-level pointer.
Definition: PAGNode.h:119
bool isAddressTakenPtr() const
Whether it is an address-taken pointer.
Definition: PAGNode.h:124

◆ isTopLevelPtr()

bool SVF::PAGNode::isTopLevelPtr ( ) const
inline

Whether it is a top-level pointer.

Definition at line 119 of file PAGNode.h.

120  {
121  return isTLPointer;
122  }
bool isTLPointer
Definition: PAGNode.h:80

◆ toString()

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

Reimplemented in SVF::CloneFIObjPN, SVF::CloneGepObjPN, SVF::CloneDummyObjPN, SVF::DummyObjPN, SVF::DummyValPN, SVF::VarArgPN, SVF::RetPN, SVF::FIObjPN, SVF::GepObjPN, SVF::GepValPN, SVF::ObjPN, and SVF::ValPN.

Definition at line 46 of file PAG.cpp.

46  {
47  std::string str;
48  raw_string_ostream rawstr(str);
49  rawstr << "PAGNode ID: " << getId();
50  return rawstr.str();
51 }
llvm::raw_string_ostream raw_string_ostream
Definition: BasicTypes.h:100
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164

Friends And Related Function Documentation

◆ operator<<

raw_ostream& operator<< ( raw_ostream o,
const PAGNode node 
)
friend

Overloading operator << for dumping PAGNode value.

Definition at line 262 of file PAGNode.h.

263  {
264  o << node.toString();
265  return o;
266  }

Member Data Documentation

◆ InEdgeKindToSetMap

PAGEdge::PAGKindToEdgeSetMapTy SVF::PAGNode::InEdgeKindToSetMap
protected

Definition at line 78 of file PAGNode.h.

◆ isATPointer

bool SVF::PAGNode::isATPointer
protected

top-level pointer

Definition at line 81 of file PAGNode.h.

◆ isTLPointer

bool SVF::PAGNode::isTLPointer
protected

Definition at line 80 of file PAGNode.h.

◆ OutEdgeKindToSetMap

PAGEdge::PAGKindToEdgeSetMapTy SVF::PAGNode::OutEdgeKindToSetMap
protected

Definition at line 79 of file PAGNode.h.

◆ value

const Value* SVF::PAGNode::value
protected

value of this PAG node

Definition at line 77 of file PAGNode.h.


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