svf-tools 1.0.1065 → 1.0.1066

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.1065",
3
+ "version": "1.0.1066",
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": {
@@ -194,7 +194,7 @@ public:
194
194
  }
195
195
 
196
196
  /// Return TRUE if this function can be reached from main.
197
- bool isReachableFromProgEntry() const;
197
+ bool isReachableFromProgEntry(Map<NodeID, bool> &reachableFromEntry, NodeBS &visitedNodes) const;
198
198
 
199
199
 
200
200
  /// Overloading operator << for dumping ICFG node ID
@@ -30,6 +30,7 @@
30
30
 
31
31
  #include "Graphs/CallGraph.h"
32
32
  #include "SVFIR/SVFIR.h"
33
+ #include "Util/Options.h"
33
34
  #include "Util/SVFUtil.h"
34
35
  #include <sstream>
35
36
 
@@ -89,30 +90,29 @@ const FunObjVar *CallGraph::getCallerOfCallSite(CallSiteID id) const
89
90
  return getCallSite(id)->getCaller();
90
91
  }
91
92
 
92
- bool CallGraphNode::isReachableFromProgEntry() const
93
+ bool CallGraphNode::isReachableFromProgEntry(Map<NodeID, bool> &reachableFromEntry, NodeBS &visitedNodes) const
93
94
  {
94
- std::stack<const CallGraphNode*> nodeStack;
95
- NodeBS visitedNodes;
96
- nodeStack.push(this);
97
- visitedNodes.set(getId());
98
-
99
- while (nodeStack.empty() == false)
100
- {
101
- CallGraphNode* node = const_cast<CallGraphNode*>(nodeStack.top());
102
- nodeStack.pop();
95
+ std::function<bool(const CallGraphNode*)> dfs =
96
+ [&reachableFromEntry, &visitedNodes, &dfs](const CallGraphNode *v) {
97
+ NodeID id = v->getId();
98
+ if (!visitedNodes.test_and_set(id))
99
+ return reachableFromEntry[id];
103
100
 
104
- if (SVFUtil::isProgEntryFunction(node->getFunction()))
105
- return true;
101
+ if (SVFUtil::isProgEntryFunction(v->getFunction()))
102
+ return reachableFromEntry[id] = true;
106
103
 
107
- for (const_iterator it = node->InEdgeBegin(), eit = node->InEdgeEnd(); it != eit; ++it)
104
+ bool result = false;
105
+ for (const_iterator it = v->InEdgeBegin(), eit = v->InEdgeEnd(); it != eit; ++it)
108
106
  {
109
107
  CallGraphEdge* edge = *it;
110
- if (visitedNodes.test_and_set(edge->getSrcID()))
111
- nodeStack.push(edge->getSrcNode());
108
+ result |= dfs(edge->getSrcNode());
109
+ if (result)
110
+ break;
112
111
  }
113
- }
112
+ return reachableFromEntry[id] = result;
113
+ };
114
114
 
115
- return false;
115
+ return dfs(this);
116
116
  }
117
117
 
118
118
 
@@ -285,6 +285,11 @@ void CallGraph::getIndCallSitesInvokingCallee(const FunObjVar* callee, CallGraph
285
285
  */
286
286
  void CallGraph::verifyCallGraph()
287
287
  {
288
+ if (Options::DisableWarn())
289
+ return;
290
+
291
+ Map<NodeID, bool> reachableFromEntry;
292
+ NodeBS visitedNodes;
288
293
  CallEdgeMap::const_iterator it = indirectCallMap.begin();
289
294
  CallEdgeMap::const_iterator eit = indirectCallMap.end();
290
295
  for (; it != eit; ++it)
@@ -294,7 +299,8 @@ void CallGraph::verifyCallGraph()
294
299
  {
295
300
  const CallICFGNode* cs = it->first;
296
301
  const FunObjVar* func = cs->getCaller();
297
- if (getCallGraphNode(func)->isReachableFromProgEntry() == false)
302
+ if (getCallGraphNode(func)->
303
+ isReachableFromProgEntry(reachableFromEntry, visitedNodes) == false)
298
304
  writeWrnMsg(func->getName() + " has indirect call site but not reachable from main");
299
305
  }
300
306
  }
@@ -206,7 +206,8 @@ void LLVMModuleSet::createSVFDataStructure()
206
206
  }
207
207
 
208
208
  // set function exit block
209
- for (const auto& func: funSet) {
209
+ for (const auto& func: funSet)
210
+ {
210
211
  for (Function::const_iterator bit = func->begin(), ebit = func->end(); bit != ebit; ++bit)
211
212
  {
212
213
  const BasicBlock* bb = &*bit;