Skip to content

Commit

Permalink
remove SVFModule:: FunctionSet
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoffrey1014 committed Sep 12, 2024
1 parent 363faf8 commit c3aaf52
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 55 deletions.
30 changes: 0 additions & 30 deletions svf/include/SVFIR/SVFModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,13 @@ class SVFModule
friend class SVFIRReader;

public:
typedef std::vector<const SVFFunction*> FunctionSetType;
typedef std::vector<SVFGlobalValue*> GlobalSetType;
typedef std::vector<SVFGlobalValue*> AliasSetType;
typedef std::vector<SVFConstant*> ConstantType;
typedef std::vector<SVFOtherValue*> OtherValueType;
typedef std::vector<const CallGraphNode*> CallGraphNodeSetType;

/// Iterators type def
typedef FunctionSetType::iterator iterator;
typedef FunctionSetType::const_iterator const_iterator;
typedef GlobalSetType::iterator global_iterator;
typedef GlobalSetType::const_iterator const_global_iterator;
typedef AliasSetType::iterator alias_iterator;
Expand All @@ -68,7 +65,6 @@ class SVFModule
static SVFModule* svfModule;
static std::string pagReadFromTxt;
std::string moduleIdentifier;
FunctionSetType FunctionSet; ///< The Functions in the module
GlobalSetType GlobalSet; ///< The Global Variables in the module
AliasSetType AliasSet; ///< The Aliases in the module
ConstantType ConstantSet; ///< The ConstantData in the module
Expand Down Expand Up @@ -104,15 +100,9 @@ class SVFModule
return !pagReadFromTxt.empty();
}

const SVFFunction* getSVFFunction(const std::string& name);

const CallGraphNode* getCallGraphNode(const std::string& name);

///@{
inline void addFunctionSet(SVFFunction* svfFunc)
{
FunctionSet.push_back(svfFunc);
}
inline void addCallGraphNode(CallGraphNode* cgn)
{
CallGraphNodeSet.push_back(cgn);
Expand Down Expand Up @@ -140,22 +130,6 @@ class SVFModule

/// Iterators
///@{
iterator begin()
{
return FunctionSet.begin();
}
const_iterator begin() const
{
return FunctionSet.begin();
}
iterator end()
{
return FunctionSet.end();
}
const_iterator end() const
{
return FunctionSet.end();
}

callgraphnode_iterator callgraphnode_begin()
{
Expand Down Expand Up @@ -240,10 +214,6 @@ class SVFModule
}
}

inline const FunctionSetType& getFunctionSet() const
{
return FunctionSet;
}
inline const CallGraphNodeSetType& getCallGraphNodeSet() const
{
return CallGraphNodeSet;
Expand Down
16 changes: 8 additions & 8 deletions svf/include/Util/SVFUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

namespace SVF
{

class CallGraphNode;
/*
* Util class to assist pointer analysis
*/
Expand Down Expand Up @@ -337,23 +337,23 @@ inline bool isProgEntryFunction(const SVFFunction* fun)
/// Get program entry function from module.
inline const SVFFunction* getProgFunction(SVFModule* svfModule, const std::string& funName)
{
for (SVFModule::const_iterator it = svfModule->begin(), eit = svfModule->end(); it != eit; ++it)
for (SVFModule::const_callgraphnode_iterator it = svfModule->callgraphnode_begin(), eit = svfModule->callgraphnode_end(); it != eit; ++it)
{
const SVFFunction *fun = *it;
const CallGraphNode *fun = *it;
if (fun->getName()==funName)
return fun;
return fun->getFunction();
}
return nullptr;
}

/// Get program entry function from module.
inline const SVFFunction* getProgEntryFunction(SVFModule* svfModule)
{
for (SVFModule::const_iterator it = svfModule->begin(), eit = svfModule->end(); it != eit; ++it)
for (SVFModule::const_callgraphnode_iterator it = svfModule->callgraphnode_begin(), eit = svfModule->callgraphnode_end(); it != eit; ++it)
{
const SVFFunction *fun = *it;
if (isProgEntryFunction(fun))
return (fun);
const CallGraphNode *fun = *it;
if (isProgEntryFunction(fun->getFunction()))
return (fun->getFunction());
}
return nullptr;
}
Expand Down
6 changes: 4 additions & 2 deletions svf/lib/MemoryModel/PointerAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,9 @@ void PointerAnalysis::resolveCPPIndCalls(const CallICFGNode* cs, const PointsTo&
void PointerAnalysis::validateSuccessTests(std::string fun)
{
// check for must alias cases, whether our alias analysis produce the correct results
if (const SVFFunction* checkFun = svfMod->getSVFFunction(fun))
if (const CallGraphNode* cgn = svfMod->getCallGraphNode(fun))
{
const SVFFunction* checkFun = cgn->getFunction();
if(!checkFun->isUncalledFunction())
outs() << "[" << this->PTAName() << "] Checking " << fun << "\n";

Expand Down Expand Up @@ -567,8 +568,9 @@ void PointerAnalysis::validateSuccessTests(std::string fun)
void PointerAnalysis::validateExpectedFailureTests(std::string fun)
{

if (const SVFFunction* checkFun = svfMod->getSVFFunction(fun))
if (const CallGraphNode* cgn = svfMod->getCallGraphNode(fun))
{
const SVFFunction* checkFun = cgn->getFunction();
if(!checkFun->isUncalledFunction())
outs() << "[" << this->PTAName() << "] Checking " << fun << "\n";

Expand Down
4 changes: 2 additions & 2 deletions svf/lib/SVFIR/SVFFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,8 @@ SVFModuleWriter::SVFModuleWriter(const SVFModule* svfModule)
{
stInfoPool.saveID(stInfo);
}

svfValuePool.reserve(svfModule->getFunctionSet().size() +
//TODO:HWG
svfValuePool.reserve(svfModule->getCallGraphNodeSet().size() +
svfModule->getConstantSet().size() +
svfModule->getOtherValueSet().size());
}
Expand Down
13 changes: 0 additions & 13 deletions svf/lib/SVFIR/SVFModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ SVFModule* SVFModule::svfModule = nullptr;

SVFModule::~SVFModule()
{
for (const SVFFunction* f : FunctionSet)
delete f;
for (const SVFConstant* c : ConstantSet)
delete c;
for (const SVFValue* o : OtherValueSet)
Expand All @@ -48,17 +46,6 @@ SVFModule::~SVFModule()
ExtAPI::destory();
}

const SVFFunction* SVFModule::getSVFFunction(const std::string& name)
{
for (const SVFFunction* fun : getFunctionSet())
{
if (fun->getName() == name)
{
return fun;
}
}
return nullptr;
}

const CallGraphNode* SVFModule::getCallGraphNode(const std::string& name)
{
Expand Down
1 change: 1 addition & 0 deletions svf/lib/Util/SVFUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "Util/Options.h"
#include "Util/SVFUtil.h"
#include "MemoryModel/PointsTo.h"
#include "Graphs/CallGraph.h"

#include <sys/resource.h> /// increase stack size

Expand Down

0 comments on commit c3aaf52

Please sign in to comment.