47 using namespace SVFUtil;
69 svfMod(nullptr),ptaTy(ty),stat(nullptr),callgraph(nullptr),callGraphSCC(nullptr),icfg(nullptr),chgraph(nullptr)
106 assert(
pag &&
"SVFIR has not been built!");
136 assert(obj &&
"object not found!!");
154 if(
ObjVar* node = SVFUtil::dyn_cast<ObjVar>(nIter->second))
155 const_cast<MemObj*
>(node->getMemObj())->setFieldSensitive();
238 if (SVFUtil::isa<DummyObjVar, DummyValVar>(node))
243 outs() <<
"\nNodeID " << node->
getId() <<
"\n";
258 if (SVFUtil::isa<DummyObjVar> (node))
260 outs() <<
"##<Dummy Obj > id:" << node->
getId();
270 outs() <<
"\nPtr " << node->
getId() <<
" ";
274 outs() <<
"\t\tPointsTo: {empty}\n\n";
278 outs() <<
"\t\tPointsTo: { ";
281 outs() << *it <<
" ";
290 if(SVFUtil::isa<ObjVar>(node) ==
false)
293 outs() <<
"!!Target NodeID " << ptd <<
"\t [";
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";
306 outs() <<
"Source Loc: "
320 outs() <<
"\nCallSite: ";
323 outs() <<
"\t with Targets: ";
325 if (!targets.empty())
327 FunctionSet::const_iterator fit = targets.begin();
328 FunctionSet::const_iterator feit = targets.end();
329 for (; fit != feit; ++fit)
337 outs() <<
"\n\tNo Targets!";
348 outs() <<
"==================Function Pointer Targets==================\n";
350 CallEdgeMap::const_iterator it = callEdges.begin();
351 CallEdgeMap::const_iterator eit = callEdges.end();
352 for (; it != eit; ++it)
360 CallSiteToFunPtrMap::const_iterator csIt = indCS.begin();
361 CallSiteToFunPtrMap::const_iterator csEit = indCS.end();
362 for (; csIt != csEit; ++csIt)
367 outs() <<
"\nNodeID: " << csIt->second;
368 outs() <<
"\nCallSite: ";
371 outs() <<
"\n\t!!!has no targets!!!\n";
392 wrnMsg(
"Resolved Indirect Call Edges are Out-Of-Budget, please increase the limit");
410 newEdges[cs].insert(callee);
450 if (chaVtbls.find(vtbl) != chaVtbls.end())
465 for (VFunSet::const_iterator fit = vfns.begin(),
466 feit = vfns.end(); fit != feit; ++fit)
475 newEdges[cs].insert(callee);
505 if(!checkFun->isUncalledFunction())
506 outs() <<
"[" << this->
PTAName() <<
"] Checking " << fun <<
"\n";
510 if (callNode->getCalledFunction() == checkFun)
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);
518 bool checkSuccessful =
false;
522 checkSuccessful =
true;
527 checkSuccessful =
true;
533 checkSuccessful =
true;
539 checkSuccessful =
true;
542 assert(
false &&
"not supported alias check!!");
548 outs() <<
sucMsg(
"\t SUCCESS :") << fun <<
" check <id:" << id1 <<
", id:" << id2 <<
"> at ("
549 << callNode->getSourceLoc() <<
")\n";
553 <<
" check <id:" << id1 <<
", id:" << id2
554 <<
"> at (" << callNode->getSourceLoc() <<
")\n";
555 assert(
false &&
"test case failed!");
570 if(!checkFun->isUncalledFunction())
571 outs() <<
"[" << this->
PTAName() <<
"] Checking " << fun <<
"\n";
575 if (callNode->getCalledFunction() == checkFun)
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);
583 bool expectedFailure =
false;
588 expectedFailure =
true;
594 expectedFailure =
true;
597 assert(
false &&
"not supported alias check!!");
603 outs() <<
sucMsg(
"\t EXPECTED-FAILURE :") << fun <<
" check <id:" << id1 <<
", id:" << id2 <<
"> at ("
604 << callNode->getSourceLoc() <<
")\n";
607 SVFUtil::errs() <<
errMsg(
"\t UNEXPECTED FAILURE :") << fun <<
" check <id:" << id1 <<
", id:" << id2 <<
"> at ("
608 << callNode->getSourceLoc() <<
")\n";
609 assert(
false &&
"test case failed!");
ThreadCallGraph * buildThreadCallGraph()
Build thread-aware callgraph.
const std::string toString() const override
const SVFFunction * getCaller() const
Return callsite.
const std::string getSourceLoc() const override
bool isVirtualCall() const
virtual bool csHasVFnsBasedonCHA(const CallICFGNode *cs)=0
virtual const VFunSet & getCSVFsBasedonCHA(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.
NodeType * getGNode(NodeID id) const
Get a node.
IDToNodeMapTy::iterator iterator
Node Iterators.
bool isBuiltFromFile()
Whether this SVFIR built from a txt file.
SymbolTableInfo * getSymbolInfo() const
const SVFValue * getValue() const
Get the reference value to this object.
bool isFunction() const
object attributes methods
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)
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)
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
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.
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
virtual void dumpTopLevelPtsTo()
static const std::string aliasTestFailMayAliasMangled
void connectVCallToVFns(const CallICFGNode *cs, const VFunSet &vfns, CallEdgeMap &newEdges)
void resetObjFieldSensitive()
Reset all object node as field-sensitive.
static const std::string aliasTestMustAlias
static const std::string aliasTestMayAlias
PTACallGraph * getCallGraph() const
Return call graph.
virtual void validateSuccessTests(std::string fun)
SVFModule * svfMod
Module.
static const std::string aliasTestPartialAlias
virtual void dumpAllPts()
virtual void resolveIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve indirect call edges.
const CallSiteToFunPtrMap & getIndirectCallsites() const
Return all indirect callsites.
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.
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.
bool empty() const
Returns true if set is empty.
const_iterator end() const
const_iterator begin() const
bool isInCycle(NodeID n) const
whether the node is in a cycle
NodeID getId() const
Get ID.
const SVFFunction * getDefFunForMultipleModule() const
PTACallGraph * getCallGraph()
const MemObj * getObject(NodeID id) const
bool isIndirectCallSites(const CallICFGNode *cs) const
const CallSiteSet & getCallSiteSet() const
Get all callsites.
static bool pagReadFromTXT()
const SVFFunction * getSVFFunction(const std::string &name)
virtual const SVFType * getType() const
const std::string & getName() const
virtual const std::string getSourceLoc() const
virtual const SVFFunction * getFunction() const
Return the function that this SVFVar resides in. Return nullptr if it is a global or constantexpr nod...
const SVFValue * getValue() const
Get/has methods of the components.
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.
bool matchArgs(const CallICFGNode *cs, const SVFFunction *callee)
std::ostream & outs()
Overwrite llvm::outs()
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set