Question: assignment - 2 . cpp: / / Software - Analysis - Teaching Assignment 2 : Source Sink ICFG DFS Traversal / / / / *

assignment-2.cpp:
// Software-Analysis-Teaching Assignment 2 : Source Sink ICFG DFS Traversal
//
//
*/
#include
#include "Assignment-2.h"
#include
using namespace SVF;
using namespace std;
/// TODO: print each path once this method is called, and
/// add each path as a string into std::set paths
/// Print the path in the format "START->1->2->4->5->END", where -> indicate an ICFGEdge connects two ICFGNode IDs
void ICFGTraversal::collectICFGPath(std::vector &path){
}
/// TODO: Implement your context-sensitive ICFG traversal here to traverse each program path (once for any loop) from src to dst
void ICFGTraversal::reachability(const ICFGNode *src, const ICFGNode *dst)
{
}
assignment-2.h:
// Software-Analysis-Teaching Assignment 2 : Source Sink ICFG DFS Traversal
//
//
*/
#ifndef ASSIGNMENT_2_H_
#define ASSIGNMENT_2_H_
#include "SVF-LLVM/LLVMUtil.h"
#include "SVF-LLVM/SVFIRBuilder.h"
using namespace SVF;
class ICFGTraversal
{
public:
typedef std::vector CallStack;
public:
ICFGTraversal(SVFIR *p) : pag(p){}
/// TODO: to be implemented
virtual void collectICFGPath(std::vector &path);
/// TODO: to be implemented context sensitive DFS
void reachability(const ICFGNode *src, const ICFGNode *dst);
// Identify source nodes on ICFG (i.e., call instruction with its callee function named 'src')
virtual std::set &identifySources()
{
for (const CallICFGNode *cs : pag->getCallSiteSet())
{
const SVFFunction *fun = cs->getCalledFunction();
if (fun->getName()== "source")
{
sources.insert(cs);
}
}
return sources;
}
// Identify sink nodes on ICFG (i.e., call instruction with its callee function named 'sink')
virtual std::set &identifySinks()
{
for (const CallICFGNode *cs : pag->getCallSiteSet())
{
const SVFFunction *fun = cs->getCalledFunction();
if (fun->getName()== "sink")
{
sinks.insert(cs);
}
}
return sinks;
}
std::set& getPaths(){
return paths;
}
protected:
std::set sources;
std::set sinks;
Set> visited;
CallStack callstack;
SVFIR* pag;
std::set paths;
std::vector path;
};
#endif

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 Programming Questions!