94 SVFUtil::errs() <<
"getMayAliases is not supported by this pointer analysis.\n";
116 assert(
pag &&
"PAG has not been built!");
145 assert(baseObjVar &&
"base object not found!!");
148 if(
const FunObjVar* svffun =
pag->getSVFVar(
id)->getFunction())
252 outs() <<
"\nNodeID " << node->
getId() <<
"\n";
265 const SVFVar* node =
pag->getSVFVar(ptr);
269 outs() <<
"##<Dummy Obj > id:" << node->
getId();
276 outs() <<
"\nPtr " << node->
getId() <<
" ";
280 outs() <<
"\t\tPointsTo: {empty}\n\n";
284 outs() <<
"\t\tPointsTo: { ";
287 outs() << *it <<
" ";
295 const SVFVar* node =
pag->getSVFVar(*it);
299 outs() <<
"!!Target NodeID " << ptd <<
"\t [";
300 const SVFVar* pagNode =
pag->getSVFVar(ptd);
302 outs() <<
"DummyVal\n";
304 outs() <<
"Dummy Obj id: " << node->
getId() <<
"]\n";
310 outs() <<
"Source Loc: "
323 outs() <<
"\nCallSite: ";
326 outs() <<
"\t with Targets: ";
328 if (!targets.empty())
330 FunctionSet::const_iterator fit = targets.begin();
331 FunctionSet::const_iterator feit = targets.end();
332 for (; fit != feit; ++fit)
340 outs() <<
"\n\tNo Targets!";
351 outs() <<
"==================Function Pointer Targets==================\n";
353 CallEdgeMap::const_iterator it = callEdges.begin();
354 CallEdgeMap::const_iterator eit = callEdges.end();
355 for (; it != eit; ++it)
363 CallSiteToFunPtrMap::const_iterator csIt = indCS.begin();
364 CallSiteToFunPtrMap::const_iterator csEit = indCS.end();
365 for (; csIt != csEit; ++csIt)
370 outs() <<
"\nNodeID: " << csIt->second;
371 outs() <<
"\nCallSite: ";
374 outs() <<
"\n\t!!!has no targets!!!\n";
387 assert(
pag->isIndirectCallSites(cs) &&
"not an indirect callsite?");
395 writeWrnMsg(
"Resolved Indirect Call Edges are Out-Of-Budget, please increase the limit");
399 if(
const ObjVar* objPN =
pag->getObjVar(*ii))
413 newEdges[cs].insert(callee);
432 if (
chgraph->csHasVFnsBasedonCHA(cs))
433 vfns =
chgraph->getCSVFsBasedonCHA(cs);
442 if (
chgraph->csHasVtblsBasedonCHA(cs))
448 const SVFVar* ptdnode =
pag->getSVFVar(*it);
457 pag->getBaseValVar(ptdnode->
getId())))
461 pag->getBaseValVar(ptdnode->
getId()))));
464 if (pVar && chaVtbls.find(pVar) != chaVtbls.end())
467 chgraph->getVFnsFromVtbls(cs, vtbls, vfns);
477 for (VFunSet::const_iterator fit = vfns.begin(),
478 feit = vfns.end(); fit != feit; ++fit)
487 newEdges[cs].insert(callee);
517 if(!checkFun->isUncalledFunction())
518 outs() <<
"[" << this->
PTAName() <<
"] Checking " << fun <<
"\n";
522 if (callNode->getCalledFunction() == checkFun)
524 assert(callNode->getNumArgOperands() == 2
525 &&
"arguments should be two pointers!!");
526 const SVFVar* V1 = callNode->getArgument(0);
527 const SVFVar* V2 = callNode->getArgument(1);
530 bool checkSuccessful =
false;
534 checkSuccessful =
true;
539 checkSuccessful =
true;
545 checkSuccessful =
true;
551 checkSuccessful =
true;
554 assert(
false &&
"not supported alias check!!");
560 outs() <<
sucMsg(
"\t SUCCESS :") << fun <<
" check <id:" << id1 <<
", id:" << id2 <<
"> at ("
561 << callNode->getSourceLoc() <<
")\n";
565 <<
" check <id:" << id1 <<
", id:" << id2
566 <<
"> at (" << callNode->getSourceLoc() <<
")\n";
567 assert(
false &&
"test case failed!");
582 if(!checkFun->isUncalledFunction())
583 outs() <<
"[" << this->
PTAName() <<
"] Checking " << fun <<
"\n";
587 if (callNode->getCalledFunction() == checkFun)
589 assert(callNode->arg_size() == 2
590 &&
"arguments should be two pointers!!");
591 const SVFVar* V1 = callNode->getArgument(0);
592 const SVFVar* V2 = callNode->getArgument(1);
595 bool expectedFailure =
false;
600 expectedFailure =
true;
606 expectedFailure =
true;
609 assert(
false &&
"not supported alias check!!");
615 outs() <<
sucMsg(
"\t EXPECTED-FAILURE :") << fun <<
" check <id:" << id1 <<
", id:" << id2 <<
"> at ("
616 << callNode->getSourceLoc() <<
")\n";
619 SVFUtil::errs() <<
errMsg(
"\t UNEXPECTED FAILURE :") << fun <<
" check <id:" << id1 <<
", id:" << id2 <<
"> at ("
620 << callNode->getSourceLoc() <<
")\n";
621 assert(
false &&
"test case failed!");
bool isFunction() const
object attributes methods
void setFieldSensitive()
Set the memory object to be field sensitive (up to max field limit).
CallGraph * buildPTACallGraph()
Buidl PTA callgraoh.
ThreadCallGraph * buildThreadCallGraph()
Build thread-aware callgraph.
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.
const std::string toString() const override
const std::string getSourceLoc() const override
bool isVirtualCall() const
const FunObjVar * getCaller() const
Return callsite.
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
const FunObjVar * getDefFunForMultipleModule() const
IDToNodeMapTy::iterator iterator
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 > TypePrint
static Option< bool > UsePreCompFieldSensitive
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
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
static bool pagReadFromTXT()
virtual NodeBS getMayAliases(NodeID node)
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.
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
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
Set< const GlobalObjVar * > VTableSet
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and PAG etc.
virtual ~PointerAnalysis()
Destructor.
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)
CallGraph * getCallGraph() const
Return call graph.
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
Set< const FunObjVar * > FunctionSet
virtual void validateSuccessTests(std::string fun)
const CallSiteToFunPtrMap & getIndirectCallsites() const
Return all indirect callsites.
static const std::string aliasTestPartialAlias
virtual void dumpAllPts()
virtual AliasResult alias(const SVFVar *V1, const SVFVar *V2)=0
Interface exposed to users of our pointer analysis, given Value infos.
virtual void resolveIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve indirect call edges.
ICFG * icfg
Interprocedural control-flow graph.
CallGraph * callgraph
Call graph used for pointer analysis.
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.
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
static const std::string aliasTestNoAlias
static const std::string aliasTestPartialAliasMangled
u32_t getNumOfResolvedIndCallEdge() const
Return number of resolved indirect call edges.
NodeID getFunPtr(const CallICFGNode *cs) const
Return function pointer PAGNode at a callsite cs.
void getVFnsFromCHA(const CallICFGNode *cs, VFunSet &vfns)
PTATY ptaTy
Pointer analysis Type.
CallGraphSCC * callGraphSCC
SCC for PTACallGraph.
PointerAnalysis(PAG *pag, PTATY ty=PTATY::Default_PTA, bool alias_check=true)
Constructor.
static const std::string aliasTestMustAliasMangled
virtual const std::string PTAName() const
Return PTA name.
static const std::string aliasTestFailNoAliasMangled
Set< const FunObjVar * > VFunSet
PAG::CallSiteToFunPtrMap CallSiteToFunPtrMap
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
NodeID getId() const
Get ID.
virtual const SVFType * getType() const
virtual const std::string getSourceLoc() const
virtual const std::string & getName() const
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
const ObjVar * getObjVarOfValVar(const ValVar *valVar)
std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > cast(const Y &Val)
LLVM_NODISCARD bool isa(const Y &Val)
std::string errMsg(const std::string &msg)
Print error message by converting a string into red string output.
std::ostream & errs()
Overwrite llvm::errs().
bool matchArgs(const CallICFGNode *cs, const FunObjVar *callee)
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
std::ostream & outs()
Overwrite llvm::outs().
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
@ BaseImpl
Represents PointerAnalaysis.
PTATY
Pointer analysis type list.
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set