SVF
Functions
ExternalPAG.cpp File Reference
#include <iostream>
#include <fstream>
#include <sstream>
#include "Graphs/PAG.h"
#include "Graphs/ExternalPAG.h"
#include "Util/BasicTypes.h"
#include "Graphs/ICFG.h"

Go to the source code of this file.

Functions

llvm::cl::list< std::string > ExternalPAGArgs ("extpags", llvm::cl::desc("ExternalPAGs to use during PAG construction (format: func1@/path/to/graph,func2@/foo,..."), llvm::cl::CommaSeparated)
 
llvm::cl::list< std::string > DumpPAGFunctions ("dump-function-pags", llvm::cl::desc("Dump PAG for functions"), llvm::cl::CommaSeparated)
 
int getArgNo (const SVFFunction *function, const Value *arg)
 
static void outputPAGNodeNoNewLine (raw_ostream &o, PAGNode *pagNode)
 
static void outputPAGNode (raw_ostream &o, PAGNode *pagNode)
 
static void outputPAGNode (raw_ostream &o, PAGNode *pagNode, int argno)
 
static void outputPAGNode (raw_ostream &o, PAGNode *pagNode, std::string trail)
 
static void outputPAGEdge (raw_ostream &o, PAGEdge *pagEdge)
 

Function Documentation

◆ DumpPAGFunctions()

llvm::cl::list<std::string> DumpPAGFunctions ( "dump-function-pags"  ,
llvm::cl::desc("Dump PAG for functions")  ,
llvm::cl::CommaSeparated   
)

◆ ExternalPAGArgs()

llvm::cl::list<std::string> ExternalPAGArgs ( "extpags"  )

◆ getArgNo()

int getArgNo ( const SVFFunction function,
const Value arg 
)

Definition at line 155 of file ExternalPAG.cpp.

156 {
157  int argNo = 0;
158  for (auto it = function->getLLVMFun()->arg_begin(); it != function->getLLVMFun()->arg_end();
159  ++it, ++argNo)
160  {
161  if (arg->getName() == it->getName()) return argNo;
162  }
163 
164  return -1;
165 }
Function * getLLVMFun() const
Definition: BasicTypes.h:245

◆ outputPAGEdge()

static void outputPAGEdge ( raw_ostream o,
PAGEdge pagEdge 
)
static

Definition at line 196 of file ExternalPAG.cpp.

197 {
198  NodeID srcId = pagEdge->getSrcID();
199  NodeID dstId = pagEdge->getDstID();
200  u32_t offset = 0;
201  std::string edgeKind = "-";
202 
203  switch (pagEdge->getEdgeKind())
204  {
205  case PAGEdge::Addr:
206  edgeKind = "addr";
207  break;
208  case PAGEdge::Copy:
209  edgeKind = "copy";
210  break;
211  case PAGEdge::Store:
212  edgeKind = "store";
213  break;
214  case PAGEdge::Load:
215  edgeKind = "load";
216  break;
217  case PAGEdge::Call:
218  edgeKind = "call";
219  break;
220  case PAGEdge::Ret:
221  edgeKind = "ret";
222  break;
223  case PAGEdge::NormalGep:
224  edgeKind = "gep";
225  break;
226  case PAGEdge::VariantGep:
227  edgeKind = "variant-gep";
228  break;
229  case PAGEdge::Cmp:
230  edgeKind = "cmp";
231  break;
232  case PAGEdge::BinaryOp:
233  edgeKind = "binary-op";
234  break;
235  case PAGEdge::UnaryOp:
236  edgeKind = "unary-op";
237  break;
238  case PAGEdge::ThreadFork:
239  outs() << "dump-function-pags: found ThreadFork edge.\n";
240  break;
241  case PAGEdge::ThreadJoin:
242  outs() << "dump-function-pags: found ThreadJoin edge.\n";
243  break;
244  }
245 
246  if (NormalGepPE::classof(pagEdge)) offset =
247  static_cast<NormalGepPE *>(pagEdge)->getOffset();
248 
249  o << srcId << " " << edgeKind << " " << dstId << " " << offset << "\n";
250 }
GEdgeKind getEdgeKind() const
Definition: GenericGraph.h:81
NodeID getDstID() const
Definition: GenericGraph.h:77
u32_t NodeID
Definition: SVFBasicTypes.h:80
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:73
unsigned u32_t
Definition: SVFBasicTypes.h:75
raw_ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:47

◆ outputPAGNode() [1/3]

static void outputPAGNode ( raw_ostream o,
PAGNode pagNode 
)
static

Definition at line 175 of file ExternalPAG.cpp.

176 {
177  outputPAGNodeNoNewLine(o, pagNode);
178  o << "\n";
179 }
static void outputPAGNodeNoNewLine(raw_ostream &o, PAGNode *pagNode)

◆ outputPAGNode() [2/3]

static void outputPAGNode ( raw_ostream o,
PAGNode pagNode,
int  argno 
)
static

Definition at line 181 of file ExternalPAG.cpp.

182 {
183  outputPAGNodeNoNewLine(o, pagNode);
184  o << " " << argno;
185  o << "\n";
186 }
static void outputPAGNodeNoNewLine(raw_ostream &o, PAGNode *pagNode)

◆ outputPAGNode() [3/3]

static void outputPAGNode ( raw_ostream o,
PAGNode pagNode,
std::string  trail 
)
static

Definition at line 188 of file ExternalPAG.cpp.

190 {
191  outputPAGNodeNoNewLine(o, pagNode);
192  o << " " << trail;
193  o << "\n";
194 }
static void outputPAGNodeNoNewLine(raw_ostream &o, PAGNode *pagNode)

◆ outputPAGNodeNoNewLine()

static void outputPAGNodeNoNewLine ( raw_ostream o,
PAGNode pagNode 
)
static

Definition at line 167 of file ExternalPAG.cpp.

168 {
169  o << pagNode->getId() << " ";
170  // TODO: is this check enough?
171  if (!ObjPN::classof(pagNode)) o << "v";
172  else o << "o";
173 }
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164