Static Value-Flow Analysis
Loading...
Searching...
No Matches
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.
 
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.
 
u32_t getNumOfResolvedIndCallEdge () const
 Return number of resolved indirect call edges.
 
PTACallGraphgetCallGraph () const
 Return call graph.
 
CallGraphSCCgetCallGraphSCC () const
 Return call graph SCC.
 
 PointerAnalysis (SVFIR *pag, PTATY ty=Default_PTA, bool alias_check=true)
 Constructor.
 
PTATY getAnalysisTy () const
 Type of pointer analysis.
 
PTAImplTy getImplTy () const
 Return implementation type of the pointer analysis.
 
bool printStat ()
 Whether print statistics.
 
void disablePrintStat ()
 Whether print statistics.
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite.
 
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.
 
void callGraphSCCDetection ()
 PTACallGraph SCC related methods.
 
NodeID getCallGraphSCCRepNode (NodeID id) const
 Get SCC rep node of a SVFG node.
 
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.
 
bool isInRecursion (const SVFFunction *fun) const
 
bool isLocalVarInRecursiveFun (NodeID id) const
 Whether a local variable is in function recursions.
 
virtual const std::string PTAName () const
 Return PTA name.
 
CommonCHGraphgetCHGraph () const
 get CHGraph
 
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.
 

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

Static Protected Attributes

static SVFIRpag = nullptr
 SVFIR.
 

Private Member Functions

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

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,
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
75 VFS_WPA,
76 FSCS_WPA,
81
82 // Demand driven analysis
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 69 of file PointerAnalysis.cpp.

69 :
70 svfMod(nullptr),ptaTy(ty),stat(nullptr),callgraph(nullptr),callGraphSCC(nullptr),icfg(nullptr),chgraph(nullptr)
71{
72 pag = p;
77}
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.
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~PointerAnalysis()

PointerAnalysis::~PointerAnalysis ( )
virtual

Destructor.

Destructor

Definition at line 82 of file PointerAnalysis.cpp.

83{
84 destroy();
85 // do not delete the SVFIR for now
86 //delete pag;
87}
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::CFLAlias, SVF::CondPTAImpl< Cond >, SVF::CondPTAImpl< ContextCond >, and SVF::BVDataPTAImpl.

◆ 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::CFLAlias, SVF::CondPTAImpl< Cond >, SVF::CondPTAImpl< ContextCond >, and SVF::BVDataPTAImpl.

◆ 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::CFLBase, SVF::ContextDDA, SVF::FlowDDA, SVF::AndersenBase, SVF::FlowSensitive, and SVF::TypeAnalysis.

◆ callGraphSCCDetection()

void SVF::PointerAnalysis::callGraphSCCDetection ( )
inline

PTACallGraph SCC related methods.

PTACallGraph SCC detection

Definition at line 386 of file PointerAnalysis.h.

387 {
388 if(callGraphSCC==nullptr)
390
391 callGraphSCC->find();
392 }
SCCDetection< PTACallGraph * > CallGraphSCC

◆ computeDDAPts()

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

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

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

Definition at line 233 of file PointerAnalysis.h.

233{}

◆ connectVCallToVFns()

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

Definition at line 466 of file PointerAnalysis.cpp.

467{
469 for (VFunSet::const_iterator fit = vfns.begin(),
470 feit = vfns.end(); fit != feit; ++fit)
471 {
472 const SVFFunction* callee = *fit;
474 if (getIndCallMap()[cs].count(callee) > 0)
475 continue;
476 if(cs->arg_size() == callee->arg_size() ||
477 (cs->isVarArg() && callee->isVarArg()))
478 {
479 newEdges[cs].insert(callee);
480 getIndCallMap()[cs].insert(callee);
481 const CallICFGNode* callBlockNode = cs;
482 callgraph->addIndirectCallGraphEdge(callBlockNode, cs->getCaller(),callee);
483 }
484 }
485}
bool isVarArg() const
Definition ICFGNode.h:523
const SVFFunction * getCaller() const
Return callsite.
Definition ICFGNode.h:470
u32_t arg_size() const
Definition ICFGNode.h:505
void addIndirectCallGraphEdge(const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
Add indirect call edges.
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
const SVFFunction * getDefFunForMultipleModule() const
Definition SVFValue.h:404

◆ 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 90 of file PointerAnalysis.cpp.

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

◆ disablePrintStat()

void SVF::PointerAnalysis::disablePrintStat ( )
inline

Whether print statistics.

Definition at line 359 of file PointerAnalysis.h.

360 {
361 print_stat = false;
362 }

◆ 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 233 of file PointerAnalysis.cpp.

234{
235 for (OrderedNodeSet::iterator nIter = this->getAllValidPtrs().begin();
236 nIter != this->getAllValidPtrs().end(); ++nIter)
237 {
238 const PAGNode* node = getPAG()->getGNode(*nIter);
239 if (SVFUtil::isa<DummyObjVar, DummyValVar>(node))
240 continue;
241
242 outs() << "##<" << node->getValue()->getName() << "> ";
243 outs() << "Source Loc: " << node->getValue()->getSourceLoc();
244 outs() << "\nNodeID " << node->getId() << "\n";
245
246 const SVFType* type = node->getValue()->getType();
248 }
249}
newitem type
Definition cJSON.cpp:2739
NodeType * getGNode(NodeID id) const
Get a node.
SymbolTableInfo * getSymbolInfo() const
Definition IRGraph.h:114
SVFIR * getPAG() const
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
NodeID getId() const
Get ID.
const std::string & getName() const
Definition SVFValue.h:243
virtual const SVFType * getType() const
Definition SVFValue.h:256
virtual const std::string getSourceLoc() const
Definition SVFValue.h:280
const SVFValue * getValue() const
Get/has methods of the components.
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::CondPTAImpl< Cond >, SVF::CondPTAImpl< ContextCond >, and SVF::BVDataPTAImpl.

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 254 of file PointerAnalysis.cpp.

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

◆ dumpStat()

void PointerAnalysis::dumpStat ( )

Dump the statistics.

Definition at line 164 of file PointerAnalysis.cpp.

165{
166
167 if(print_stat && stat)
168 {
169 stat->performStat();
170 }
171}
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::CFLAlias, SVF::CFLBase, SVF::CFLVF, SVF::CondPTAImpl< Cond >, SVF::CondPTAImpl< ContextCond >, SVF::Andersen, SVF::ContextDDA, SVF::FlowDDA, SVF::BVDataPTAImpl, SVF::AndersenBase, SVF::FlowSensitive, SVF::TypeAnalysis, and SVF::VersionedFlowSensitive.

Definition at line 177 of file PointerAnalysis.cpp.

178{
179
181 dumpStat();
182
184 if (Options::PTSPrint())
185 {
187 //dumpAllPts();
188 //dumpCPts();
189 }
190
191 if (Options::TypePrint())
192 dumpAllTypes();
193
195 dumpAllPts();
196
199
201
203 getCallGraph()->dump("callgraph_final");
204
207
210}
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.
virtual void dumpAllPts()
PTACallGraph * getCallGraph() const
Return call graph.
void dumpStat()
Dump the statistics.

◆ getAllFieldsObjVars()

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

Definition at line 336 of file PointerAnalysis.h.

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

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

◆ 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 324 of file PointerAnalysis.h.

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

◆ 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 394 of file PointerAnalysis.h.

395 {
396 return callGraphSCC->repNode(id);
397 }

◆ getCHGraph()

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

get CHGraph

Definition at line 420 of file PointerAnalysis.h.

421 {
422 return chgraph;
423 }

◆ getFIObjVar()

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

Definition at line 328 of file PointerAnalysis.h.

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

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

◆ getGepObjVar()

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

Definition at line 332 of file PointerAnalysis.h.

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

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

◆ 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 366 of file PointerAnalysis.h.

367 {
368 return getCallGraph()->getIndCallMap();
369 }
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.

◆ getIndCSCallees()

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

Definition at line 374 of file PointerAnalysis.h.

375 {
376 return getCallGraph()->getIndCSCallees(cs);
377 }
const FunctionSet & getIndCSCallees(const CallICFGNode *cs) const

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

◆ 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

◆ 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::Andersen, SVF::BVDataPTAImpl, SVF::Steensgaard, SVF::CondPTAImpl< Cond >, and SVF::CondPTAImpl< ContextCond >.

◆ 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::CFLAlias, SVF::BVDataPTAImpl, SVF::CondPTAImpl< Cond >, and SVF::CondPTAImpl< ContextCond >.

◆ 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 428 of file PointerAnalysis.cpp.

429{
432}
virtual const VFunSet & getCSVFsBasedonCHA(const CallICFGNode *cs)=0
virtual bool csHasVFnsBasedonCHA(const CallICFGNode *cs)=0

◆ getVFnsFromPts()

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

Definition at line 437 of file PointerAnalysis.cpp.

438{
439
441 {
444 for (PointsTo::iterator it = target.begin(), eit = target.end(); it != eit; ++it)
445 {
446 const PAGNode *ptdnode = pag->getGNode(*it);
447 if (ptdnode->hasValue())
448 {
451 {
452 const SVFGlobalValue* globalValue = SVFUtil::dyn_cast<SVFGlobalValue>(ptdnode->getValue());
453 if (chaVtbls.find(globalValue) != chaVtbls.end())
454 vtbls.insert(globalValue);
455 }
456
457 }
458 }
460 }
461}
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
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:405
const ValVar * getBaseValVar(NodeID id) const
Definition SVFIR.h:415
Set< const SVFGlobalValue * > VTableSet
Definition CHG.h:46

◆ hasIndCSCallees()

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

Definition at line 370 of file PointerAnalysis.h.

371 {
372 return getCallGraph()->hasIndCSCallees(cs);
373 }
bool hasIndCSCallees(const CallICFGNode *cs) const

◆ 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::CFLAlias, SVF::CFLVF, SVF::Andersen, SVF::AndersenWaveDiff, SVF::AndersenSFR, SVF::ContextDDA, SVF::FlowDDA, SVF::AndersenBase, SVF::FlowSensitive, SVF::TypeAnalysis, and SVF::VersionedFlowSensitive.

Definition at line 105 of file PointerAnalysis.cpp.

106{
107 assert(pag && "SVFIR has not been built!");
108
109 svfMod = pag->getModule();
110 chgraph = pag->getCHG();
111
114 {
116 callgraph = bd.buildThreadCallGraph();
117 }
118 else
119 {
121 callgraph = bd.buildPTACallGraph();
122 }
124
125 // dump callgraph
127 getCallGraph()->dump("callgraph_initial");
128}
static const Option< bool > EnableThreadCallGraph
Definition Options.h:132
void callGraphSCCDetection()
PTACallGraph SCC related methods.
SVFModule * getModule()
Definition SVFIR.h:162
CommonCHGraph * getCHG()
Definition SVFIR.h:182

◆ 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 399 of file PointerAnalysis.h.

400 {
401 const PTACallGraphNode* src = callgraph->getCallGraphNode(fun1);
402 const PTACallGraphNode* dst = callgraph->getCallGraphNode(fun2);
403 return (getCallGraphSCCRepNode(src->getId()) == getCallGraphSCCRepNode(dst->getId()));
404 }
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
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 310 of file PointerAnalysis.h.

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

◆ isBlkObjOrConstantObj()

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

Definition at line 297 of file PointerAnalysis.h.

298 {
300 }
bool isBlkObjOrConstantObj(NodeID id) const
Definition SVFIR.h:457

◆ isFieldInsensitive()

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

Definition at line 345 of file PointerAnalysis.h.

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

◆ isFIObjNode()

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

For field-sensitivity

Definition at line 320 of file PointerAnalysis.h.

321 {
322 return (SVFUtil::isa<BaseObjVar>(pag->getGNode(id)));
323 }

◆ 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 return pag->getBaseObject(id) && SVFUtil::isa<HeapObjVar, DummyObjVar>(pag->getBaseObject(id));
308 }

◆ isInRecursion()

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

Definition at line 405 of file PointerAnalysis.h.

406 {
407 return callGraphSCC->isInCycle(callgraph->getCallGraphNode(fun)->getId());
408 }

◆ 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 134 of file PointerAnalysis.cpp.

135{
137 assert(baseObjVar && "base object not found!!");
138 if(SVFUtil::isa<StackObjVar>(baseObjVar))
139 {
140 if(const SVFFunction* svffun = pag->getGNode(id)->getFunction())
141 {
142 return callGraphSCC->isInCycle(getCallGraph()->getCallGraphNode(svffun)->getId());
143 }
144 }
145 return false;
146}
virtual const SVFFunction * getFunction() const

◆ printIndCSTargets() [1/2]

void PointerAnalysis::printIndCSTargets ( )

Print all indirect callsites

Definition at line 347 of file PointerAnalysis.cpp.

348{
349 outs() << "==================Function Pointer Targets==================\n";
351 CallEdgeMap::const_iterator it = callEdges.begin();
352 CallEdgeMap::const_iterator eit = callEdges.end();
353 for (; it != eit; ++it)
354 {
355 const CallICFGNode* cs = it->first;
356 const FunctionSet& targets = it->second;
358 }
359
361 CallSiteToFunPtrMap::const_iterator csIt = indCS.begin();
362 CallSiteToFunPtrMap::const_iterator csEit = indCS.end();
363 for (; csIt != csEit; ++csIt)
364 {
365 const CallICFGNode* cs = csIt->first;
366 if (hasIndCSCallees(cs) == false)
367 {
368 outs() << "\nNodeID: " << csIt->second;
369 outs() << "\nCallSite: ";
370 outs() << cs->toString();
371 outs() << "\tLocation: " << cs->getSourceLoc();
372 outs() << "\n\t!!!has no targets!!!\n";
373 }
374 }
375}
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 318 of file PointerAnalysis.cpp.

319{
320 outs() << "\nNodeID: " << getFunPtr(cs);
321 outs() << "\nCallSite: ";
322 outs() << cs->toString();
323 outs() << "\tLocation: " << cs->getSourceLoc();
324 outs() << "\t with Targets: ";
325
326 if (!targets.empty())
327 {
328 FunctionSet::const_iterator fit = targets.begin();
329 FunctionSet::const_iterator feit = targets.end();
330 for (; fit != feit; ++fit)
331 {
332 const SVFFunction* callee = *fit;
333 outs() << "\n\t" << callee->getName();
334 }
335 }
336 else
337 {
338 outs() << "\n\tNo Targets!";
339 }
340
341 outs() << "\n";
342}
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 353 of file PointerAnalysis.h.

354 {
355 return print_stat;
356 }

◆ PTAName()

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

Return PTA name.

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

Definition at line 414 of file PointerAnalysis.h.

415 {
416 return "Pointer Analysis";
417 }

◆ resetObjFieldSensitive()

void PointerAnalysis::resetObjFieldSensitive ( )
protected

Reset all object node as field-sensitive.

Reset field sensitivity

Definition at line 151 of file PointerAnalysis.cpp.

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

◆ resolveCPPIndCalls()

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

Resolve cpp indirect call edges.

Definition at line 488 of file PointerAnalysis.cpp.

489{
490 assert(cs->isVirtualCall() && "not cpp virtual call");
491
494 getVFnsFromCHA(cs, vfns);
495 else
498}
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 382 of file PointerAnalysis.cpp.

383{
384
385 assert(pag->isIndirectCallSites(cs) && "not an indirect callsite?");
387 for (PointsTo::iterator ii = target.begin(), ie = target.end();
388 ii != ie; ii++)
389 {
390
392 {
393 wrnMsg("Resolved Indirect Call Edges are Out-Of-Budget, please increase the limit");
394 return;
395 }
396
397 if(ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(pag->getGNode(*ii)))
398 {
399 const MemObj* obj = pag->getObject(objPN);
400
401 if(obj->isFunction())
402 {
403 const SVFFunction* calleefun = SVFUtil::cast<CallGraphNode>(obj->getGNode())->getFunction();
405
406 if(SVFUtil::matchArgs(cs, callee) == false)
407 continue;
408
409 if(0 == getIndCallMap()[cs].count(callee))
410 {
411 newEdges[cs].insert(callee);
412 getIndCallMap()[cs].insert(callee);
413
415 // FIXME: do we need to update llvm call graph here?
416 // The indirect call is maintained by ourself, We may update llvm's when we need to
417 //PTACallGraphNode* callgraphNode = callgraph->getOrInsertFunction(cs.getCaller());
418 //callgraphNode->addCalledFunction(cs,callgraph->getOrInsertFunction(callee));
419 }
420 }
421 }
422 }
423}
int count
Definition cJSON.h:216
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:367
std::string wrnMsg(const std::string &msg)
Returns warning message by converting a string into yellow string output.
Definition SVFUtil.cpp:62
bool matchArgs(const CallICFGNode *cs, const SVFFunction *callee)
Definition SVFUtil.cpp:321

◆ setObjFieldInsensitive()

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

Definition at line 340 of file PointerAnalysis.h.

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

◆ validateExpectedFailureTests()

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

Pointer analysis validator

Definition at line 569 of file PointerAnalysis.cpp.

570{
571
572 if (const SVFFunction* checkFun = svfMod->getSVFFunction(fun))
573 {
574 if(!checkFun->isUncalledFunction())
575 outs() << "[" << this->PTAName() << "] Checking " << fun << "\n";
576
577 for(const CallICFGNode* callNode : pag->getCallSiteSet())
578 {
579 if (callNode->getCalledFunction() == checkFun)
580 {
581 assert(callNode->arg_size() == 2
582 && "arguments should be two pointers!!");
583 const SVFVar* V1 = callNode->getArgument(0);
584 const SVFVar* V2 = callNode->getArgument(1);
585 AliasResult aliasRes = alias(V1->getId(), V2->getId());
586
587 bool expectedFailure = false;
589 {
590 // change to must alias when our analysis support it
592 expectedFailure = true;
593 }
594 else if (fun == aliasTestFailNoAlias || fun == aliasTestFailNoAliasMangled)
595 {
596 // change to partial alias when our analysis support it
598 expectedFailure = true;
599 }
600 else
601 assert(false && "not supported alias check!!");
602
603 NodeID id1 = V1->getId();
604 NodeID id2 = V2->getId();
605
606 if (expectedFailure)
607 outs() << sucMsg("\t EXPECTED-FAILURE :") << fun << " check <id:" << id1 << ", id:" << id2 << "> at ("
608 << callNode->getSourceLoc() << ")\n";
609 else
610 {
611 SVFUtil::errs() << errMsg("\t UNEXPECTED FAILURE :") << fun << " check <id:" << id1 << ", id:" << id2 << "> at ("
612 << callNode->getSourceLoc() << ")\n";
613 assert(false && "test case failed!");
614 }
615 }
616 }
617 }
618}
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 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:54
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
Definition SVFUtil.cpp:77
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 504 of file PointerAnalysis.cpp.

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