48using namespace SVFUtil;
107 assert(
pag &&
"SVFIR has not been built!");
155 if(
ObjVar* node = SVFUtil::dyn_cast<ObjVar>(
nIter->second))
156 const_cast<MemObj*
>(node->getMemObj())->setFieldSensitive();
239 if (SVFUtil::isa<DummyObjVar, DummyValVar>(node))
244 outs() <<
"\nNodeID " << node->
getId() <<
"\n";
259 if (SVFUtil::isa<DummyObjVar> (node))
261 outs() <<
"##<Dummy Obj > id:" << node->
getId();
271 outs() <<
"\nPtr " << node->
getId() <<
" ";
275 outs() <<
"\t\tPointsTo: {empty}\n\n";
279 outs() <<
"\t\tPointsTo: { ";
291 if(SVFUtil::isa<ObjVar>(node) ==
false)
294 outs() <<
"!!Target NodeID " <<
ptd <<
"\t [";
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";
306 outs() <<
"<" <<
pagNode->getValue()->getName() <<
"> ";
307 outs() <<
"Source Loc: "
308 <<
pagNode->getValue()->getSourceLoc() <<
"] \n";
321 outs() <<
"\nCallSite: ";
324 outs() <<
"\t with Targets: ";
328 FunctionSet::const_iterator
fit =
targets.begin();
338 outs() <<
"\n\tNo Targets!";
349 outs() <<
"==================Function Pointer Targets==================\n";
351 CallEdgeMap::const_iterator
it =
callEdges.begin();
361 CallSiteToFunPtrMap::const_iterator
csIt =
indCS.begin();
362 CallSiteToFunPtrMap::const_iterator
csEit =
indCS.end();
368 outs() <<
"\nNodeID: " <<
csIt->second;
369 outs() <<
"\nCallSite: ";
372 outs() <<
"\n\t!!!has no targets!!!\n";
393 wrnMsg(
"Resolved Indirect Call Edges are Out-Of-Budget, please increase the limit");
401 if(
obj->isFunction())
469 for (VFunSet::const_iterator
fit =
vfns.begin(),
510 outs() <<
"[" << this->
PTAName() <<
"] Checking " << fun <<
"\n";
517 &&
"arguments should be two pointers!!");
546 assert(
false &&
"not supported alias check!!");
552 outs() <<
sucMsg(
"\t SUCCESS :") << fun <<
" check <id:" <<
id1 <<
", id:" <<
id2 <<
"> at ("
553 <<
callNode->getSourceLoc() <<
")\n";
557 <<
" check <id:" <<
id1 <<
", id:" <<
id2
558 <<
"> at (" <<
callNode->getSourceLoc() <<
")\n";
559 assert(
false &&
"test case failed!");
575 outs() <<
"[" << this->
PTAName() <<
"] Checking " << fun <<
"\n";
582 &&
"arguments should be two pointers!!");
601 assert(
false &&
"not supported alias check!!");
607 outs() <<
sucMsg(
"\t EXPECTED-FAILURE :") << fun <<
" check <id:" <<
id1 <<
", id:" <<
id2 <<
"> at ("
608 <<
callNode->getSourceLoc() <<
")\n";
612 <<
callNode->getSourceLoc() <<
")\n";
613 assert(
false &&
"test case failed!");
const std::string toString() const override
const std::string getSourceLoc() const override
bool isVirtualCall() const
const SVFFunction * getCaller() const
Return callsite.
virtual const VFunSet & getCSVFsBasedonCHA(const CallICFGNode *cs)=0
virtual bool csHasVFnsBasedonCHA(const CallICFGNode *cs)=0
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
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.
NodeType * getGNode(NodeID id) const
Get a node.
bool isBuiltFromFile()
Whether this SVFIR built from a txt file.
SymbolTableInfo * getSymbolInfo() const
static const Option< bool > CallGraphDotGraph
static const Option< bool > EnableThreadCallGraph
static const Option< bool > PTSPrint
static const Option< bool > EnableAliasCheck
static const Option< bool > PTSAllPrint
static const Option< bool > UsePreCompFieldSensitive
static const Option< bool > TypePrint
static const Option< u32_t > IndirectCallLimit
static const Option< bool > FuncPointerPrint
static const Option< bool > ConnectVCallOnCHA
static const Option< bool > PStat
static const Option< u32_t > StatBudget
void addIndirectCallGraphEdge(const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
Add indirect call edges.
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.
void performStat() override
void getVFnsFromPts(const CallICFGNode *cs, const PointsTo &target, VFunSet &vfns)
void destroy()
Release the memory.
virtual void validateTests()
Alias check functions to verify correctness of pointer analysis.
PTATY
Pointer analysis type list.
CommonCHGraph * chgraph
CHGraph.
static const std::string aliasTestNoAliasMangled
bool isLocalVarInRecursiveFun(NodeID id) const
Whether a local variable is in function recursions.
virtual void finalize()
Finalization of a pointer analysis, including checking alias correctness.
static const std::string aliasTestMayAliasMangled
PointerAnalysis(SVFIR *pag, PTATY ty=Default_PTA, bool alias_check=true)
Constructor.
static const std::string aliasTestFailNoAlias
virtual void dumpPts(NodeID ptr, const PointsTo &pts)
static const std::string aliasTestFailMayAlias
bool print_stat
User input flags.
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
virtual ~PointerAnalysis()
Destructor.
Set< const SVFGlobalValue * > VTableSet
PTAImplTy ptaImplTy
PTA implementation type.
PTAStat * stat
Statistics.
virtual void dumpTopLevelPtsTo()
static const std::string aliasTestFailMayAliasMangled
void connectVCallToVFns(const CallICFGNode *cs, const VFunSet &vfns, CallEdgeMap &newEdges)
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
void resetObjFieldSensitive()
Reset all object node as field-sensitive.
static const std::string aliasTestMustAlias
static const std::string aliasTestMayAlias
virtual void validateSuccessTests(std::string fun)
SVFModule * svfMod
Module.
const CallSiteToFunPtrMap & getIndirectCallsites() const
Return all indirect callsites.
static const std::string aliasTestPartialAlias
virtual void dumpAllPts()
virtual void resolveIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve indirect call edges.
PTACallGraph * getCallGraph() const
Return call graph.
Set< const SVFFunction * > VFunSet
bool alias_validation
Flag for validating points-to/alias results.
void callGraphSCCDetection()
PTACallGraph SCC related methods.
void dumpStat()
Dump the statistics.
virtual void validateExpectedFailureTests(std::string fun)
bool hasIndCSCallees(const CallICFGNode *cs) const
virtual void resolveCPPIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve cpp indirect call edges.
@ BaseImpl
Represents PointerAnalaysis.
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
Set< const SVFFunction * > FunctionSet
static const std::string aliasTestNoAlias
static const std::string aliasTestPartialAliasMangled
PTACallGraph * callgraph
Call graph used for pointer analysis.
u32_t getNumOfResolvedIndCallEdge() const
Return number of resolved indirect call edges.
SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
NodeID getFunPtr(const CallICFGNode *cs) const
Return function pointer PAGNode at a callsite cs.
void getVFnsFromCHA(const CallICFGNode *cs, VFunSet &vfns)
virtual AliasResult alias(const SVFValue *V1, const SVFValue *V2)=0
Interface exposed to users of our pointer analysis, given Value infos.
CallGraphSCC * callGraphSCC
SCC for PTACallGraph.
static const std::string aliasTestMustAliasMangled
virtual const std::string PTAName() const
Return PTA name.
static const std::string aliasTestFailNoAliasMangled
u32_t OnTheFlyIterBudgetForStat
Flag for iteration budget for on-the-fly statistics.
NodeID getId() const
Get ID.
const SVFFunction * getDefFunForMultipleModule() const
const CallSiteSet & getCallSiteSet() const
Get all callsites.
bool isIndirectCallSites(const CallICFGNode *cs) const
const BaseObjVar * getBaseObject(NodeID id) const
const MemObj * getObject(NodeID id) const
const ValVar * getBaseValVar(NodeID id) const
static bool pagReadFromTXT()
const SVFFunction * getSVFFunction(const std::string &name)
const std::string & getName() const
virtual const SVFType * getType() const
virtual const std::string getSourceLoc() const
const SVFValue * getValue() const
Get/has methods of the components.
virtual const SVFFunction * getFunction() const
void printFlattenFields(const SVFType *type)
Debug method.
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
std::ostream & errs()
Overwrite llvm::errs()
std::string wrnMsg(const std::string &msg)
Returns warning message by converting a string into yellow string output.
std::ostream & outs()
Overwrite llvm::outs()
bool matchArgs(const CallICFGNode *cs, const SVFFunction *callee)
llvm::IRBuilder IRBuilder