Question: / / / TODO: Implement handling of function calls bool SSE::handleCall ( const CallCFGEdge * calledge ) { return true; } / / / TODO:

/// TODO: Implement handling of function calls
bool SSE::handleCall(const CallCFGEdge* calledge){
return true;
}
/// TODO: Implement handling of function returns
bool SSE::handleRet(const RetCFGEdge* retEdge){
return true;
}
/// TODO: Implement handling of branch statement inside a function
bool SSE::handleBranch(const IntraCFGEdge* edge){
return true;
}
/// TODO: Implement handling of non-branch statement inside a function
/// including handling of (1) AddrStmt, (2) CopyStmt, (3) LoadStmt, (4) StoreStmt and (5) GepStmt
bool SSE::handleNonBranch(const IntraCFGEdge* edge){
const ICFGNode* dstNode = edge->getDstNode();
const ICFGNode* srcNode = edge->getSrcNode();
DBOP(if(!SVFUtil::isa(dstNode) && !SVFUtil::isa(dstNode)) std::cout <<"
## Analyzing "<< dstNode->toString()<<"
");
for (const SVFStmt *stmt : dstNode->getSVFStmts())
{
if (const AddrStmt *addr = SVFUtil::dyn_cast(stmt))
{
/// TODO: Implement handling (1) AddrStmt
}
else if (const CopyStmt *copy = SVFUtil::dyn_cast(stmt))
{
/// TODO: Implement handling (2) CopyStmt
}
else if (const LoadStmt *load = SVFUtil::dyn_cast(stmt))
{
/// TODO: Implement handling (3) LoadStmt
}
else if (const StoreStmt *store = SVFUtil::dyn_cast(stmt))
{
/// TODO: Implement handling (4) StoreStmt
}
else if (const GepStmt *gep = SVFUtil::dyn_cast(stmt))
{
/// TODO: Implement handling (5) GepStmt
}
else if (const BinaryOPStmt *binary = SVFUtil::dyn_cast(stmt))
{
expr op0= getZ3Expr(binary->getOpVarID(0));
expr op1= getZ3Expr(binary->getOpVarID(1));
expr res = getZ3Expr(binary->getResID());
switch (binary->getOpcode())
{
case BinaryOperator::Add:
addToSolver(res == op0+ op1);
break;
case BinaryOperator::Sub:
addToSolver(res == op0- op1);
break;
case BinaryOperator::Mul:
addToSolver(res == op0* op1);
break;
case BinaryOperator::SDiv:
addToSolver(res == op0/ op1);
break;
case BinaryOperator::SRem:
addToSolver(res == op0% op1);
break;
case BinaryOperator::Xor:
addToSolver(int2bv(32, res)==(int2bv(32, op0)^ int2bv(32, op1)));
break;
case BinaryOperator::And:
addToSolver(int2bv(32, res)==(int2bv(32, op0) & int2bv(32, op1)));
break;
case BinaryOperator::Or:
addToSolver(int2bv(32, res)==(int2bv(32, op0)| int2bv(32, op1)));
break;
case BinaryOperator::AShr:
addToSolver(int2bv(32, res)== ashr(int2bv(32, op0), int2bv(32, op1)));
break;
case BinaryOperator::Shl:
addToSolver(int2bv(32, res)== shl(int2bv(32, op0), int2bv(32, op1)));
break;
default:
assert(false && "implement this part");
}
}
else if (const CmpStmt *cmp = SVFUtil::dyn_cast(stmt))
{
expr op0= getZ3Expr(cmp->getOpVarID(0));
expr op1= getZ3Expr(cmp->getOpVarID(1));
expr res = getZ3Expr(cmp->getResID());
auto predicate = cmp->getPredicate();
switch (predicate)
{
case CmpInst::ICMP_EQ:
addToSolver(res == ite(op0== op1, getCtx().int_val(1), getCtx().int_val(0)));
break;
case CmpInst::ICMP_NE:
addToSolver(res == ite(op0!= op1, getCtx().int_val(1), getCtx().int_val(0)));
break;
case CmpInst::ICMP_UGT:
case CmpInst::ICMP_SGT:
addToSolver(res == ite(op0> op1, getCtx().int_val(1), getCtx().int_val(0)));
break;
case CmpInst::ICMP_UGE:
case CmpInst::ICMP_SGE:
addToSolver(res == ite(op0>= op1, getCtx().int_val(1), getCtx().int_val(0)));
break;
case CmpInst::ICMP_ULT:
case CmpInst::ICMP_SLT:
addToSolver(res == ite(op0< op1, getCtx().int_val(1), getCtx().int_val(0)));
break;
case CmpInst::ICMP_ULE:
case CmpInst::ICMP_SLE:
addToSolver(res == ite(op0<= op1, getCtx().int_val(1), getCtx().int_val(0)));
break;
default:
assert(false && "implement this part");
}
}
else if (const UnaryOPStmt *unary = SVFUtil::dyn_cast(stmt))
{
assert(false && "implement this part");

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!