Static Value-Flow Analysis
Public Types | Public Member Functions | Static Public Attributes | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
SVF::PointerAnalysis Class Referenceabstract

#include <PointerAnalysis.h>

Inheritance diagram for SVF::PointerAnalysis:
SVF::CondPTAImpl< ContextCond > SVF::BVDataPTAImpl SVF::CondPTAImpl< Cond > SVF::ContextDDA SVF::AndersenBase SVF::CFLBase SVF::FlowDDA SVF::FlowSensitive SVF::Andersen SVF::Steensgaard SVF::TypeAnalysis SVF::CFLAlias SVF::CFLVF SVF::VersionedFlowSensitive SVF::AndersenSCD SVF::AndersenWaveDiff SVF::POCRAlias SVF::POCRHybrid SVF::AndersenSFR

Public Types

enum  PTATY {
  Andersen_BASE , Andersen_WPA , AndersenSCD_WPA , AndersenSFR_WPA ,
  AndersenWaveDiff_WPA , Steensgaard_WPA , CSCallString_WPA , CSSummary_WPA ,
  FSDATAFLOW_WPA , FSSPARSE_WPA , VFS_WPA , FSCS_WPA ,
  CFLFICI_WPA , CFLFSCI_WPA , CFLFSCS_WPA , TypeCPP_WPA ,
  FieldS_DDA , FlowS_DDA , PathS_DDA , Cxt_DDA ,
  Default_PTA
}
 Pointer analysis type list. More...
 
enum  PTAImplTy { BaseImpl , BVDataImpl , CondImpl }
 Implementation type: BVDataPTAImpl or CondPTAImpl. More...
 
typedef Set< const CallICFGNode * > CallSiteSet
 Indirect call edges type, map a callsite to a set of callees. More...
 
typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
 
typedef Set< const SVFFunction * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSetCallEdgeMap
 
typedef SCCDetection< PTACallGraph * > CallGraphSCC
 
typedef Set< const SVFGlobalValue * > VTableSet
 
typedef Set< const SVFFunction * > VFunSet
 

Public Member Functions

ICFGgetICFG () const
 Get ICFG. More...
 
u32_t getNumOfResolvedIndCallEdge () const
 Return number of resolved indirect call edges. More...
 
PTACallGraphgetCallGraph () const
 Return call graph. More...
 
CallGraphSCCgetCallGraphSCC () const
 Return call graph SCC. More...
 
 PointerAnalysis (SVFIR *pag, PTATY ty=Default_PTA, bool alias_check=true)
 Constructor. More...
 
PTATY getAnalysisTy () const
 Type of pointer analysis. More...
 
PTAImplTy getImplTy () const
 Return implementation type of the pointer analysis. More...
 
bool printStat ()
 Whether print statistics. More...
 
void disablePrintStat ()
 Whether print statistics. More...
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite. More...
 
bool hasIndCSCallees (const CallICFGNode *cs) const
 
const FunctionSetgetIndCSCallees (const CallICFGNode *cs) const
 
virtual void resolveIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve indirect call edges. More...
 
void callGraphSCCDetection ()
 PTACallGraph SCC related methods. More...
 
NodeID getCallGraphSCCRepNode (NodeID id) const
 Get SCC rep node of a SVFG node. More...
 
bool inSameCallGraphSCC (const SVFFunction *fun1, const SVFFunction *fun2)
 Return TRUE if this edge is inside a PTACallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG. More...
 
bool isInRecursion (const SVFFunction *fun) const
 
bool isLocalVarInRecursiveFun (NodeID id) const
 Whether a local variable is in function recursions. More...
 
virtual const std::string PTAName () const
 Return PTA name. More...
 
CommonCHGraphgetCHGraph () const
 get CHGraph More...
 
void getVFnsFromCHA (const CallICFGNode *cs, VFunSet &vfns)
 
void getVFnsFromPts (const CallICFGNode *cs, const PointsTo &target, VFunSet &vfns)
 
void connectVCallToVFns (const CallICFGNode *cs, const VFunSet &vfns, CallEdgeMap &newEdges)
 
virtual void resolveCPPIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve cpp indirect call edges. More...
 

Static Public Attributes

static const std::string aliasTestMayAlias = "MAYALIAS"
 
static const std::string aliasTestMayAliasMangled = "_Z8MAYALIASPvS_"
 
static const std::string aliasTestNoAlias = "NOALIAS"
 
static const std::string aliasTestNoAliasMangled = "_Z7NOALIASPvS_"
 
static const std::string aliasTestPartialAlias = "PARTIALALIAS"
 
static const std::string aliasTestPartialAliasMangled = "_Z12PARTIALALIASPvS_"
 
static const std::string aliasTestMustAlias = "MUSTALIAS"
 
static const std::string aliasTestMustAliasMangled = "_Z9MUSTALIASPvS_"
 
static const std::string aliasTestFailMayAlias = "EXPECTEDFAIL_MAYALIAS"
 
static const std::string aliasTestFailMayAliasMangled = "_Z21EXPECTEDFAIL_MAYALIASPvS_"
 
static const std::string aliasTestFailNoAlias = "EXPECTEDFAIL_NOALIAS"
 
static const std::string aliasTestFailNoAliasMangled = "_Z20EXPECTEDFAIL_NOALIASPvS_"
 

Protected Attributes

bool print_stat
 User input flags. More...
 
bool alias_validation
 Flag for validating points-to/alias results. More...
 
u32_t OnTheFlyIterBudgetForStat
 Flag for iteration budget for on-the-fly statistics. More...
 
SVFModulesvfMod
 Module. More...
 
PTATY ptaTy
 Pointer analysis Type. More...
 
PTAImplTy ptaImplTy
 PTA implementation type. More...
 
PTAStatstat
 Statistics. More...
 
PTACallGraphcallgraph
 Call graph used for pointer analysis. More...
 
CallGraphSCCcallGraphSCC
 SCC for PTACallGraph. More...
 
ICFGicfg
 Interprocedural control-flow graph. More...
 
CommonCHGraphchgraph
 CHGraph. More...
 

Static Protected Attributes

static SVFIRpag = nullptr
 SVFIR. More...
 

Private Member Functions

void destroy ()
 Release the memory. More...
 
SVFIRgetPAG () const
 
PTAStatgetStat () const
 Get PTA stat. More...
 
SVFModulegetModule () const
 Module. More...
 
OrderedNodeSetgetAllValidPtrs ()
 Get all Valid Pointers for resolution. More...
 
virtual ~PointerAnalysis ()
 Destructor. More...
 
virtual void initialize ()
 Initialization of a pointer analysis, including building symbol table and SVFIR etc. More...
 
virtual void finalize ()
 Finalization of a pointer analysis, including checking alias correctness. More...
 
virtual void analyze ()=0
 Start Analysis here (main part of pointer analysis). It needs to be implemented in child class. More...
 
virtual void computeDDAPts (NodeID)
 Compute points-to results on-demand, overridden by derived classes. More...
 
virtual AliasResult alias (const SVFValue *V1, const SVFValue *V2)=0
 Interface exposed to users of our pointer analysis, given Value infos. More...
 
virtual AliasResult alias (NodeID node1, NodeID node2)=0
 Interface exposed to users of our pointer analysis, given PAGNodeID. More...
 
virtual const PointsTogetPts (NodeID ptr)=0
 Get points-to targets of a pointer. It needs to be implemented in child class. More...
 
virtual const NodeSetgetRevPts (NodeID nodeId)=0
 
void printIndCSTargets (const CallICFGNode *cs, const FunctionSet &targets)
 Print targets of a function pointer. More...
 
virtual void dumpTopLevelPtsTo ()
 
virtual void dumpAllPts ()
 
virtual void dumpCPts ()
 
virtual void dumpPts (NodeID ptr, const PointsTo &pts)
 
void printIndCSTargets ()
 
void dumpAllTypes ()
 
void dumpStat ()
 Dump the statistics. More...
 
bool containBlackHoleNode (const PointsTo &pts)
 Determine whether a points-to contains a black hole or constant node. More...
 
bool containConstantNode (const PointsTo &pts)
 
virtual bool isBlkObjOrConstantObj (NodeID ptd) const
 
bool isHeapMemObj (NodeID id) const
 Whether this object is heap or array. More...
 
bool isArrayMemObj (NodeID id) const
 
bool isFIObjNode (NodeID id) const
 
NodeID getBaseObjVar (NodeID id)
 
NodeID getFIObjVar (NodeID id)
 
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 
virtual const NodeBSgetAllFieldsObjVars (NodeID id)
 
void setObjFieldInsensitive (NodeID id)
 
bool isFieldInsensitive (NodeID id) const
 
const CallSiteToFunPtrMapgetIndirectCallsites () const
 Return all indirect callsites. More...
 
NodeID getFunPtr (const CallICFGNode *cs) const
 Return function pointer PAGNode at a callsite cs. More...
 
virtual void validateTests ()
 Alias check functions to verify correctness of pointer analysis. More...
 
virtual void validateSuccessTests (std::string fun)
 
virtual void validateExpectedFailureTests (std::string fun)
 
void resetObjFieldSensitive ()
 Reset all object node as field-sensitive. More...
 

Detailed Description

Definition at line 57 of file PointerAnalysis.h.

Member Typedef Documentation

◆ CallEdgeMap

Definition at line 105 of file PointerAnalysis.h.

◆ CallGraphSCC

Definition at line 106 of file PointerAnalysis.h.

◆ CallSiteSet

Indirect call edges type, map a callsite to a set of callees.

Definition at line 102 of file PointerAnalysis.h.

◆ CallSiteToFunPtrMap

Definition at line 103 of file PointerAnalysis.h.

◆ FunctionSet

Definition at line 104 of file PointerAnalysis.h.

◆ VFunSet

Definition at line 108 of file PointerAnalysis.h.

◆ VTableSet

Definition at line 107 of file PointerAnalysis.h.

Member Enumeration Documentation

◆ PTAImplTy

Implementation type: BVDataPTAImpl or CondPTAImpl.

Enumerator
BaseImpl 

Represents PointerAnalaysis.

BVDataImpl 

Represents BVDataPTAImpl.

CondImpl 

Represents CondPTAImpl.

Definition at line 93 of file PointerAnalysis.h.

94  {
95  BaseImpl,
96  BVDataImpl,
97  CondImpl,
98  };
@ BaseImpl
Represents PointerAnalaysis.
@ BVDataImpl
Represents BVDataPTAImpl.
@ CondImpl
Represents CondPTAImpl.

◆ PTATY

Pointer analysis type list.

Enumerator
Andersen_BASE 

Base Andersen PTA.

Andersen_WPA 

Andersen PTA.

AndersenSCD_WPA 

Selective cycle detection andersen-style WPA.

AndersenSFR_WPA 

Stride-based field representation.

AndersenWaveDiff_WPA 

Diff wave propagation andersen-style WPA.

Steensgaard_WPA 

Steensgaard PTA.

CSCallString_WPA 

Call string based context sensitive WPA.

CSSummary_WPA 

Summary based context sensitive WPA.

FSDATAFLOW_WPA 

Traditional Dataflow-based flow sensitive WPA.

FSSPARSE_WPA 

Sparse flow sensitive WPA.

VFS_WPA 

Versioned sparse flow-sensitive WPA.

FSCS_WPA 

Flow-, context- sensitive WPA.

CFLFICI_WPA 

Flow-, context-, insensitive CFL-reachability-based analysis.

CFLFSCI_WPA 

Flow-insensitive, context-sensitive CFL-reachability-based analysis.

CFLFSCS_WPA 

Flow-, context-, CFL-reachability-based analysis.

TypeCPP_WPA 

Type-based analysis for C++.

FieldS_DDA 

Field sensitive DDA.

FlowS_DDA 

Flow sensitive DDA.

PathS_DDA 

Guarded value-flow DDA.

Cxt_DDA 

context sensitive DDA

Default_PTA 

default pta without any analysis

Definition at line 62 of file PointerAnalysis.h.

63  {
64  // Whole program analysis
66  Andersen_WPA,
74  FSSPARSE_WPA,
75  VFS_WPA,
76  FSCS_WPA,
77  CFLFICI_WPA,
78  CFLFSCI_WPA,
79  CFLFSCS_WPA,
80  TypeCPP_WPA,
81 
82  // Demand driven analysis
83  FieldS_DDA,
84  FlowS_DDA,
85  PathS_DDA,
86  Cxt_DDA,
87 
88 
90  };
@ Cxt_DDA
context sensitive DDA
@ CFLFICI_WPA
Flow-, context-, insensitive CFL-reachability-based analysis.
@ VFS_WPA
Versioned sparse flow-sensitive WPA.
@ FSCS_WPA
Flow-, context- sensitive WPA.
@ FSDATAFLOW_WPA
Traditional Dataflow-based flow sensitive WPA.
@ AndersenSCD_WPA
Selective cycle detection andersen-style WPA.
@ Andersen_BASE
Base Andersen PTA.
@ FlowS_DDA
Flow sensitive DDA.
@ Andersen_WPA
Andersen PTA.
@ CFLFSCS_WPA
Flow-, context-, CFL-reachability-based analysis.
@ FieldS_DDA
Field sensitive DDA.
@ AndersenWaveDiff_WPA
Diff wave propagation andersen-style WPA.
@ CSCallString_WPA
Call string based context sensitive WPA.
@ PathS_DDA
Guarded value-flow DDA.
@ TypeCPP_WPA
Type-based analysis for C++.
@ AndersenSFR_WPA
Stride-based field representation.
@ Steensgaard_WPA
Steensgaard PTA.
@ FSSPARSE_WPA
Sparse flow sensitive WPA.
@ Default_PTA
default pta without any analysis
@ CSSummary_WPA
Summary based context sensitive WPA.
@ CFLFSCI_WPA
Flow-insensitive, context-sensitive CFL-reachability-based analysis.

Constructor & Destructor Documentation

◆ PointerAnalysis()

PointerAnalysis::PointerAnalysis ( SVFIR p,
PTATY  ty = Default_PTA,
bool  alias_check = true 
)

Constructor.

Constructor

Definition at line 68 of file PointerAnalysis.cpp.

68  :
69  svfMod(nullptr),ptaTy(ty),stat(nullptr),callgraph(nullptr),callGraphSCC(nullptr),icfg(nullptr),chgraph(nullptr)
70 {
71  pag = p;
75  alias_validation = (alias_check && Options::EnableAliasCheck());
76 }
cJSON * p
Definition: cJSON.cpp:2559
static const Option< bool > EnableAliasCheck
Definition: Options.h:130
static const Option< bool > PStat
Definition: Options.h:119
static const Option< u32_t > StatBudget
Definition: Options.h:120
CommonCHGraph * chgraph
CHGraph.
bool print_stat
User input flags.
PTAImplTy ptaImplTy
PTA implementation type.
PTAStat * stat
Statistics.
SVFModule * svfMod
Module.
ICFG * icfg
Interprocedural control-flow graph.
bool alias_validation
Flag for validating points-to/alias results.
PTACallGraph * callgraph
Call graph used for pointer analysis.
static SVFIR * pag
SVFIR.
PTATY ptaTy
Pointer analysis Type.
CallGraphSCC * callGraphSCC
SCC for PTACallGraph.
u32_t OnTheFlyIterBudgetForStat
Flag for iteration budget for on-the-fly statistics.

◆ ~PointerAnalysis()

PointerAnalysis::~PointerAnalysis ( )
virtual

Destructor.

Destructor

Definition at line 81 of file PointerAnalysis.cpp.

82 {
83  destroy();
84  // do not delete the SVFIR for now
85  //delete pag;
86 }
void destroy()
Release the memory.

Member Function Documentation

◆ alias() [1/2]

virtual AliasResult SVF::PointerAnalysis::alias ( const SVFValue V1,
const SVFValue V2 
)
pure virtual

Interface exposed to users of our pointer analysis, given Value infos.

Implemented in SVF::BVDataPTAImpl, SVF::CondPTAImpl< Cond >, SVF::CondPTAImpl< ContextCond >, and SVF::CFLAlias.

◆ alias() [2/2]

virtual AliasResult SVF::PointerAnalysis::alias ( NodeID  node1,
NodeID  node2 
)
pure virtual

Interface exposed to users of our pointer analysis, given PAGNodeID.

Implemented in SVF::BVDataPTAImpl, SVF::CondPTAImpl< Cond >, SVF::CondPTAImpl< ContextCond >, and SVF::CFLAlias.

◆ analyze()

virtual void SVF::PointerAnalysis::analyze ( )
pure virtual

Start Analysis here (main part of pointer analysis). It needs to be implemented in child class.

Implemented in SVF::TypeAnalysis, SVF::FlowSensitive, SVF::AndersenBase, SVF::FlowDDA, SVF::ContextDDA, and SVF::CFLBase.

◆ callGraphSCCDetection()

void SVF::PointerAnalysis::callGraphSCCDetection ( )
inline

PTACallGraph SCC related methods.

PTACallGraph SCC detection

Definition at line 388 of file PointerAnalysis.h.

389  {
390  if(callGraphSCC==nullptr)
392 
393  callGraphSCC->find();
394  }
SCCDetection< PTACallGraph * > CallGraphSCC
void find(void)
Definition: SCC.h:308

◆ computeDDAPts()

virtual void SVF::PointerAnalysis::computeDDAPts ( NodeID  )
inlinevirtual

Compute points-to results on-demand, overridden by derived classes.

Reimplemented in SVF::FlowDDA, and SVF::ContextDDA.

Definition at line 233 of file PointerAnalysis.h.

233 {}

◆ connectVCallToVFns()

void PointerAnalysis::connectVCallToVFns ( const CallICFGNode cs,
const VFunSet vfns,
CallEdgeMap newEdges 
)

Definition at line 462 of file PointerAnalysis.cpp.

463 {
465  for (VFunSet::const_iterator fit = vfns.begin(),
466  feit = vfns.end(); fit != feit; ++fit)
467  {
468  const SVFFunction* callee = *fit;
469  callee = callee->getDefFunForMultipleModule();
470  if (getIndCallMap()[cs].count(callee) > 0)
471  continue;
472  if(cs->arg_size() == callee->arg_size() ||
473  (cs->isVarArg() && callee->isVarArg()))
474  {
475  newEdges[cs].insert(callee);
476  getIndCallMap()[cs].insert(callee);
477  const CallICFGNode* callBlockNode = cs;
478  callgraph->addIndirectCallGraphEdge(callBlockNode, cs->getCaller(),callee);
479  }
480  }
481 }
int count
Definition: cJSON.h:216
const SVFFunction * getCaller() const
Return callsite.
Definition: ICFGNode.h:470
bool isVarArg() const
Definition: ICFGNode.h:523
u32_t arg_size() const
Definition: ICFGNode.h:505
void addIndirectCallGraphEdge(const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
const SVFFunction * getDefFunForMultipleModule() const
Definition: SVFValue.h:393
u32_t arg_size() const
Definition: SVFValue.cpp:170
bool isVarArg() const
Definition: SVFValue.cpp:181

◆ containBlackHoleNode()

bool SVF::PointerAnalysis::containBlackHoleNode ( const PointsTo pts)
inline

Determine whether a points-to contains a black hole or constant node.

Definition at line 289 of file PointerAnalysis.h.

290  {
291  return pts.test(pag->getBlackHoleNode());
292  }
NodeID getBlackHoleNode() const
Definition: IRGraph.h:161

◆ containConstantNode()

bool SVF::PointerAnalysis::containConstantNode ( const PointsTo pts)
inline

Definition at line 293 of file PointerAnalysis.h.

294  {
295  return pts.test(pag->getConstantNode());
296  }
NodeID getConstantNode() const
Definition: IRGraph.h:165

◆ destroy()

void PointerAnalysis::destroy ( )
private

Release the memory.

Definition at line 89 of file PointerAnalysis.cpp.

90 {
91  delete callgraph;
92  callgraph = nullptr;
93 
94  delete callGraphSCC;
95  callGraphSCC = nullptr;
96 
97  delete stat;
98  stat = nullptr;
99 }

◆ disablePrintStat()

void SVF::PointerAnalysis::disablePrintStat ( )
inline

Whether print statistics.

Definition at line 361 of file PointerAnalysis.h.

362  {
363  print_stat = false;
364  }

◆ dumpAllPts()

virtual void SVF::PointerAnalysis::dumpAllPts ( )
inlinevirtual

Reimplemented in SVF::BVDataPTAImpl.

Definition at line 255 of file PointerAnalysis.h.

255 {}

◆ dumpAllTypes()

void PointerAnalysis::dumpAllTypes ( )

Definition at line 232 of file PointerAnalysis.cpp.

233 {
234  for (OrderedNodeSet::iterator nIter = this->getAllValidPtrs().begin();
235  nIter != this->getAllValidPtrs().end(); ++nIter)
236  {
237  const PAGNode* node = getPAG()->getGNode(*nIter);
238  if (SVFUtil::isa<DummyObjVar, DummyValVar>(node))
239  continue;
240 
241  outs() << "##<" << node->getValue()->getName() << "> ";
242  outs() << "Source Loc: " << node->getValue()->getSourceLoc();
243  outs() << "\nNodeID " << node->getId() << "\n";
244 
245  const SVFType* type = node->getValue()->getType();
247  }
248 }
newitem type
Definition: cJSON.cpp:2739
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:653
SymbolTableInfo * getSymbolInfo() const
Definition: IRGraph.h:114
SVFIR * getPAG() const
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
virtual const SVFType * getType() const
Definition: SVFValue.h:256
const std::string & getName() const
Definition: SVFValue.h:243
virtual const std::string getSourceLoc() const
Definition: SVFValue.h:280
const SVFValue * getValue() const
Get/has methods of the components.
Definition: SVFVariables.h:83
void printFlattenFields(const SVFType *type)
Debug method.
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ dumpCPts()

virtual void SVF::PointerAnalysis::dumpCPts ( )
inlinevirtual

Reimplemented in SVF::BVDataPTAImpl, SVF::CondPTAImpl< Cond >, and SVF::CondPTAImpl< ContextCond >.

Definition at line 256 of file PointerAnalysis.h.

256 {}

◆ dumpPts()

void PointerAnalysis::dumpPts ( NodeID  ptr,
const PointsTo pts 
)
virtual

Dump points-to of top-level pointers (ValVar)

print the points-to set of node which has the maximum pts size.

Definition at line 253 of file PointerAnalysis.cpp.

254 {
255 
256  const PAGNode* node = pag->getGNode(ptr);
258  if (SVFUtil::isa<DummyObjVar> (node))
259  {
260  outs() << "##<Dummy Obj > id:" << node->getId();
261  }
262  else if (!SVFUtil::isa<DummyValVar>(node) && !SVFModule::pagReadFromTXT())
263  {
264  if (node->hasValue())
265  {
266  outs() << "##<" << node->getValue()->getName() << "> ";
267  outs() << "Source Loc: " << node->getValue()->getSourceLoc();
268  }
269  }
270  outs() << "\nPtr " << node->getId() << " ";
271 
272  if (pts.empty())
273  {
274  outs() << "\t\tPointsTo: {empty}\n\n";
275  }
276  else
277  {
278  outs() << "\t\tPointsTo: { ";
279  for (PointsTo::iterator it = pts.begin(), eit = pts.end(); it != eit;
280  ++it)
281  outs() << *it << " ";
282  outs() << "}\n\n";
283  }
284 
285  outs() << "";
286 
287  for (PointsTo::iterator it = pts.begin(), eit = pts.end(); it != eit; ++it)
288  {
289  const PAGNode* node = pag->getGNode(*it);
290  if(SVFUtil::isa<ObjVar>(node) == false)
291  continue;
292  NodeID ptd = node->getId();
293  outs() << "!!Target NodeID " << ptd << "\t [";
294  const PAGNode* pagNode = pag->getGNode(ptd);
295  if (SVFUtil::isa<DummyValVar>(node))
296  outs() << "DummyVal\n";
297  else if (SVFUtil::isa<DummyObjVar>(node))
298  outs() << "Dummy Obj id: " << node->getId() << "]\n";
299  else
300  {
302  {
303  if (node->hasValue())
304  {
305  outs() << "<" << pagNode->getValue()->getName() << "> ";
306  outs() << "Source Loc: "
307  << pagNode->getValue()->getSourceLoc() << "] \n";
308  }
309  }
310  }
311  }
312 }
bool empty() const
Returns true if set is empty.
Definition: PointsTo.cpp:98
const_iterator end() const
Definition: PointsTo.h:132
const_iterator begin() const
Definition: PointsTo.h:128
static bool pagReadFromTXT()
Definition: SVFModule.h:98
bool hasValue() const
Definition: SVFVariables.h:101
u32_t NodeID
Definition: GeneralType.h:55

◆ dumpStat()

void PointerAnalysis::dumpStat ( )

Dump the statistics.

Definition at line 163 of file PointerAnalysis.cpp.

164 {
165 
166  if(print_stat && stat)
167  {
168  stat->performStat();
169  }
170 }
void performStat() override
Definition: PTAStat.cpp:52

◆ dumpTopLevelPtsTo()

virtual void SVF::PointerAnalysis::dumpTopLevelPtsTo ( )
inlinevirtual

◆ finalize()

void PointerAnalysis::finalize ( )
virtual

Finalization of a pointer analysis, including checking alias correctness.

Finalize the analysis after solving Given the alias results, verify whether it is correct or not using alias check functions

Print statistics

Dump results

Reimplemented in SVF::VersionedFlowSensitive, SVF::TypeAnalysis, SVF::FlowSensitive, SVF::AndersenBase, SVF::BVDataPTAImpl, SVF::FlowDDA, SVF::ContextDDA, SVF::Andersen, SVF::CondPTAImpl< Cond >, SVF::CondPTAImpl< ContextCond >, SVF::CFLVF, SVF::CFLBase, and SVF::CFLAlias.

Definition at line 176 of file PointerAnalysis.cpp.

177 {
178 
180  dumpStat();
181 
183  if (Options::PTSPrint())
184  {
186  //dumpAllPts();
187  //dumpCPts();
188  }
189 
190  if (Options::TypePrint())
191  dumpAllTypes();
192 
194  dumpAllPts();
195 
198 
200 
202  getCallGraph()->dump("callgraph_final");
203 
205  validateTests();
206 
209 }
bool isBuiltFromFile()
Whether this SVFIR built from a txt file.
Definition: IRGraph.h:119
static const Option< bool > CallGraphDotGraph
Definition: Options.h:126
static const Option< bool > PTSPrint
Definition: Options.h:116
static const Option< bool > PTSAllPrint
Definition: Options.h:117
static const Option< bool > UsePreCompFieldSensitive
Definition: Options.h:129
static const Option< bool > TypePrint
Definition: Options.h:114
static const Option< bool > FuncPointerPrint
Definition: Options.h:115
void dump(const std::string &filename)
Dump the graph.
void verifyCallGraph()
Issue a warning if the function which has indirect call sites can not be reached from program entry.
virtual void validateTests()
Alias check functions to verify correctness of pointer analysis.
virtual void dumpTopLevelPtsTo()
void resetObjFieldSensitive()
Reset all object node as field-sensitive.
PTACallGraph * getCallGraph() const
Return call graph.
virtual void dumpAllPts()
void dumpStat()
Dump the statistics.

◆ getAllFieldsObjVars()

virtual const NodeBS& SVF::PointerAnalysis::getAllFieldsObjVars ( NodeID  id)
inlinevirtual

Definition at line 338 of file PointerAnalysis.h.

339  {
340  return pag->getAllFieldsObjVars(id);
341  }
NodeBS & getAllFieldsObjVars(const MemObj *obj)
Get all fields of an object.
Definition: SVFIR.cpp:477

◆ getAllValidPtrs()

OrderedNodeSet& SVF::PointerAnalysis::getAllValidPtrs ( )
inline

Get all Valid Pointers for resolution.

Definition at line 215 of file PointerAnalysis.h.

216  {
217  return pag->getAllValidPtrs();
218  }
OrderedNodeSet & getAllValidPtrs()
Return valid pointers.
Definition: SVFIR.h:139

◆ getAnalysisTy()

PTATY SVF::PointerAnalysis::getAnalysisTy ( ) const
inline

Type of pointer analysis.

Definition at line 185 of file PointerAnalysis.h.

186  {
187  return ptaTy;
188  }

◆ getBaseObjVar()

NodeID SVF::PointerAnalysis::getBaseObjVar ( NodeID  id)
inline

Definition at line 326 of file PointerAnalysis.h.

327  {
328  return pag->getBaseObjVar(id);
329  }
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
Definition: SVFIR.h:455

◆ getCallGraph()

PTACallGraph* SVF::PointerAnalysis::getCallGraph ( ) const
inline

Return call graph.

Definition at line 171 of file PointerAnalysis.h.

172  {
173  return callgraph;
174  }

◆ getCallGraphSCC()

CallGraphSCC* SVF::PointerAnalysis::getCallGraphSCC ( ) const
inline

Return call graph SCC.

Definition at line 176 of file PointerAnalysis.h.

177  {
178  return callGraphSCC;
179  }

◆ getCallGraphSCCRepNode()

NodeID SVF::PointerAnalysis::getCallGraphSCCRepNode ( NodeID  id) const
inline

Get SCC rep node of a SVFG node.

Definition at line 396 of file PointerAnalysis.h.

397  {
398  return callGraphSCC->repNode(id);
399  }
NodeID repNode(NodeID n) const
get the rep node if not found return itself
Definition: SCC.h:139

◆ getCHGraph()

CommonCHGraph* SVF::PointerAnalysis::getCHGraph ( ) const
inline

get CHGraph

Definition at line 422 of file PointerAnalysis.h.

423  {
424  return chgraph;
425  }

◆ getFIObjVar()

NodeID SVF::PointerAnalysis::getFIObjVar ( NodeID  id)
inline

Definition at line 330 of file PointerAnalysis.h.

331  {
332  return pag->getFIObjVar(id);
333  }
NodeID getFIObjVar(const MemObj *obj) const
Get a field-insensitive obj SVFIR node according to a mem obj.
Definition: SVFIR.h:415

◆ getFunPtr()

NodeID SVF::PointerAnalysis::getFunPtr ( const CallICFGNode cs) const
inlineprotected

Return function pointer PAGNode at a callsite cs.

Definition at line 269 of file PointerAnalysis.h.

270  {
271  return pag->getFunPtr(cs);
272  }
NodeID getFunPtr(const CallICFGNode *cs) const
Definition: SVFIR.h:354

◆ getGepObjVar()

NodeID SVF::PointerAnalysis::getGepObjVar ( NodeID  id,
const APOffset ap 
)
inline

Definition at line 334 of file PointerAnalysis.h.

335  {
336  return pag->getGepObjVar(id, ap);
337  }
NodeID getGepObjVar(const MemObj *obj, const APOffset &ap)
Get a field SVFIR Object node according to base mem obj and offset.
Definition: SVFIR.cpp:422

◆ getICFG()

ICFG* SVF::PointerAnalysis::getICFG ( ) const
inline

Get ICFG.

Definition at line 161 of file PointerAnalysis.h.

162  {
163  return pag->getICFG();
164  }
ICFG * getICFG() const
Definition: SVFIR.h:171

◆ getImplTy()

PTAImplTy SVF::PointerAnalysis::getImplTy ( ) const
inline

Return implementation type of the pointer analysis.

Definition at line 191 of file PointerAnalysis.h.

192  {
193  return ptaImplTy;
194  }

◆ getIndCallMap()

CallEdgeMap& SVF::PointerAnalysis::getIndCallMap ( )
inline

Get callees from an indirect callsite.

Definition at line 368 of file PointerAnalysis.h.

369  {
370  return getCallGraph()->getIndCallMap();
371  }
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
Definition: PTACallGraph.h:304

◆ getIndCSCallees()

const FunctionSet& SVF::PointerAnalysis::getIndCSCallees ( const CallICFGNode cs) const
inline

Definition at line 376 of file PointerAnalysis.h.

377  {
378  return getCallGraph()->getIndCSCallees(cs);
379  }
const FunctionSet & getIndCSCallees(const CallICFGNode *cs) const
Definition: PTACallGraph.h:312

◆ getIndirectCallsites()

const CallSiteToFunPtrMap& SVF::PointerAnalysis::getIndirectCallsites ( ) const
inlineprotected

Return all indirect callsites.

Definition at line 264 of file PointerAnalysis.h.

265  {
266  return pag->getIndirectCallsites();
267  }
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
Definition: SVFIR.h:350

◆ getModule()

SVFModule* SVF::PointerAnalysis::getModule ( ) const
inline

Module.

Definition at line 210 of file PointerAnalysis.h.

211  {
212  return svfMod;
213  }

◆ getNumOfResolvedIndCallEdge()

u32_t SVF::PointerAnalysis::getNumOfResolvedIndCallEdge ( ) const
inline

Return number of resolved indirect call edges.

Definition at line 166 of file PointerAnalysis.h.

167  {
169  }
u32_t getNumOfResolvedIndCallEdge() const
Definition: PTACallGraph.h:324

◆ getPAG()

SVFIR* SVF::PointerAnalysis::getPAG ( ) const
inline

Get/set SVFIR

Definition at line 198 of file PointerAnalysis.h.

199  {
200  return pag;
201  }

◆ getPts()

virtual const PointsTo& SVF::PointerAnalysis::getPts ( NodeID  ptr)
pure virtual

Get points-to targets of a pointer. It needs to be implemented in child class.

Implemented in SVF::CondPTAImpl< Cond >, SVF::CondPTAImpl< ContextCond >, SVF::Steensgaard, SVF::BVDataPTAImpl, and SVF::Andersen.

◆ getRevPts()

virtual const NodeSet& SVF::PointerAnalysis::getRevPts ( NodeID  nodeId)
pure virtual

Given an object, get all the nodes having whose pointsto contains the object. Similar to getPts, this also needs to be implemented in child classes.

Implemented in SVF::CondPTAImpl< Cond >, SVF::CondPTAImpl< ContextCond >, SVF::BVDataPTAImpl, and SVF::CFLAlias.

◆ getStat()

PTAStat* SVF::PointerAnalysis::getStat ( ) const
inline

Get PTA stat.

Definition at line 205 of file PointerAnalysis.h.

206  {
207  return stat;
208  }

◆ getVFnsFromCHA()

void PointerAnalysis::getVFnsFromCHA ( const CallICFGNode cs,
VFunSet vfns 
)

Definition at line 427 of file PointerAnalysis.cpp.

428 {
429  if (chgraph->csHasVFnsBasedonCHA(cs))
430  vfns = chgraph->getCSVFsBasedonCHA(cs);
431 }
virtual bool csHasVFnsBasedonCHA(const CallICFGNode *cs)=0
virtual const VFunSet & getCSVFsBasedonCHA(const CallICFGNode *cs)=0

◆ getVFnsFromPts()

void PointerAnalysis::getVFnsFromPts ( const CallICFGNode cs,
const PointsTo target,
VFunSet vfns 
)

Definition at line 436 of file PointerAnalysis.cpp.

437 {
438 
439  if (chgraph->csHasVtblsBasedonCHA(cs))
440  {
442  const VTableSet &chaVtbls = chgraph->getCSVtblsBasedonCHA(cs);
443  for (PointsTo::iterator it = target.begin(), eit = target.end(); it != eit; ++it)
444  {
445  const PAGNode *ptdnode = pag->getGNode(*it);
446  if (ptdnode->hasValue())
447  {
448  if (const SVFGlobalValue *vtbl = SVFUtil::dyn_cast<SVFGlobalValue>(ptdnode->getValue()))
449  {
450  if (chaVtbls.find(vtbl) != chaVtbls.end())
451  vtbls.insert(vtbl);
452  }
453  }
454  }
455  chgraph->getVFnsFromVtbls(cs, vtbls, vfns);
456  }
457 }
virtual const VTableSet & getCSVtblsBasedonCHA(const CallICFGNode *cs)=0
virtual void getVFnsFromVtbls(const CallICFGNode *cs, const VTableSet &vtbls, VFunSet &virtualFunctions)=0
virtual bool csHasVtblsBasedonCHA(const CallICFGNode *cs)=0
Set< const SVFGlobalValue * > VTableSet
Definition: CHG.h:44
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96

◆ hasIndCSCallees()

bool SVF::PointerAnalysis::hasIndCSCallees ( const CallICFGNode cs) const
inline

Definition at line 372 of file PointerAnalysis.h.

373  {
374  return getCallGraph()->hasIndCSCallees(cs);
375  }
bool hasIndCSCallees(const CallICFGNode *cs) const
Definition: PTACallGraph.h:308

◆ initialize()

void PointerAnalysis::initialize ( )
virtual

Initialization of a pointer analysis, including building symbol table and SVFIR etc.

Initialization of pointer analysis

initialise pta call graph for every pointer analysis instance

Reimplemented in SVF::VersionedFlowSensitive, SVF::TypeAnalysis, SVF::FlowSensitive, SVF::AndersenBase, SVF::FlowDDA, SVF::ContextDDA, SVF::AndersenSFR, SVF::AndersenWaveDiff, SVF::Andersen, SVF::CFLVF, and SVF::CFLAlias.

Definition at line 104 of file PointerAnalysis.cpp.

105 {
106  assert(pag && "SVFIR has not been built!");
107 
108  svfMod = pag->getModule();
109  chgraph = pag->getCHG();
110 
113  {
114  CallGraphBuilder bd;
116  }
117  else
118  {
119  PTACallGraph* cg = pag->getCallGraph();
120  callgraph = new PTACallGraph(*cg);
121  }
123 
124  // dump callgraph
126  getCallGraph()->dump("callgraph_initial");
127 }
ThreadCallGraph * buildThreadCallGraph()
Build thread-aware callgraph.
static const Option< bool > EnableThreadCallGraph
Definition: Options.h:132
void callGraphSCCDetection()
PTACallGraph SCC related methods.
PTACallGraph * getCallGraph()
Definition: SVFIR.h:192
CommonCHGraph * getCHG()
Definition: SVFIR.h:181
SVFModule * getModule()
Definition: SVFIR.h:161

◆ inSameCallGraphSCC()

bool SVF::PointerAnalysis::inSameCallGraphSCC ( const SVFFunction fun1,
const SVFFunction fun2 
)
inline

Return TRUE if this edge is inside a PTACallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG.

Definition at line 401 of file PointerAnalysis.h.

402  {
403  const PTACallGraphNode* src = callgraph->getCallGraphNode(fun1);
404  const PTACallGraphNode* dst = callgraph->getCallGraphNode(fun2);
405  return (getCallGraphSCCRepNode(src->getId()) == getCallGraphSCCRepNode(dst->getId()));
406  }
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
Definition: PTACallGraph.h:339
NodeID getCallGraphSCCRepNode(NodeID id) const
Get SCC rep node of a SVFG node.

◆ isArrayMemObj()

bool SVF::PointerAnalysis::isArrayMemObj ( NodeID  id) const
inline

Definition at line 312 of file PointerAnalysis.h.

313  {
314  const MemObj* mem = pag->getObject(id);
315  assert(mem && "memory object is null??");
316  return mem->isArray();
317  }
const MemObj * getObject(NodeID id) const
Definition: SVFIR.h:395

◆ isBlkObjOrConstantObj()

virtual bool SVF::PointerAnalysis::isBlkObjOrConstantObj ( NodeID  ptd) const
inlinevirtual

Definition at line 297 of file PointerAnalysis.h.

298  {
299  return pag->isBlkObjOrConstantObj(ptd);
300  }
bool isBlkObjOrConstantObj(NodeID id) const
Definition: SVFIR.h:435

◆ isFieldInsensitive()

bool SVF::PointerAnalysis::isFieldInsensitive ( NodeID  id) const
inline

Definition at line 347 of file PointerAnalysis.h.

348  {
349  const MemObj* mem = pag->getBaseObj(id);
350  return mem->isFieldInsensitive();
351  }
bool isFieldInsensitive() const
Return true if its field limit is 0.
const MemObj * getBaseObj(NodeID id) const
Definition: SVFIR.h:459

◆ isFIObjNode()

bool SVF::PointerAnalysis::isFIObjNode ( NodeID  id) const
inline

For field-sensitivity

Definition at line 322 of file PointerAnalysis.h.

323  {
324  return (SVFUtil::isa<FIObjVar>(pag->getGNode(id)));
325  }

◆ isHeapMemObj()

bool SVF::PointerAnalysis::isHeapMemObj ( NodeID  id) const
inline

Whether this object is heap or array.

Definition at line 305 of file PointerAnalysis.h.

306  {
307  const MemObj* mem = pag->getObject(id);
308  assert(mem && "memory object is null??");
309  return mem->isHeap();
310  }

◆ isInRecursion()

bool SVF::PointerAnalysis::isInRecursion ( const SVFFunction fun) const
inline

Definition at line 407 of file PointerAnalysis.h.

408  {
410  }
bool isInCycle(NodeID n) const
whether the node is in a cycle
Definition: SCC.h:149

◆ isLocalVarInRecursiveFun()

bool PointerAnalysis::isLocalVarInRecursiveFun ( NodeID  id) const

Whether a local variable is in function recursions.

Return TRUE if this node is a local variable of recursive function.

Definition at line 133 of file PointerAnalysis.cpp.

134 {
135  const MemObj* obj = pag->getObject(id);
136  assert(obj && "object not found!!");
137  if(obj->isStack())
138  {
139  if(const SVFFunction* svffun = pag->getGNode(id)->getFunction())
140  {
141  return callGraphSCC->isInCycle(getCallGraph()->getCallGraphNode(svffun)->getId());
142  }
143  }
144  return false;
145 }
bool isStack() const
virtual const SVFFunction * getFunction() const
Return the function that this SVFVar resides in. Return nullptr if it is a global or constantexpr nod...
Definition: SVFVariables.h:122

◆ printIndCSTargets() [1/2]

void PointerAnalysis::printIndCSTargets ( )

Print all indirect callsites

Definition at line 346 of file PointerAnalysis.cpp.

347 {
348  outs() << "==================Function Pointer Targets==================\n";
349  const CallEdgeMap& callEdges = getIndCallMap();
350  CallEdgeMap::const_iterator it = callEdges.begin();
351  CallEdgeMap::const_iterator eit = callEdges.end();
352  for (; it != eit; ++it)
353  {
354  const CallICFGNode* cs = it->first;
355  const FunctionSet& targets = it->second;
356  printIndCSTargets(cs, targets);
357  }
358 
359  const CallSiteToFunPtrMap& indCS = getIndirectCallsites();
360  CallSiteToFunPtrMap::const_iterator csIt = indCS.begin();
361  CallSiteToFunPtrMap::const_iterator csEit = indCS.end();
362  for (; csIt != csEit; ++csIt)
363  {
364  const CallICFGNode* cs = csIt->first;
365  if (hasIndCSCallees(cs) == false)
366  {
367  outs() << "\nNodeID: " << csIt->second;
368  outs() << "\nCallSite: ";
369  outs() << cs->toString();
370  outs() << "\tLocation: " << cs->getSourceLoc();
371  outs() << "\n\t!!!has no targets!!!\n";
372  }
373  }
374 }
const std::string toString() const override
Definition: ICFG.cpp:131
const std::string getSourceLoc() const override
Definition: ICFGNode.h:588
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
const CallSiteToFunPtrMap & getIndirectCallsites() const
Return all indirect callsites.
bool hasIndCSCallees(const CallICFGNode *cs) const
Set< const SVFFunction * > FunctionSet
SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap

◆ printIndCSTargets() [2/2]

void PointerAnalysis::printIndCSTargets ( const CallICFGNode cs,
const FunctionSet targets 
)

Print targets of a function pointer.

Print indirect call targets at an indirect callsite

Definition at line 317 of file PointerAnalysis.cpp.

318 {
319  outs() << "\nNodeID: " << getFunPtr(cs);
320  outs() << "\nCallSite: ";
321  outs() << cs->toString();
322  outs() << "\tLocation: " << cs->getSourceLoc();
323  outs() << "\t with Targets: ";
324 
325  if (!targets.empty())
326  {
327  FunctionSet::const_iterator fit = targets.begin();
328  FunctionSet::const_iterator feit = targets.end();
329  for (; fit != feit; ++fit)
330  {
331  const SVFFunction* callee = *fit;
332  outs() << "\n\t" << callee->getName();
333  }
334  }
335  else
336  {
337  outs() << "\n\tNo Targets!";
338  }
339 
340  outs() << "\n";
341 }
NodeID getFunPtr(const CallICFGNode *cs) const
Return function pointer PAGNode at a callsite cs.

◆ printStat()

bool SVF::PointerAnalysis::printStat ( )
inline

Whether print statistics.

Definition at line 355 of file PointerAnalysis.h.

356  {
357  return print_stat;
358  }

◆ PTAName()

virtual const std::string SVF::PointerAnalysis::PTAName ( ) const
inlinevirtual

Return PTA name.

Reimplemented in SVF::VersionedFlowSensitive, SVF::FlowSensitive, SVF::FlowDDA, SVF::ContextDDA, and SVF::Andersen.

Definition at line 416 of file PointerAnalysis.h.

417  {
418  return "Pointer Analysis";
419  }

◆ resetObjFieldSensitive()

void PointerAnalysis::resetObjFieldSensitive ( )
protected

Reset all object node as field-sensitive.

Reset field sensitivity

Definition at line 150 of file PointerAnalysis.cpp.

151 {
152  for (SVFIR::iterator nIter = pag->begin(); nIter != pag->end(); ++nIter)
153  {
154  if(ObjVar* node = SVFUtil::dyn_cast<ObjVar>(nIter->second))
155  const_cast<MemObj*>(node->getMemObj())->setFieldSensitive();
156  }
157 }
iterator begin()
Iterators.
Definition: GenericGraph.h:627
IDToNodeMapTy::iterator iterator
Node Iterators.
Definition: GenericGraph.h:606

◆ resolveCPPIndCalls()

void PointerAnalysis::resolveCPPIndCalls ( const CallICFGNode cs,
const PointsTo target,
CallEdgeMap newEdges 
)
virtual

Resolve cpp indirect call edges.

Definition at line 484 of file PointerAnalysis.cpp.

485 {
486  assert(cs->isVirtualCall() && "not cpp virtual call");
487 
488  VFunSet vfns;
490  getVFnsFromCHA(cs, vfns);
491  else
492  getVFnsFromPts(cs, target, vfns);
493  connectVCallToVFns(cs, vfns, newEdges);
494 }
bool isVirtualCall() const
Definition: ICFGNode.h:527
static const Option< bool > ConnectVCallOnCHA
Definition: Options.h:133
void getVFnsFromPts(const CallICFGNode *cs, const PointsTo &target, VFunSet &vfns)
void connectVCallToVFns(const CallICFGNode *cs, const VFunSet &vfns, CallEdgeMap &newEdges)
void getVFnsFromCHA(const CallICFGNode *cs, VFunSet &vfns)
Set< const SVFFunction * > VFunSet
Definition: CHG.h:47

◆ resolveIndCalls()

void PointerAnalysis::resolveIndCalls ( const CallICFGNode cs,
const PointsTo target,
CallEdgeMap newEdges 
)
virtual

Resolve indirect call edges.

Resolve indirect calls

discover indirect pointer target

Definition at line 381 of file PointerAnalysis.cpp.

382 {
383 
384  assert(pag->isIndirectCallSites(cs) && "not an indirect callsite?");
386  for (PointsTo::iterator ii = target.begin(), ie = target.end();
387  ii != ie; ii++)
388  {
389 
391  {
392  wrnMsg("Resolved Indirect Call Edges are Out-Of-Budget, please increase the limit");
393  return;
394  }
395 
396  if(ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(pag->getGNode(*ii)))
397  {
398  const MemObj* obj = pag->getObject(objPN);
399 
400  if(obj->isFunction())
401  {
402  const SVFFunction* calleefun = SVFUtil::cast<SVFFunction>(obj->getValue());
403  const SVFFunction* callee = calleefun->getDefFunForMultipleModule();
404 
405  if(SVFUtil::matchArgs(cs, callee) == false)
406  continue;
407 
408  if(0 == getIndCallMap()[cs].count(callee))
409  {
410  newEdges[cs].insert(callee);
411  getIndCallMap()[cs].insert(callee);
412 
413  callgraph->addIndirectCallGraphEdge(cs, cs->getCaller(), callee);
414  // FIXME: do we need to update llvm call graph here?
415  // The indirect call is maintained by ourself, We may update llvm's when we need to
416  //PTACallGraphNode* callgraphNode = callgraph->getOrInsertFunction(cs.getCaller());
417  //callgraphNode->addCalledFunction(cs,callgraph->getOrInsertFunction(callee));
418  }
419  }
420  }
421  }
422 }
const SVFValue * getValue() const
Get the reference value to this object.
bool isFunction() const
object attributes methods
static const Option< u32_t > IndirectCallLimit
Definition: Options.h:128
u32_t getNumOfResolvedIndCallEdge() const
Return number of resolved indirect call edges.
bool isIndirectCallSites(const CallICFGNode *cs) const
Definition: SVFIR.h:366
std::string wrnMsg(const std::string &msg)
Returns warning message by converting a string into yellow string output.
Definition: SVFUtil.cpp:61
bool matchArgs(const CallICFGNode *cs, const SVFFunction *callee)
Definition: SVFUtil.cpp:320

◆ setObjFieldInsensitive()

void SVF::PointerAnalysis::setObjFieldInsensitive ( NodeID  id)
inline

Definition at line 342 of file PointerAnalysis.h.

343  {
344  MemObj* mem = const_cast<MemObj*>(pag->getBaseObj(id));
345  mem->setFieldInsensitive();
346  }

◆ validateExpectedFailureTests()

void PointerAnalysis::validateExpectedFailureTests ( std::string  fun)
protectedvirtual

Pointer analysis validator

Definition at line 565 of file PointerAnalysis.cpp.

566 {
567 
568  if (const SVFFunction* checkFun = svfMod->getSVFFunction(fun))
569  {
570  if(!checkFun->isUncalledFunction())
571  outs() << "[" << this->PTAName() << "] Checking " << fun << "\n";
572 
573  for(const CallICFGNode* callNode : pag->getCallSiteSet())
574  {
575  if (callNode->getCalledFunction() == checkFun)
576  {
577  assert(callNode->arg_size() == 2
578  && "arguments should be two pointers!!");
579  const SVFVar* V1 = callNode->getArgument(0);
580  const SVFVar* V2 = callNode->getArgument(1);
581  AliasResult aliasRes = alias(V1->getId(), V2->getId());
582 
583  bool expectedFailure = false;
585  {
586  // change to must alias when our analysis support it
587  if (aliasRes == AliasResult::NoAlias)
588  expectedFailure = true;
589  }
590  else if (fun == aliasTestFailNoAlias || fun == aliasTestFailNoAliasMangled)
591  {
592  // change to partial alias when our analysis support it
593  if (aliasRes == AliasResult::MayAlias || aliasRes == AliasResult::PartialAlias || aliasRes == AliasResult::MustAlias)
594  expectedFailure = true;
595  }
596  else
597  assert(false && "not supported alias check!!");
598 
599  NodeID id1 = V1->getId();
600  NodeID id2 = V2->getId();
601 
602  if (expectedFailure)
603  outs() << sucMsg("\t EXPECTED-FAILURE :") << fun << " check <id:" << id1 << ", id:" << id2 << "> at ("
604  << callNode->getSourceLoc() << ")\n";
605  else
606  {
607  SVFUtil::errs() << errMsg("\t UNEXPECTED FAILURE :") << fun << " check <id:" << id1 << ", id:" << id2 << "> at ("
608  << callNode->getSourceLoc() << ")\n";
609  assert(false && "test case failed!");
610  }
611  }
612  }
613  }
614 }
static const std::string aliasTestFailNoAlias
static const std::string aliasTestFailMayAlias
static const std::string aliasTestFailMayAliasMangled
virtual AliasResult alias(const SVFValue *V1, const SVFValue *V2)=0
Interface exposed to users of our pointer analysis, given Value infos.
virtual const std::string PTAName() const
Return PTA name.
static const std::string aliasTestFailNoAliasMangled
const CallSiteSet & getCallSiteSet() const
Get all callsites.
Definition: SVFIR.h:254
const SVFFunction * getSVFFunction(const std::string &name)
Definition: SVFModule.cpp:48
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
Definition: SVFUtil.cpp:53
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
Definition: SVFUtil.cpp:76
std::ostream & errs()
Overwrite llvm::errs()
Definition: SVFUtil.h:56
AliasResult
Definition: SVFType.h:527
@ PartialAlias
Definition: SVFType.h:531
@ MustAlias
Definition: SVFType.h:530
@ MayAlias
Definition: SVFType.h:529
@ NoAlias
Definition: SVFType.h:528

◆ validateSuccessTests()

void PointerAnalysis::validateSuccessTests ( std::string  fun)
protectedvirtual

Find the alias check functions annotated in the C files check whether the alias analysis results consistent with the alias check function itself

Definition at line 500 of file PointerAnalysis.cpp.

501 {
502  // check for must alias cases, whether our alias analysis produce the correct results
503  if (const SVFFunction* checkFun = svfMod->getSVFFunction(fun))
504  {
505  if(!checkFun->isUncalledFunction())
506  outs() << "[" << this->PTAName() << "] Checking " << fun << "\n";
507 
508  for(const CallICFGNode* callNode : pag->getCallSiteSet())
509  {
510  if (callNode->getCalledFunction() == checkFun)
511  {
512  assert(callNode->getNumArgOperands() == 2
513  && "arguments should be two pointers!!");
514  const SVFVar* V1 = callNode->getArgument(0);
515  const SVFVar* V2 = callNode->getArgument(1);
516  AliasResult aliasRes = alias(V1->getId(), V2->getId());
517 
518  bool checkSuccessful = false;
519  if (fun == aliasTestMayAlias || fun == aliasTestMayAliasMangled)
520  {
521  if (aliasRes == AliasResult::MayAlias || aliasRes == AliasResult::MustAlias)
522  checkSuccessful = true;
523  }
524  else if (fun == aliasTestNoAlias || fun == aliasTestNoAliasMangled)
525  {
526  if (aliasRes == AliasResult::NoAlias)
527  checkSuccessful = true;
528  }
529  else if (fun == aliasTestMustAlias || fun == aliasTestMustAliasMangled)
530  {
531  // change to must alias when our analysis support it
532  if (aliasRes == AliasResult::MayAlias || aliasRes == AliasResult::MustAlias)
533  checkSuccessful = true;
534  }
535  else if (fun == aliasTestPartialAlias || fun == aliasTestPartialAliasMangled)
536  {
537  // change to partial alias when our analysis support it
538  if (aliasRes == AliasResult::MayAlias)
539  checkSuccessful = true;
540  }
541  else
542  assert(false && "not supported alias check!!");
543 
544  NodeID id1 = V1->getId();
545  NodeID id2 = V2->getId();
546 
547  if (checkSuccessful)
548  outs() << sucMsg("\t SUCCESS :") << fun << " check <id:" << id1 << ", id:" << id2 << "> at ("
549  << callNode->getSourceLoc() << ")\n";
550  else
551  {
552  SVFUtil::errs() << errMsg("\t FAILURE :") << fun
553  << " check <id:" << id1 << ", id:" << id2
554  << "> at (" << callNode->getSourceLoc() << ")\n";
555  assert(false && "test case failed!");
556  }
557  }
558  }
559  }
560 }
static const std::string aliasTestNoAliasMangled
static const std::string aliasTestMayAliasMangled
static const std::string aliasTestMustAlias
static const std::string aliasTestMayAlias
static const std::string aliasTestPartialAlias
static const std::string aliasTestNoAlias
static const std::string aliasTestPartialAliasMangled
static const std::string aliasTestMustAliasMangled

◆ validateTests()

void PointerAnalysis::validateTests ( )
protectedvirtual

Member Data Documentation

◆ alias_validation

bool SVF::PointerAnalysis::alias_validation
protected

Flag for validating points-to/alias results.

Definition at line 135 of file PointerAnalysis.h.

◆ aliasTestFailMayAlias

const std::string PointerAnalysis::aliasTestFailMayAlias = "EXPECTEDFAIL_MAYALIAS"
static

Definition at line 119 of file PointerAnalysis.h.

◆ aliasTestFailMayAliasMangled

const std::string PointerAnalysis::aliasTestFailMayAliasMangled = "_Z21EXPECTEDFAIL_MAYALIASPvS_"
static

Definition at line 120 of file PointerAnalysis.h.

◆ aliasTestFailNoAlias

const std::string PointerAnalysis::aliasTestFailNoAlias = "EXPECTEDFAIL_NOALIAS"
static

Definition at line 121 of file PointerAnalysis.h.

◆ aliasTestFailNoAliasMangled

const std::string PointerAnalysis::aliasTestFailNoAliasMangled = "_Z20EXPECTEDFAIL_NOALIASPvS_"
static

Definition at line 122 of file PointerAnalysis.h.

◆ aliasTestMayAlias

const std::string PointerAnalysis::aliasTestMayAlias = "MAYALIAS"
static

Definition at line 111 of file PointerAnalysis.h.

◆ aliasTestMayAliasMangled

const std::string PointerAnalysis::aliasTestMayAliasMangled = "_Z8MAYALIASPvS_"
static

Definition at line 112 of file PointerAnalysis.h.

◆ aliasTestMustAlias

const std::string PointerAnalysis::aliasTestMustAlias = "MUSTALIAS"
static

Definition at line 117 of file PointerAnalysis.h.

◆ aliasTestMustAliasMangled

const std::string PointerAnalysis::aliasTestMustAliasMangled = "_Z9MUSTALIASPvS_"
static

Definition at line 118 of file PointerAnalysis.h.

◆ aliasTestNoAlias

const std::string PointerAnalysis::aliasTestNoAlias = "NOALIAS"
static

Definition at line 113 of file PointerAnalysis.h.

◆ aliasTestNoAliasMangled

const std::string PointerAnalysis::aliasTestNoAliasMangled = "_Z7NOALIASPvS_"
static

Definition at line 114 of file PointerAnalysis.h.

◆ aliasTestPartialAlias

const std::string PointerAnalysis::aliasTestPartialAlias = "PARTIALALIAS"
static

Definition at line 115 of file PointerAnalysis.h.

◆ aliasTestPartialAliasMangled

const std::string PointerAnalysis::aliasTestPartialAliasMangled = "_Z12PARTIALALIASPvS_"
static

Definition at line 116 of file PointerAnalysis.h.

◆ callgraph

PTACallGraph* SVF::PointerAnalysis::callgraph
protected

Call graph used for pointer analysis.

Definition at line 151 of file PointerAnalysis.h.

◆ callGraphSCC

CallGraphSCC* SVF::PointerAnalysis::callGraphSCC
protected

SCC for PTACallGraph.

Definition at line 153 of file PointerAnalysis.h.

◆ chgraph

CommonCHGraph* SVF::PointerAnalysis::chgraph
protected

CHGraph.

Definition at line 157 of file PointerAnalysis.h.

◆ icfg

ICFG* SVF::PointerAnalysis::icfg
protected

Interprocedural control-flow graph.

Definition at line 155 of file PointerAnalysis.h.

◆ OnTheFlyIterBudgetForStat

u32_t SVF::PointerAnalysis::OnTheFlyIterBudgetForStat
protected

Flag for iteration budget for on-the-fly statistics.

Definition at line 137 of file PointerAnalysis.h.

◆ pag

SVFIR * PointerAnalysis::pag = nullptr
staticprotected

SVFIR.

Definition at line 141 of file PointerAnalysis.h.

◆ print_stat

bool SVF::PointerAnalysis::print_stat
protected

User input flags.

Flag for printing the statistic results

Definition at line 133 of file PointerAnalysis.h.

◆ ptaImplTy

PTAImplTy SVF::PointerAnalysis::ptaImplTy
protected

PTA implementation type.

Definition at line 147 of file PointerAnalysis.h.

◆ ptaTy

PTATY SVF::PointerAnalysis::ptaTy
protected

Pointer analysis Type.

Definition at line 145 of file PointerAnalysis.h.

◆ stat

PTAStat* SVF::PointerAnalysis::stat
protected

Statistics.

Definition at line 149 of file PointerAnalysis.h.

◆ svfMod

SVFModule* SVF::PointerAnalysis::svfMod
protected

Module.

Definition at line 143 of file PointerAnalysis.h.


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