Question: #include Assignment - 2 . h using namespace SVF; using namespace SVFUtil; void ICFGTraversal::dfs ( const ICFGEdge * src , const ICFGNode * dst

#include "Assignment-2.h"
using namespace SVF;
using namespace SVFUtil;
void ICFGTraversal::dfs(const ICFGEdge *src, const ICFGNode *dst){
auto curItem = std::make_pair(src, callstack);
visited.insert(curItem);
path.push_back(src);
if (src->getDstNode()== dst){
printICFGPath();
}
for (const ICFGEdge* edge : src->getDstNode()->getOutEdges()){
auto newItem = std::make_pair(edge, callstack);
if (visited.find(newItem)== visited.end()){
if (edge->isIntraCFGEdge()){
dfs(edge, dst);
} else if (edge->isCallCFGEdge()){
callstack.push_back(edge->getSrcNode());
dfs(edge, dst);
callstack.pop_back();
} else if (edge->isRetCFGEdge()){
if (!callstack.empty() && callstack.back()== edge->getCallSite()){
callstack.pop_back();
dfs(edge, dst);
} else if (callstack.empty()){
dfs(edge, dst);
}
}
}
}
visited.erase(curItem);
path.pop_back();
}
void ICFGTraversal::printICFGPath(){
std::string pathStr = "START: ";
for (const auto& edge : path){
pathStr += std::to_string(edge->getSrcNode()->getId())+"->";
}
pathStr += std::to_string(path.back()->getDstNode()->getId())+" END";
paths.insert(pathStr);
std::cout pathStr std::endl;
}
void ICFGTraversal::analyse(){
std::set sources;
std::set sinks;
for (const ICFGNode *src : identifySource(sources)){
for (const ICFGNode *sink: identifySink(sinks)){
const IntraCFGEdge* startEdge = new IntraCFGEdge(nullptr,const_cast(src));
handleIntra(startEdge);
dfs(startEdge, sink);
resetSolver();
}
}
}#ifndef SVF_ICFG_TRAVERSAL_H
#define SVF_ICFG_TRAVERSAL_H
#include "SVF-LLVM/SVFIRBuilder.h"
namespace SVF{
class ICFGTraversal
{
public:
typedef std::vector CallStack;
ICFGTraversal(SVFIR *s, ICFG *i) : svfir(s), icfg(i)
{
}
std::set &identifySource(std::set &container)
{
container.insert(icfg->getGlobalICFGNode());
return container;
}
std::set &identifySink(std::set &container)
{
for (const CallICFGNode *cs : svfir->getCallSiteSet())
{
const SVFFunction *fun = SVFUtil::getCallee(cs->getCallSite());
if (isAssertFun(fun))
container.insert(cs);
}
return container;
}
inline bool isAssertFun(const SVFFunction *fun) const{
return (fun != NULL && (fun->getName()== "assert" || fun->getName()=="svf_assert" ||fun->getName()== "sink" ));
}
virtual void resetSolver(){
visited.clear();
}
virtual void printICFGPath();
void dfs(const ICFGEdge *src, const ICFGNode *dst);
void analyse();
virtual bool handleCall(const CallCFGEdge* call){ return true; }
virtual bool handleRet(const RetCFGEdge* ret){ return true; }
virtual bool handleIntra(const IntraCFGEdge* edge){ return true; }
Set getPaths(){
return paths;
}
private:
ICFG *icfg;
Set paths;
protected:
SVFIR *svfir;
Set > visited;
CallStack callstack;
std::vector path;
};
}
#endif //SVF_EX_SSE_H. I have two problems with my code. Type Mismatch in push_back: The first error is due to a type mismatch in the push_back method call. Your callstack vector is defined to hold pointers of type const SVF::SVFInstruction*, but you're trying to push a pointer of type SVF::GenericEdge::NodeType*(which is equivalent to SVF::ICFGNode*). Since SVF::ICFGNode* is not implicitly convertible to const SVF::SVFInstruction*, the compiler raises an error. You need to ensure that the types are compatible or find another way to track the call stack that doesn't involve pushing incompatible types.
Missing getCallSite Method: The second error indicates that the ICFGEdge class doesn't have a member function named getCallSite. This could be due to a few reasons: maybe the method doesn't exist in the version of the SVF framework you're using, or it might be a method of a subclass of ICFGEdge, and you're trying to call it on an ICFGEdge object. Please fix it for me.
 #include "Assignment-2.h" using namespace SVF; using namespace SVFUtil; void ICFGTraversal::dfs(const ICFGEdge

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!