svf-tools 1.0.1014 → 1.0.1015
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/svf/include/AE/Svfexe/AbstractInterpretation.h +2 -2
- package/svf/include/Graphs/CallGraph.h +2 -0
- package/svf/include/SVFIR/SVFValue.h +12 -1
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +21 -17
- package/svf/lib/Graphs/CallGraph.cpp +10 -0
- package/svf-llvm/include/SVF-LLVM/LLVMModule.h +1 -1
- package/svf-llvm/lib/LLVMModule.cpp +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1015",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -251,8 +251,8 @@ private:
|
|
|
251
251
|
AEStat* stat;
|
|
252
252
|
|
|
253
253
|
std::vector<const CallICFGNode*> callSiteStack;
|
|
254
|
-
Map<const
|
|
255
|
-
Set<const
|
|
254
|
+
Map<const CallGraphNode*, ICFGWTO*> funcToWTO;
|
|
255
|
+
Set<const CallGraphNode*> recursiveFuns;
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
AbstractState& getAbsStateFromTrace(const ICFGNode* node)
|
|
@@ -40,7 +40,7 @@ namespace SVF
|
|
|
40
40
|
/// LLVM Aliases and constants
|
|
41
41
|
typedef SVF::GraphPrinter GraphPrinter;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
class CallGraphNode;
|
|
44
44
|
class SVFInstruction;
|
|
45
45
|
class SVFBasicBlock;
|
|
46
46
|
class SVFArgument;
|
|
@@ -320,8 +320,14 @@ private:
|
|
|
320
320
|
std::vector<const SVFBasicBlock*> allBBs; /// all BasicBlocks of this function
|
|
321
321
|
std::vector<const SVFArgument*> allArgs; /// all formal arguments of this function
|
|
322
322
|
SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
|
|
323
|
+
const CallGraphNode *callGraphNode; /// call graph node for this function
|
|
323
324
|
|
|
324
325
|
protected:
|
|
326
|
+
inline void setCallGraphNode(CallGraphNode *cgn)
|
|
327
|
+
{
|
|
328
|
+
callGraphNode = cgn;
|
|
329
|
+
}
|
|
330
|
+
|
|
325
331
|
///@{ attributes to be set only through Module builders e.g., LLVMModule
|
|
326
332
|
inline void addBasicBlock(const SVFBasicBlock* bb)
|
|
327
333
|
{
|
|
@@ -354,6 +360,11 @@ public:
|
|
|
354
360
|
SVFFunction(void) = delete;
|
|
355
361
|
virtual ~SVFFunction();
|
|
356
362
|
|
|
363
|
+
inline const CallGraphNode* getCallGraphNode() const
|
|
364
|
+
{
|
|
365
|
+
return callGraphNode;
|
|
366
|
+
}
|
|
367
|
+
|
|
357
368
|
static inline bool classof(const SVFValue *node)
|
|
358
369
|
{
|
|
359
370
|
return node->getKind() == SVFFunc;
|
|
@@ -84,24 +84,19 @@ void AbstractInterpretation::initWTO()
|
|
|
84
84
|
// Detect if the call graph has cycles by finding its strongly connected components (SCC)
|
|
85
85
|
Andersen::CallGraphSCC* callGraphScc = ander->getCallGraphSCC();
|
|
86
86
|
callGraphScc->find();
|
|
87
|
-
|
|
87
|
+
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
|
|
88
88
|
|
|
89
89
|
// Iterate through the call graph
|
|
90
|
-
for (auto it =
|
|
90
|
+
for (auto it = svfirCallGraph->begin(); it != svfirCallGraph->end(); it++)
|
|
91
91
|
{
|
|
92
92
|
// Check if the current function is part of a cycle
|
|
93
93
|
if (callGraphScc->isInCycle(it->second->getId()))
|
|
94
|
-
recursiveFuns.insert(it->second
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// Initialize WTO for each function in the module
|
|
98
|
-
for (const SVFFunction* fun : svfir->getModule()->getFunctionSet())
|
|
99
|
-
{
|
|
100
|
-
if(fun->isDeclaration())
|
|
94
|
+
recursiveFuns.insert(it->second); // Mark the function as recursive
|
|
95
|
+
if (it->second->getFunction()->isDeclaration())
|
|
101
96
|
continue;
|
|
102
|
-
auto* wto = new ICFGWTO(icfg, icfg->getFunEntryICFGNode(
|
|
97
|
+
auto* wto = new ICFGWTO(icfg, icfg->getFunEntryICFGNode(it->second->getFunction()));
|
|
103
98
|
wto->init();
|
|
104
|
-
funcToWTO[
|
|
99
|
+
funcToWTO[it->second] = wto;
|
|
105
100
|
}
|
|
106
101
|
}
|
|
107
102
|
/// Program entry
|
|
@@ -112,9 +107,9 @@ void AbstractInterpretation::analyse()
|
|
|
112
107
|
handleGlobalNode();
|
|
113
108
|
getAbsStateFromTrace(
|
|
114
109
|
icfg->getGlobalICFGNode())[PAG::getPAG()->getBlkPtr()] = IntervalValue::top();
|
|
115
|
-
if (const
|
|
110
|
+
if (const CallGraphNode* cgn = svfir->getCallGraph()->getCallGraphNode("main"))
|
|
116
111
|
{
|
|
117
|
-
ICFGWTO* wto = funcToWTO[
|
|
112
|
+
ICFGWTO* wto = funcToWTO[cgn];
|
|
118
113
|
handleWTOComponents(wto->getWTOComponents());
|
|
119
114
|
}
|
|
120
115
|
}
|
|
@@ -586,7 +581,11 @@ void AbstractInterpretation::extCallPass(const SVF::CallICFGNode *callNode)
|
|
|
586
581
|
|
|
587
582
|
bool AbstractInterpretation::isRecursiveCall(const SVF::CallICFGNode *callNode)
|
|
588
583
|
{
|
|
589
|
-
|
|
584
|
+
const SVFFunction *callfun = callNode->getCalledFunction();
|
|
585
|
+
if (!callfun)
|
|
586
|
+
return false;
|
|
587
|
+
else
|
|
588
|
+
return recursiveFuns.find(callfun->getCallGraphNode()) != recursiveFuns.end();
|
|
590
589
|
}
|
|
591
590
|
|
|
592
591
|
void AbstractInterpretation::recursiveCallPass(const SVF::CallICFGNode *callNode)
|
|
@@ -610,7 +609,11 @@ void AbstractInterpretation::recursiveCallPass(const SVF::CallICFGNode *callNode
|
|
|
610
609
|
|
|
611
610
|
bool AbstractInterpretation::isDirectCall(const SVF::CallICFGNode *callNode)
|
|
612
611
|
{
|
|
613
|
-
|
|
612
|
+
const SVFFunction *callfun =callNode->getCalledFunction();
|
|
613
|
+
if (!callfun)
|
|
614
|
+
return false;
|
|
615
|
+
else
|
|
616
|
+
return funcToWTO.find(callfun->getCallGraphNode()) != funcToWTO.end();
|
|
614
617
|
}
|
|
615
618
|
void AbstractInterpretation::directCallFunPass(const SVF::CallICFGNode *callNode)
|
|
616
619
|
{
|
|
@@ -619,7 +622,8 @@ void AbstractInterpretation::directCallFunPass(const SVF::CallICFGNode *callNode
|
|
|
619
622
|
|
|
620
623
|
abstractTrace[callNode] = as;
|
|
621
624
|
|
|
622
|
-
|
|
625
|
+
const SVFFunction *callfun =callNode->getCalledFunction();
|
|
626
|
+
ICFGWTO* wto = funcToWTO[callfun->getCallGraphNode()];
|
|
623
627
|
handleWTOComponents(wto->getWTOComponents());
|
|
624
628
|
|
|
625
629
|
callSiteStack.pop_back();
|
|
@@ -649,7 +653,7 @@ void AbstractInterpretation::indirectCallFunPass(const SVF::CallICFGNode *callNo
|
|
|
649
653
|
SVFVar *func_var = svfir->getGNode(AbstractState::getInternalID(addr));
|
|
650
654
|
if(const FunObjVar*funObjVar = SVFUtil::dyn_cast<FunObjVar>(func_var))
|
|
651
655
|
{
|
|
652
|
-
const
|
|
656
|
+
const CallGraphNode* callfun = funObjVar->getCallGraphNode();
|
|
653
657
|
callSiteStack.push_back(callNode);
|
|
654
658
|
abstractTrace[callNode] = as;
|
|
655
659
|
|
|
@@ -143,6 +143,16 @@ void CallGraph::view()
|
|
|
143
143
|
SVF::ViewGraph(this, "Call Graph");
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
const CallGraphNode* CallGraph::getCallGraphNode(const std::string& name)
|
|
147
|
+
{
|
|
148
|
+
for (const auto& item : *this)
|
|
149
|
+
{
|
|
150
|
+
if (item.second->getName() == name)
|
|
151
|
+
return item.second;
|
|
152
|
+
}
|
|
153
|
+
return nullptr;
|
|
154
|
+
}
|
|
155
|
+
|
|
146
156
|
namespace SVF
|
|
147
157
|
{
|
|
148
158
|
|
|
@@ -172,7 +172,7 @@ public:
|
|
|
172
172
|
LLVMFunc2SVFFunc[func] = svfFunc;
|
|
173
173
|
setValueAttr(func,svfFunc);
|
|
174
174
|
}
|
|
175
|
-
void addFunctionMap(const Function* func, CallGraphNode*
|
|
175
|
+
void addFunctionMap(const Function* func, CallGraphNode* cgNode);
|
|
176
176
|
|
|
177
177
|
inline void addBasicBlockMap(const BasicBlock* bb, SVFBasicBlock* svfBB)
|
|
178
178
|
{
|
|
@@ -169,11 +169,18 @@ void LLVMModuleSet::build()
|
|
|
169
169
|
|
|
170
170
|
createSVFDataStructure();
|
|
171
171
|
initSVFFunction();
|
|
172
|
+
|
|
173
|
+
|
|
172
174
|
ICFGBuilder icfgbuilder;
|
|
173
175
|
icfg = icfgbuilder.build();
|
|
174
176
|
|
|
175
177
|
CallGraphBuilder callGraphBuilder;
|
|
176
178
|
callgraph = callGraphBuilder.buildSVFIRCallGraph(svfModule);
|
|
179
|
+
for (const auto& func : svfModule->getFunctionSet())
|
|
180
|
+
{
|
|
181
|
+
SVFFunction* svffunc = const_cast<SVFFunction*>(func);
|
|
182
|
+
svffunc->setCallGraphNode(callgraph->getCallGraphNode(func));
|
|
183
|
+
}
|
|
177
184
|
|
|
178
185
|
for (const auto& it : *callgraph)
|
|
179
186
|
{
|
|
@@ -1217,10 +1224,10 @@ void LLVMModuleSet::dumpModulesToFile(const std::string& suffix)
|
|
|
1217
1224
|
}
|
|
1218
1225
|
}
|
|
1219
1226
|
|
|
1220
|
-
void LLVMModuleSet::addFunctionMap(const SVF::Function* func, SVF::CallGraphNode*
|
|
1227
|
+
void LLVMModuleSet::addFunctionMap(const SVF::Function* func, SVF::CallGraphNode* cgNode)
|
|
1221
1228
|
{
|
|
1222
|
-
LLVMFunc2CallGraphNode[func] =
|
|
1223
|
-
setValueAttr(func,
|
|
1229
|
+
LLVMFunc2CallGraphNode[func] = cgNode;
|
|
1230
|
+
setValueAttr(func, cgNode);
|
|
1224
1231
|
}
|
|
1225
1232
|
|
|
1226
1233
|
void LLVMModuleSet::setValueAttr(const Value* val, SVFValue* svfvalue)
|