Skip to content

Commit

Permalink
SVF code formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
yuleisui committed Nov 30, 2024
1 parent 4708c4e commit 07d6570
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
21 changes: 13 additions & 8 deletions svf-llvm/lib/SVFIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ SVFIR* SVFIRBuilder::build()
{
if(llvmModuleSet()->hasICFGNode(inst))
it.second->gNode = llvmModuleSet()->getICFGNode(inst);
} else if (const Function* func = SVFUtil::dyn_cast<Function>(llvmModuleSet()->getLLVMValue(
it.second->getValue())))
}
else if (const Function* func = SVFUtil::dyn_cast<Function>(llvmModuleSet()->getLLVMValue(
it.second->getValue())))
{
it.second->gNode = llvmModuleSet()->getCallGraphNode(func);
}
Expand Down Expand Up @@ -232,11 +233,13 @@ void SVFIRBuilder::initialiseNodes()
}

if (const Function* func =
SVFUtil::dyn_cast<Function>(llvmModuleSet()->getLLVMValue(iter->first)))
SVFUtil::dyn_cast<Function>(llvmModuleSet()->getLLVMValue(iter->first)))
{
const CallGraphNode* cgn = llvmModuleSet()->getCallGraphNode(func);
pag->addFunValNode(cgn, iter->second, icfgNode);
} else {
}
else
{
pag->addValNode(iter->first, iter->second, icfgNode);
}
}
Expand All @@ -249,10 +252,12 @@ void SVFIRBuilder::initialiseNodes()
if(iter->second == symTable->blackholeSymID() || iter->second == symTable->constantSymID())
continue;
if (const Function* func = SVFUtil::dyn_cast<Function>(
llvmModuleSet()->getLLVMValue(iter->first)))
llvmModuleSet()->getLLVMValue(iter->first)))
{
pag->addFunObjNode(llvmModuleSet()->getCallGraphNode(func), iter->second);
} else {
}
else
{
pag->addObjNode(iter->first, iter->second);
}
}
Expand All @@ -264,7 +269,7 @@ void SVFIRBuilder::initialiseNodes()
DBOUT(DPAGBuild, outs() << "add ret node " << iter->second << "\n");
pag->addRetNode(
llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
llvmModuleSet()->getLLVMValue(iter->first))),
llvmModuleSet()->getLLVMValue(iter->first))),
iter->second);
}

Expand All @@ -275,7 +280,7 @@ void SVFIRBuilder::initialiseNodes()
DBOUT(DPAGBuild, outs() << "add vararg node " << iter->second << "\n");
pag->addVarargNode(
llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(
llvmModuleSet()->getLLVMValue(iter->first))),
llvmModuleSet()->getLLVMValue(iter->first))),
iter->second);
}

Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/lib/SVFIRExtAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
if (const FunValVar* funcValVar = SVFUtil::dyn_cast<FunValVar>(valVar))
{
const SVFFunction* forkedFun = funcValVar->getCallGraphNode()->getFunction()
->getDefFunForMultipleModule();
->getDefFunForMultipleModule();
const SVFVar* actualParm = getActualParmAtForkSite(callICFGNode);
/// pthread_create has 1 arg.
/// apr_thread_create has 2 arg.
Expand Down
3 changes: 2 additions & 1 deletion svf/include/SVFIR/SVFIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,8 @@ class SVFIR : public IRGraph
return addValNode(val, node, i);
}

NodeID addFunValNode(const CallGraphNode* callGraphNode, NodeID i, const ICFGNode* icfgNode) {
NodeID addFunValNode(const CallGraphNode* callGraphNode, NodeID i, const ICFGNode* icfgNode)
{
FunValVar* node = new FunValVar(callGraphNode, i, icfgNode);
return addValNode(nullptr, node, i);
}
Expand Down
19 changes: 12 additions & 7 deletions svf/include/SVFIR/SVFVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ class FIObjVar: public ObjVar

class CallGraphNode;

class FunValVar : public ValVar {
class FunValVar : public ValVar
{
friend class SVFIRWriter;
friend class SVFIRReader;
private:
Expand Down Expand Up @@ -617,13 +618,14 @@ class FunValVar : public ValVar {
}
//@}

inline const CallGraphNode* getCallGraphNode() const {
inline const CallGraphNode* getCallGraphNode() const
{
return callGraphNode;
}

/// Constructor
FunValVar(const CallGraphNode* cgn, NodeID i, const ICFGNode* icn,
PNODEK ty = FunValNode)
PNODEK ty = FunValNode)
: ValVar(nullptr, i, ty, icn), callGraphNode(cgn)
{

Expand All @@ -632,7 +634,8 @@ class FunValVar : public ValVar {
virtual const std::string toString() const;
};

class FunObjVar : public FIObjVar {
class FunObjVar : public FIObjVar
{
friend class SVFIRWriter;
friend class SVFIRReader;

Expand Down Expand Up @@ -674,9 +677,10 @@ class FunObjVar : public FIObjVar {

/// Constructor
FunObjVar(const CallGraphNode* cgNode, NodeID i, const MemObj* mem,
PNODEK ty = FunObjNode);
PNODEK ty = FunObjNode);

inline const CallGraphNode* getCallGraphNode() const {
inline const CallGraphNode* getCallGraphNode() const
{
return callGraphNode;
}

Expand Down Expand Up @@ -727,7 +731,8 @@ class RetPN: public ValVar
/// Constructor
RetPN(const CallGraphNode* node, NodeID i);

inline const CallGraphNode* getCallGraphNode() const {
inline const CallGraphNode* getCallGraphNode() const
{
return callGraphNode;
}

Expand Down
6 changes: 3 additions & 3 deletions svf/lib/Graphs/ThreadCallGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool ThreadCallGraph::addDirectForkEdge(const CallICFGNode* cs)

PTACallGraphNode* caller = getCallGraphNode(cs->getCaller());
const SVFFunction* forkee = SVFUtil::dyn_cast<FunValVar>(tdAPI->getForkedFun(cs))
->getCallGraphNode()->getFunction();
->getCallGraphNode()->getFunction();
assert(forkee && "callee does not exist");
PTACallGraphNode* callee = getCallGraphNode(forkee->getDefFunForMultipleModule());
CallSiteID csId = addCallSite(cs, callee->getFunction());
Expand Down Expand Up @@ -189,8 +189,8 @@ void ThreadCallGraph::addDirectJoinEdge(const CallICFGNode* cs,const CallSiteSet

const SVFFunction* threadRoutineFun =
SVFUtil::dyn_cast<FunValVar>(tdAPI->getForkedFun(*it))
->getCallGraphNode()
->getFunction();
->getCallGraphNode()
->getFunction();
assert(threadRoutineFun && "thread routine function does not exist");
PTACallGraphNode* threadRoutineFunNode = getCallGraphNode(threadRoutineFun);
CallSiteID csId = addCallSite(cs, threadRoutineFun);
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/SVFIR/SVFIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ bool SVFIR::isValidTopLevelPtr(const SVFVar* node)
if (SVFUtil::isa<RetPN>(node) || SVFUtil::isa<VarArgPN>(node) || SVFUtil::isa<FunValVar>(node))
{
return true;
} else if(node->hasValue())
}
else if(node->hasValue())
return !SVFUtil::isArgOfUncalledFunction(node->getValue());
}
}
Expand Down
8 changes: 5 additions & 3 deletions svf/lib/SVFIR/SVFVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ const std::string GepValVar::toString() const
return rawstr.str();
}

RetPN::RetPN(const CallGraphNode* node, NodeID i) : ValVar(i, RetNode), callGraphNode(node) {
RetPN::RetPN(const CallGraphNode* node, NodeID i) : ValVar(i, RetNode), callGraphNode(node)
{
isPtr = node->getFunction()->getReturnType()->isPointerTy();
}

Expand Down Expand Up @@ -198,7 +199,7 @@ const std::string FunValVar::toString() const
}

FunObjVar::FunObjVar(const CallGraphNode* cgNode, NodeID i, const MemObj* mem,
PNODEK ty)
PNODEK ty)
: FIObjVar(nullptr, i, mem, ty), callGraphNode(cgNode)
{
isPtr = callGraphNode->getFunction()->getType()->isPointerTy();
Expand Down Expand Up @@ -230,7 +231,8 @@ const std::string RetPN::toString() const
return rawstr.str();
}

const SVFFunction* VarArgPN::getFunction() const {
const SVFFunction* VarArgPN::getFunction() const
{
return callGraphNode->getFunction();
}

Expand Down

0 comments on commit 07d6570

Please sign in to comment.