svf-tools 1.0.1042 → 1.0.1043

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.
Files changed (98) hide show
  1. package/package.json +1 -1
  2. package/svf/include/AE/Svfexe/AbstractInterpretation.h +2 -2
  3. package/svf/include/CFL/CFLAlias.h +1 -1
  4. package/svf/include/DDA/ContextDDA.h +6 -6
  5. package/svf/include/DDA/DDAVFSolver.h +2 -2
  6. package/svf/include/DDA/FlowDDA.h +2 -2
  7. package/svf/include/Graphs/BasicBlockG.h +17 -9
  8. package/svf/include/Graphs/CHG.h +7 -7
  9. package/svf/include/Graphs/CallGraph.h +23 -27
  10. package/svf/include/Graphs/ConsG.h +2 -2
  11. package/svf/include/Graphs/ICFG.h +11 -11
  12. package/svf/include/Graphs/ICFGNode.h +12 -18
  13. package/svf/include/Graphs/IRGraph.h +11 -9
  14. package/svf/include/Graphs/SVFG.h +13 -13
  15. package/svf/include/Graphs/SVFGNode.h +2 -2
  16. package/svf/include/Graphs/ThreadCallGraph.h +3 -21
  17. package/svf/include/Graphs/VFG.h +15 -15
  18. package/svf/include/Graphs/VFGNode.h +10 -10
  19. package/svf/include/MSSA/MSSAMuChi.h +6 -6
  20. package/svf/include/MSSA/MemPartition.h +12 -12
  21. package/svf/include/MSSA/MemRegion.h +21 -21
  22. package/svf/include/MSSA/MemSSA.h +10 -10
  23. package/svf/include/MTA/LockAnalysis.h +4 -4
  24. package/svf/include/MTA/MHP.h +8 -8
  25. package/svf/include/MTA/TCT.h +10 -10
  26. package/svf/include/MemoryModel/PointerAnalysis.h +4 -4
  27. package/svf/include/SABER/DoubleFreeChecker.h +2 -2
  28. package/svf/include/SABER/FileChecker.h +2 -2
  29. package/svf/include/SABER/LeakChecker.h +4 -4
  30. package/svf/include/SABER/SaberCheckerAPI.h +6 -5
  31. package/svf/include/SABER/SaberCondAllocator.h +5 -5
  32. package/svf/include/SABER/SrcSnkDDA.h +2 -2
  33. package/svf/include/SVFIR/SVFIR.h +20 -27
  34. package/svf/include/SVFIR/SVFValue.h +3 -2
  35. package/svf/include/SVFIR/SVFVariables.h +271 -71
  36. package/svf/include/Util/CDGBuilder.h +1 -1
  37. package/svf/include/Util/CallGraphBuilder.h +1 -1
  38. package/svf/include/Util/CxtStmt.h +6 -6
  39. package/svf/include/Util/ExtAPI.h +20 -16
  40. package/svf/include/Util/SVFUtil.h +16 -30
  41. package/svf/include/Util/ThreadAPI.h +2 -11
  42. package/svf/include/WPA/Andersen.h +2 -2
  43. package/svf/lib/AE/Svfexe/AEDetector.cpp +1 -1
  44. package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +3 -3
  45. package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +6 -6
  46. package/svf/lib/CFL/CFLAlias.cpp +1 -1
  47. package/svf/lib/DDA/ContextDDA.cpp +5 -5
  48. package/svf/lib/DDA/DDAClient.cpp +2 -2
  49. package/svf/lib/DDA/DDAPass.cpp +6 -6
  50. package/svf/lib/DDA/FlowDDA.cpp +5 -5
  51. package/svf/lib/Graphs/CHG.cpp +2 -2
  52. package/svf/lib/Graphs/CallGraph.cpp +21 -11
  53. package/svf/lib/Graphs/ICFG.cpp +15 -6
  54. package/svf/lib/Graphs/IRGraph.cpp +7 -7
  55. package/svf/lib/Graphs/SVFG.cpp +4 -4
  56. package/svf/lib/Graphs/ThreadCallGraph.cpp +26 -5
  57. package/svf/lib/Graphs/VFG.cpp +6 -6
  58. package/svf/lib/MSSA/MemPartition.cpp +8 -8
  59. package/svf/lib/MSSA/MemRegion.cpp +13 -13
  60. package/svf/lib/MSSA/MemSSA.cpp +9 -8
  61. package/svf/lib/MSSA/SVFGBuilder.cpp +1 -1
  62. package/svf/lib/MTA/LockAnalysis.cpp +13 -12
  63. package/svf/lib/MTA/MHP.cpp +12 -12
  64. package/svf/lib/MTA/MTA.cpp +2 -1
  65. package/svf/lib/MTA/MTAStat.cpp +4 -3
  66. package/svf/lib/MTA/TCT.cpp +18 -18
  67. package/svf/lib/MemoryModel/PointerAnalysis.cpp +7 -7
  68. package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +1 -1
  69. package/svf/lib/SABER/DoubleFreeChecker.cpp +3 -3
  70. package/svf/lib/SABER/LeakChecker.cpp +5 -5
  71. package/svf/lib/SABER/SaberCondAllocator.cpp +6 -6
  72. package/svf/lib/SABER/SaberSVFGBuilder.cpp +1 -1
  73. package/svf/lib/SVFIR/SVFIR.cpp +14 -0
  74. package/svf/lib/SVFIR/SVFVariables.cpp +50 -19
  75. package/svf/lib/Util/CDGBuilder.cpp +4 -4
  76. package/svf/lib/Util/CallGraphBuilder.cpp +3 -3
  77. package/svf/lib/Util/ExtAPI.cpp +28 -29
  78. package/svf/lib/Util/SVFBugReport.cpp +1 -1
  79. package/svf/lib/Util/SVFStat.cpp +2 -2
  80. package/svf/lib/Util/SVFUtil.cpp +22 -4
  81. package/svf/lib/Util/ThreadAPI.cpp +15 -3
  82. package/svf/lib/WPA/Andersen.cpp +2 -2
  83. package/svf/lib/WPA/FlowSensitive.cpp +2 -2
  84. package/svf/lib/WPA/TypeAnalysis.cpp +3 -3
  85. package/svf/lib/WPA/VersionedFlowSensitive.cpp +1 -1
  86. package/svf/lib/WPA/WPAPass.cpp +2 -2
  87. package/svf-llvm/include/SVF-LLVM/LLVMModule.h +83 -7
  88. package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +9 -1
  89. package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +5 -2
  90. package/svf-llvm/lib/CHGBuilder.cpp +12 -12
  91. package/svf-llvm/lib/DCHG.cpp +3 -3
  92. package/svf-llvm/lib/ICFGBuilder.cpp +8 -8
  93. package/svf-llvm/lib/LLVMLoopAnalysis.cpp +1 -1
  94. package/svf-llvm/lib/LLVMModule.cpp +126 -11
  95. package/svf-llvm/lib/LLVMUtil.cpp +34 -9
  96. package/svf-llvm/lib/SVFIRBuilder.cpp +183 -99
  97. package/svf-llvm/lib/SVFIRExtAPI.cpp +4 -4
  98. package/svf-llvm/lib/SymbolTableBuilder.cpp +10 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.1042",
3
+ "version": "1.0.1043",
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 SVFFunction*, ICFGWTO*> funcToWTO;
255
- Set<const SVFFunction*> recursiveFuns;
254
+ Map<const FunObjVar*, ICFGWTO*> funcToWTO;
255
+ Set<const FunObjVar*> recursiveFuns;
256
256
 
257
257
 
258
258
  AbstractState& getAbsStateFromTrace(const ICFGNode* node)
@@ -135,7 +135,7 @@ public:
135
135
  virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap& callsites, CallEdgeMap& newEdges);
136
136
 
137
137
  /// Connect formal and actual parameters for indirect callsites
138
- void connectCaller2CalleeParams(const CallICFGNode* cs, const SVFFunction* F);
138
+ void connectCaller2CalleeParams(const CallICFGNode* cs, const FunObjVar* F);
139
139
 
140
140
  void heapAllocatorViaIndCall(const CallICFGNode* cs);
141
141
 
@@ -110,7 +110,7 @@ public:
110
110
  virtual bool isHeapCondMemObj(const CxtVar& var, const StoreSVFGNode* store) override;
111
111
 
112
112
  /// refine indirect call edge
113
- bool testIndCallReachability(CxtLocDPItem& dpm, const SVFFunction* callee, const CallICFGNode* cs);
113
+ bool testIndCallReachability(CxtLocDPItem& dpm, const FunObjVar* callee, const CallICFGNode* cs);
114
114
 
115
115
  /// get callsite id from call, return 0 if it is a spurious call edge
116
116
  CallSiteID getCSIDAtCall(CxtLocDPItem& dpm, const SVFGEdge* edge);
@@ -133,8 +133,8 @@ public:
133
133
  /// Whether call/return inside recursion
134
134
  inline virtual bool isEdgeInRecursion(CallSiteID csId)
135
135
  {
136
- const SVFFunction* caller = getCallGraph()->getCallerOfCallSite(csId);
137
- const SVFFunction* callee = getCallGraph()->getCalleeOfCallSite(csId);
136
+ const FunObjVar* caller = getCallGraph()->getCallerOfCallSite(csId);
137
+ const FunObjVar* callee = getCallGraph()->getCalleeOfCallSite(csId);
138
138
  return inSameCallGraphSCC(caller, callee);
139
139
  }
140
140
  /// Update call graph.
@@ -149,7 +149,7 @@ public:
149
149
  const FunctionSet & functions = iter->second;
150
150
  for (FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
151
151
  {
152
- const SVFFunction* func = *func_iter;
152
+ const FunObjVar* func = *func_iter;
153
153
  getSVFG()->connectCallerAndCallee(newcs, func, svfgEdges);
154
154
  }
155
155
  }
@@ -159,8 +159,8 @@ public:
159
159
  /// Return TRUE if this edge is inside a SVFG SCC, i.e., src node and dst node are in the same SCC on the SVFG.
160
160
  inline bool edgeInCallGraphSCC(const SVFGEdge* edge)
161
161
  {
162
- const SVFFunction* srcfun = edge->getSrcNode()->getFun();
163
- const SVFFunction* dstfun = edge->getDstNode()->getFun();
162
+ const FunObjVar* srcfun = edge->getSrcNode()->getFun();
163
+ const FunObjVar* dstfun = edge->getDstNode()->getFun();
164
164
 
165
165
  if(srcfun && dstfun)
166
166
  return inSameCallGraphSCC(srcfun,dstfun);
@@ -475,7 +475,7 @@ protected:
475
475
  assert(baseObj && "base object is null??");
476
476
  if(SVFUtil::isa<StackObjVar>(baseObj))
477
477
  {
478
- if(const SVFFunction* svffun = _pag->getGNode(id)->getFunction())
478
+ if(const FunObjVar* svffun = _pag->getGNode(id)->getFunction())
479
479
  {
480
480
  return _callGraphSCC->isInCycle(_callGraph->getCallGraphNode(svffun)->getId());
481
481
  }
@@ -501,7 +501,7 @@ protected:
501
501
  findPT(funPtrDpm);
502
502
  }
503
503
  }
504
- else if(const SVFFunction* fun = getSVFG()->isFunEntrySVFGNode(dpm.getLoc()))
504
+ else if(const FunObjVar* fun = getSVFG()->isFunEntrySVFGNode(dpm.getLoc()))
505
505
  {
506
506
  CallInstSet csSet;
507
507
  /// use pre-analysis call graph to approximate all potential callsites
@@ -80,7 +80,7 @@ public:
80
80
  virtual bool handleBKCondition(LocDPItem& dpm, const SVFGEdge* edge) override;
81
81
 
82
82
  /// refine indirect call edge
83
- bool testIndCallReachability(LocDPItem& dpm, const SVFFunction* callee, CallSiteID csId);
83
+ bool testIndCallReachability(LocDPItem& dpm, const FunObjVar* callee, CallSiteID csId);
84
84
 
85
85
  /// Initialization of the analysis
86
86
  inline virtual void initialize() override
@@ -142,7 +142,7 @@ public:
142
142
  const FunctionSet & functions = iter->second;
143
143
  for (FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
144
144
  {
145
- const SVFFunction* func = *func_iter;
145
+ const FunObjVar* func = *func_iter;
146
146
  getSVFG()->connectCallerAndCallee(newcs, func, svfgEdges);
147
147
  }
148
148
  }
@@ -39,7 +39,8 @@ namespace SVF
39
39
  class SVFBasicBlock;
40
40
  class BasicBlockEdge;
41
41
  class ICFGNode;
42
- class SVFFunction;
42
+ class FunObjVar;
43
+
43
44
  typedef GenericEdge<SVFBasicBlock> GenericBasicBlockEdgeTy;
44
45
  class BasicBlockEdge: public GenericBasicBlockEdgeTy
45
46
  {
@@ -75,7 +76,7 @@ class SVFBasicBlock : public GenericBasicBlockNodeTy
75
76
  friend class SVFIRWriter;
76
77
  friend class SVFIRReader;
77
78
  friend class SVFIRBuilder;
78
- friend class SVFFunction;
79
+ friend class FunObjVar;
79
80
  friend class ICFGBuilder;
80
81
  friend class ICFG;
81
82
 
@@ -86,7 +87,7 @@ public:
86
87
 
87
88
  private:
88
89
  std::vector<const ICFGNode*> allICFGNodes; ///< all ICFGNodes in this BasicBlock
89
- const SVFFunction* fun; /// Function where this BasicBlock is
90
+ const FunObjVar* fun; /// Function where this BasicBlock is
90
91
 
91
92
 
92
93
 
@@ -104,7 +105,7 @@ protected:
104
105
 
105
106
  public:
106
107
  /// Constructor without name
107
- SVFBasicBlock(NodeID id, const SVFFunction* f): GenericBasicBlockNodeTy(id, BasicBlockKd), fun(f)
108
+ SVFBasicBlock(NodeID id, const FunObjVar* f): GenericBasicBlockNodeTy(id, BasicBlockKd), fun(f)
108
109
  {
109
110
 
110
111
  }
@@ -148,6 +149,12 @@ public:
148
149
  return allICFGNodes.end();
149
150
  }
150
151
 
152
+
153
+ inline void setFun(const FunObjVar* f)
154
+ {
155
+ fun = f;
156
+ }
157
+
151
158
  inline void addSuccBasicBlock(const SVFBasicBlock* succ2)
152
159
  {
153
160
  // check if the edge already exists
@@ -181,13 +188,15 @@ public:
181
188
  pred->succBBs.push_back(this);
182
189
  }
183
190
 
184
- inline const SVFFunction* getParent() const
191
+ inline const FunObjVar* getParent() const
185
192
  {
193
+ assert(fun && "Function is null?");
186
194
  return fun;
187
195
  }
188
196
 
189
- inline const SVFFunction* getFunction() const
197
+ inline const FunObjVar* getFunction() const
190
198
  {
199
+ assert(fun && "Function is null?");
191
200
  return fun;
192
201
  }
193
202
 
@@ -287,10 +296,9 @@ class BasicBlockGraph: public GenericBasicBlockGraphTy
287
296
  {
288
297
  private:
289
298
  NodeID id{0};
290
- const SVFFunction* fun;
291
299
  public:
292
300
  /// Constructor
293
- BasicBlockGraph(const SVFFunction* f): fun(f)
301
+ BasicBlockGraph()
294
302
  {
295
303
 
296
304
  }
@@ -298,7 +306,7 @@ public:
298
306
  SVFBasicBlock* addBasicBlock(const std::string& bbname)
299
307
  {
300
308
  id++;
301
- SVFBasicBlock* bb = new SVFBasicBlock(id, fun);
309
+ SVFBasicBlock* bb = new SVFBasicBlock(id, nullptr);
302
310
  addGNode(id, bb);
303
311
  bb->setName(bbname);
304
312
  return bb;
@@ -45,7 +45,7 @@ class CHNode;
45
45
  class GlobalObjVar;
46
46
 
47
47
  typedef Set<const GlobalObjVar*> VTableSet;
48
- typedef Set<const SVFFunction*> VFunSet;
48
+ typedef Set<const FunObjVar*> VFunSet;
49
49
 
50
50
  /// Common base for class hierarchy graph. Only implements what PointerAnalysis needs.
51
51
  class CommonCHGraph
@@ -119,7 +119,7 @@ public:
119
119
  TEMPLATE = 0x04 // template class
120
120
  } CLASSATTR;
121
121
 
122
- typedef std::vector<const SVFFunction*> FuncVector;
122
+ typedef std::vector<const FunObjVar*> FuncVector;
123
123
 
124
124
  CHNode (const std::string& name, NodeID i = 0, GNodeK k = CHNodeKd):
125
125
  GenericCHNodeTy(i, k), vtable(nullptr), className(name), flags(0)
@@ -267,18 +267,18 @@ public:
267
267
  void view();
268
268
  void printCH();
269
269
 
270
- inline u32_t getVirtualFunctionID(const SVFFunction* vfn) const
270
+ inline u32_t getVirtualFunctionID(const FunObjVar* vfn) const
271
271
  {
272
- Map<const SVFFunction*, u32_t>::const_iterator it =
272
+ Map<const FunObjVar*, u32_t>::const_iterator it =
273
273
  virtualFunctionToIDMap.find(vfn);
274
274
  if (it != virtualFunctionToIDMap.end())
275
275
  return it->second;
276
276
  else
277
277
  return -1;
278
278
  }
279
- inline const SVFFunction* getVirtualFunctionBasedonID(u32_t id) const
279
+ inline const FunObjVar* getVirtualFunctionBasedonID(u32_t id) const
280
280
  {
281
- Map<const SVFFunction*, u32_t>::const_iterator it, eit;
281
+ Map<const FunObjVar*, u32_t>::const_iterator it, eit;
282
282
  for (it = virtualFunctionToIDMap.begin(), eit =
283
283
  virtualFunctionToIDMap.end(); it != eit; ++it)
284
284
  {
@@ -329,7 +329,7 @@ private:
329
329
  NameToCHNodesMap templateNameToInstancesMap;
330
330
  CallNodeToCHNodesMap callNodeToClassesMap;
331
331
 
332
- Map<const SVFFunction*, u32_t> virtualFunctionToIDMap;
332
+ Map<const FunObjVar*, u32_t> virtualFunctionToIDMap;
333
333
 
334
334
  CallNodeToVTableSetMap callNodeToCHAVtblsMap;
335
335
  CallNodeToVFunSetMap callNodeToCHAVFnsMap;
@@ -168,6 +168,8 @@ public:
168
168
 
169
169
  };
170
170
 
171
+ class FunObjVar;
172
+
171
173
  /*
172
174
  * Call Graph node representing a function
173
175
  */
@@ -175,22 +177,19 @@ typedef GenericNode<CallGraphNode, CallGraphEdge> GenericPTACallGraphNodeTy;
175
177
  class CallGraphNode : public GenericPTACallGraphNodeTy
176
178
  {
177
179
  private:
178
- const SVFFunction* fun;
180
+ const FunObjVar* fun;
179
181
 
180
182
  public:
181
183
  /// Constructor
182
- CallGraphNode(NodeID i, const SVFFunction* f) : GenericPTACallGraphNodeTy(i,CallNodeKd), fun(f)
184
+ CallGraphNode(NodeID i, const FunObjVar* f) : GenericPTACallGraphNodeTy(i,CallNodeKd), fun(f)
183
185
  {
184
186
 
185
187
  }
186
188
 
187
- inline const std::string &getName() const
188
- {
189
- return fun->getName();
190
- }
189
+ const std::string &getName() const;
191
190
 
192
191
  /// Get function of this call node
193
- inline const SVFFunction* getFunction() const
192
+ inline const FunObjVar* getFunction() const
194
193
  {
195
194
  return fun;
196
195
  }
@@ -238,12 +237,12 @@ class CallGraph : public GenericPTACallGraphTy
238
237
 
239
238
  public:
240
239
  typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
241
- typedef Map<const SVFFunction*, CallGraphNode*> FunToCallGraphNodeMap;
240
+ typedef Map<const FunObjVar*, CallGraphNode*> FunToCallGraphNodeMap;
242
241
  typedef Map<const CallICFGNode*, CallGraphEdgeSet> CallInstToCallGraphEdgesMap;
243
- typedef std::pair<const CallICFGNode*, const SVFFunction*> CallSitePair;
242
+ typedef std::pair<const CallICFGNode*, const FunObjVar*> CallSitePair;
244
243
  typedef Map<CallSitePair, CallSiteID> CallSiteToIdMap;
245
244
  typedef Map<CallSiteID, CallSitePair> IdToCallSiteMap;
246
- typedef Set<const SVFFunction*> FunctionSet;
245
+ typedef Set<const FunObjVar*> FunctionSet;
247
246
  typedef OrderedMap<const CallICFGNode*, FunctionSet> CallEdgeMap;
248
247
  typedef CallGraphEdgeSet::iterator CallGraphEdgeIter;
249
248
  typedef CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter;
@@ -275,9 +274,9 @@ protected:
275
274
 
276
275
  protected:
277
276
  /// Add CallSiteID
278
- inline CallSiteID addCallSite(const CallICFGNode* cs, const SVFFunction* callee)
277
+ inline CallSiteID addCallSite(const CallICFGNode* cs, const FunObjVar* callee)
279
278
  {
280
- std::pair<const CallICFGNode*, const SVFFunction*> newCS(std::make_pair(cs, callee));
279
+ std::pair<const CallICFGNode*, const FunObjVar*> newCS(std::make_pair(cs, callee));
281
280
  CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
282
281
  //assert(it == csToIdMap.end() && "cannot add a callsite twice");
283
282
  if(it == csToIdMap.end())
@@ -352,9 +351,9 @@ public:
352
351
  void verifyCallGraph();
353
352
 
354
353
  /// Add direct call edges
355
- void addDirectCallGraphEdge(const CallICFGNode* call, const SVFFunction* callerFun, const SVFFunction* calleeFun);
354
+ void addDirectCallGraphEdge(const CallICFGNode* call, const FunObjVar* callerFun, const FunObjVar* calleeFun);
356
355
 
357
- void addCallGraphNode(const SVFFunction* fun);
356
+ void addCallGraphNode(const FunObjVar* fun);
358
357
 
359
358
  /// Get call graph node
360
359
  //@{
@@ -365,7 +364,7 @@ public:
365
364
  {
366
365
  return getGNode(id);
367
366
  }
368
- inline CallGraphNode* getCallGraphNode(const SVFFunction* fun) const
367
+ inline CallGraphNode* getCallGraphNode(const FunObjVar* fun) const
369
368
  {
370
369
  FunToCallGraphNodeMap::const_iterator it = funToCallGraphNodeMap.find(fun);
371
370
  assert(it!=funToCallGraphNodeMap.end() && "call graph node not found!!");
@@ -376,14 +375,14 @@ public:
376
375
 
377
376
  /// Get CallSiteID
378
377
  //@{
379
- inline CallSiteID getCallSiteID(const CallICFGNode* cs, const SVFFunction* callee) const
378
+ inline CallSiteID getCallSiteID(const CallICFGNode* cs, const FunObjVar* callee) const
380
379
  {
381
380
  CallSitePair newCS(std::make_pair(cs, callee));
382
381
  CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
383
382
  assert(it != csToIdMap.end() && "callsite id not found! This maybe a partially resolved callgraph, please check the indCallEdge limit");
384
383
  return it->second;
385
384
  }
386
- inline bool hasCallSiteID(const CallICFGNode* cs, const SVFFunction* callee) const
385
+ inline bool hasCallSiteID(const CallICFGNode* cs, const FunObjVar* callee) const
387
386
  {
388
387
  CallSitePair newCS(std::make_pair(cs, callee));
389
388
  CallSiteToIdMap::const_iterator it = csToIdMap.find(newCS);
@@ -399,11 +398,8 @@ public:
399
398
  {
400
399
  return getCallSitePair(id).first;
401
400
  }
402
- inline const SVFFunction* getCallerOfCallSite(CallSiteID id) const
403
- {
404
- return getCallSite(id)->getCaller();
405
- }
406
- inline const SVFFunction* getCalleeOfCallSite(CallSiteID id) const
401
+ const FunObjVar* getCallerOfCallSite(CallSiteID id) const;
402
+ inline const FunObjVar* getCalleeOfCallSite(CallSiteID id) const
407
403
  {
408
404
  return getCallSitePair(id).second;
409
405
  }
@@ -454,18 +450,18 @@ public:
454
450
 
455
451
  /// Add indirect call edges
456
452
  //@{
457
- void addIndirectCallGraphEdge(const CallICFGNode* cs,const SVFFunction* callerFun, const SVFFunction* calleeFun);
453
+ void addIndirectCallGraphEdge(const CallICFGNode* cs,const FunObjVar* callerFun, const FunObjVar* calleeFun);
458
454
  //@}
459
455
 
460
456
  /// Get callsites invoking the callee
461
457
  //@{
462
- void getAllCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet);
463
- void getDirCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet);
464
- void getIndCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet);
458
+ void getAllCallSitesInvokingCallee(const FunObjVar* callee, CallGraphEdge::CallInstSet& csSet);
459
+ void getDirCallSitesInvokingCallee(const FunObjVar* callee, CallGraphEdge::CallInstSet& csSet);
460
+ void getIndCallSitesInvokingCallee(const FunObjVar* callee, CallGraphEdge::CallInstSet& csSet);
465
461
  //@}
466
462
 
467
463
  /// Whether its reachable between two functions
468
- bool isReachableBetweenFunctions(const SVFFunction* srcFn, const SVFFunction* dstFn) const;
464
+ bool isReachableBetweenFunctions(const FunObjVar* srcFn, const FunObjVar* dstFn) const;
469
465
 
470
466
  /// Dump the graph
471
467
  void dump(const std::string& filename);
@@ -76,12 +76,12 @@ protected:
76
76
 
77
77
  /// Wrappers used internally, not expose to Andersen Pass
78
78
  //@{
79
- inline NodeID getReturnNode(const SVFFunction* value) const
79
+ inline NodeID getReturnNode(const FunObjVar* value) const
80
80
  {
81
81
  return pag->getReturnNode(value);
82
82
  }
83
83
 
84
- inline NodeID getVarargNode(const SVFFunction* value) const
84
+ inline NodeID getVarargNode(const FunObjVar* value) const
85
85
  {
86
86
  return pag->getVarargNode(value);
87
87
  }
@@ -58,8 +58,8 @@ public:
58
58
  typedef ICFGNodeIDToNodeMapTy::iterator iterator;
59
59
  typedef ICFGNodeIDToNodeMapTy::const_iterator const_iterator;
60
60
 
61
- typedef Map<const SVFFunction*, FunEntryICFGNode *> FunToFunEntryNodeMapTy;
62
- typedef Map<const SVFFunction*, FunExitICFGNode *> FunToFunExitNodeMapTy;
61
+ typedef Map<const FunObjVar*, FunEntryICFGNode *> FunToFunEntryNodeMapTy;
62
+ typedef Map<const FunObjVar*, FunExitICFGNode *> FunToFunExitNodeMapTy;
63
63
  typedef std::vector<const SVFLoop *> SVFLoopVec;
64
64
  typedef Map<const ICFGNode *, SVFLoopVec> ICFGNodeToSVFLoopVec;
65
65
 
@@ -164,8 +164,8 @@ protected:
164
164
  /// sanitize Intra edges, verify that both nodes belong to the same function.
165
165
  inline void checkIntraEdgeParents(const ICFGNode *srcNode, const ICFGNode *dstNode)
166
166
  {
167
- const SVFFunction* srcfun = srcNode->getFun();
168
- const SVFFunction* dstfun = dstNode->getFun();
167
+ const FunObjVar* srcfun = srcNode->getFun();
168
+ const FunObjVar* dstfun = dstNode->getFun();
169
169
  if(srcfun != nullptr && dstfun != nullptr)
170
170
  {
171
171
  assert((srcfun == dstfun) && "src and dst nodes of an intra edge should in the same function!" );
@@ -182,7 +182,7 @@ protected:
182
182
 
183
183
  virtual inline CallICFGNode* addCallICFGNode(
184
184
  const SVFBasicBlock* bb, const SVFType* ty,
185
- const SVFFunction* calledFunc, bool isVararg, bool isvcall,
185
+ const FunObjVar* calledFunc, bool isVararg, bool isvcall,
186
186
  s32_t vcallIdx, const std::string& funNameOfVcall)
187
187
  {
188
188
 
@@ -201,14 +201,14 @@ protected:
201
201
  return retICFGNode;
202
202
  }
203
203
 
204
- virtual inline FunEntryICFGNode* addFunEntryICFGNode(const SVFFunction* svfFunc)
204
+ virtual inline FunEntryICFGNode* addFunEntryICFGNode(const FunObjVar* svfFunc)
205
205
  {
206
206
  FunEntryICFGNode* sNode = new FunEntryICFGNode(totalICFGNode++,svfFunc);
207
207
  addICFGNode(sNode);
208
208
  return FunToFunEntryNodeMap[svfFunc] = sNode;
209
209
  }
210
210
 
211
- virtual inline FunExitICFGNode* addFunExitICFGNode(const SVFFunction* svfFunc)
211
+ virtual inline FunExitICFGNode* addFunExitICFGNode(const FunObjVar* svfFunc)
212
212
  {
213
213
  FunExitICFGNode* sNode = new FunExitICFGNode(totalICFGNode++, svfFunc);
214
214
  addICFGNode(sNode);
@@ -229,9 +229,9 @@ public:
229
229
  //@{
230
230
 
231
231
 
232
- FunEntryICFGNode* getFunEntryICFGNode(const SVFFunction* fun);
232
+ FunEntryICFGNode* getFunEntryICFGNode(const FunObjVar* fun);
233
233
 
234
- FunExitICFGNode* getFunExitICFGNode(const SVFFunction* fun);
234
+ FunExitICFGNode* getFunExitICFGNode(const FunObjVar* fun);
235
235
 
236
236
  inline GlobalICFGNode* getGlobalICFGNode() const
237
237
  {
@@ -284,7 +284,7 @@ private:
284
284
  }
285
285
 
286
286
  /// Get/Add a function entry node
287
- inline FunEntryICFGNode* getFunEntryBlock(const SVFFunction* fun)
287
+ inline FunEntryICFGNode* getFunEntryBlock(const FunObjVar* fun)
288
288
  {
289
289
  FunToFunEntryNodeMapTy::const_iterator it = FunToFunEntryNodeMap.find(fun);
290
290
  if (it == FunToFunEntryNodeMap.end())
@@ -293,7 +293,7 @@ private:
293
293
  }
294
294
 
295
295
  /// Get/Add a function exit node
296
- inline FunExitICFGNode* getFunExitBlock(const SVFFunction* fun)
296
+ inline FunExitICFGNode* getFunExitBlock(const FunObjVar* fun)
297
297
  {
298
298
  FunToFunExitNodeMapTy::const_iterator it = FunToFunExitNodeMap.find(fun);
299
299
  if (it == FunToFunExitNodeMap.end())
@@ -73,7 +73,7 @@ public:
73
73
  }
74
74
 
75
75
  /// Return the function of this ICFGNode
76
- virtual const SVFFunction* getFun() const
76
+ virtual const FunObjVar* getFun() const
77
77
  {
78
78
  return fun;
79
79
  }
@@ -145,7 +145,7 @@ public:
145
145
 
146
146
 
147
147
  protected:
148
- const SVFFunction* fun;
148
+ const FunObjVar* fun;
149
149
  const SVFBasicBlock* bb;
150
150
  VFGNodeList VFGNodes; //< a list of VFGNodes
151
151
  SVFStmtList pagEdges; //< a list of PAGEdges
@@ -289,10 +289,10 @@ private:
289
289
  FunEntryICFGNode(NodeID id) : InterICFGNode(id, FunEntryBlock) {}
290
290
 
291
291
  public:
292
- FunEntryICFGNode(NodeID id, const SVFFunction* f);
292
+ FunEntryICFGNode(NodeID id, const FunObjVar* f);
293
293
 
294
294
  /// Return function
295
- inline const SVFFunction* getFun() const override
295
+ inline const FunObjVar* getFun() const override
296
296
  {
297
297
  return fun;
298
298
  }
@@ -339,10 +339,7 @@ public:
339
339
 
340
340
  const std::string toString() const override;
341
341
 
342
- const std::string getSourceLoc() const override
343
- {
344
- return "function entry: " + fun->getSourceLoc();
345
- }
342
+ const std::string getSourceLoc() const override;
346
343
  };
347
344
 
348
345
  /*!
@@ -360,10 +357,10 @@ private:
360
357
  FunExitICFGNode(NodeID id) : InterICFGNode(id, FunExitBlock), formalRet{} {}
361
358
 
362
359
  public:
363
- FunExitICFGNode(NodeID id, const SVFFunction* f);
360
+ FunExitICFGNode(NodeID id, const FunObjVar* f);
364
361
 
365
362
  /// Return function
366
- inline const SVFFunction* getFun() const override
363
+ inline const FunObjVar* getFun() const override
367
364
  {
368
365
  return fun;
369
366
  }
@@ -410,10 +407,7 @@ public:
410
407
 
411
408
  const std::string toString() const override;
412
409
 
413
- const std::string getSourceLoc() const override
414
- {
415
- return "function ret: " + fun->getSourceLoc();
416
- }
410
+ const std::string getSourceLoc() const override;
417
411
  };
418
412
 
419
413
  /*!
@@ -430,7 +424,7 @@ public:
430
424
  protected:
431
425
  const RetICFGNode* ret;
432
426
  ActualParmNodeVec APNodes; /// arguments
433
- const SVFFunction* calledFunc; /// called function
427
+ const FunObjVar* calledFunc; /// called function
434
428
  bool isvararg; /// is variable argument
435
429
  bool isVirCallInst; /// is virtual call inst
436
430
  SVFVar* vtabPtr; /// virtual table pointer
@@ -442,7 +436,7 @@ protected:
442
436
 
443
437
  public:
444
438
  CallICFGNode(NodeID id, const SVFBasicBlock* b, const SVFType* ty,
445
- const SVFFunction* cf, bool iv, bool ivc, s32_t vfi,
439
+ const FunObjVar* cf, bool iv, bool ivc, s32_t vfi,
446
440
  const std::string& fnv)
447
441
  : InterICFGNode(id, FunCallBlock), ret(nullptr), calledFunc(cf),
448
442
  isvararg(iv), isVirCallInst(ivc), vtabPtr(nullptr),
@@ -467,7 +461,7 @@ public:
467
461
  }
468
462
 
469
463
  /// Return callsite
470
- inline const SVFFunction* getCaller() const
464
+ inline const FunObjVar* getCaller() const
471
465
  {
472
466
  return getFun();
473
467
  }
@@ -515,7 +509,7 @@ public:
515
509
  {
516
510
  return arg_size();
517
511
  }
518
- inline const SVFFunction* getCalledFunction() const
512
+ inline const FunObjVar* getCalledFunction() const
519
513
  {
520
514
  return calledFunc;
521
515
  }
@@ -52,6 +52,7 @@ class IRGraph : public GenericGraph<SVFVar, SVFStmt>
52
52
  {
53
53
  friend class SVFIRWriter;
54
54
  friend class SVFIRReader;
55
+ friend class SVFIRBuilder;
55
56
  friend class SymbolTableBuilder;
56
57
 
57
58
  public:
@@ -75,14 +76,15 @@ public:
75
76
  typedef OrderedMap<NodeID, ObjTypeInfo*> IDToTypeInfoMapTy;
76
77
 
77
78
  /// function to sym id map
78
- typedef OrderedMap<const SVFFunction*, NodeID> FunToIDMapTy;
79
+ typedef OrderedMap<const FunObjVar*, NodeID> FunObjVarToIDMapTy;
80
+
79
81
  /// struct type to struct info map
80
82
  typedef Set<const SVFType*> SVFTypeSet;
81
83
  //@}
82
84
 
83
85
  private:
84
- FunToIDMapTy returnSymMap; ///< return map
85
- FunToIDMapTy varargSymMap; ///< vararg map
86
+ FunObjVarToIDMapTy returnFunObjSymMap; ///< return map
87
+ FunObjVarToIDMapTy varargFunObjSymMap; ///< vararg map
86
88
  IDToTypeInfoMapTy objTypeInfoMap; ///< map a memory sym id to its obj
87
89
 
88
90
  /// (owned) All SVF Types
@@ -217,14 +219,14 @@ public:
217
219
  return objTypeInfoMap;
218
220
  }
219
221
 
220
- inline FunToIDMapTy& retSyms()
222
+ inline FunObjVarToIDMapTy& retFunObjSyms()
221
223
  {
222
- return returnSymMap;
224
+ return returnFunObjSymMap;
223
225
  }
224
226
 
225
- inline FunToIDMapTy& varargSyms()
227
+ inline FunObjVarToIDMapTy& varargFunObjSyms()
226
228
  {
227
- return varargSymMap;
229
+ return varargFunObjSymMap;
228
230
  }
229
231
 
230
232
  //@}
@@ -237,10 +239,10 @@ public:
237
239
  }
238
240
 
239
241
  /// GetReturnNode - Return the unique node representing the return value of a function
240
- NodeID getReturnNode(const SVFFunction* func) const;
242
+ NodeID getReturnNode(const FunObjVar*func) const;
241
243
 
242
244
  /// getVarargNode - Return the unique node representing the variadic argument of a variadic function.
243
- NodeID getVarargNode(const SVFFunction* func) const;
245
+ NodeID getVarargNode(const FunObjVar*func) const;
244
246
 
245
247
  inline NodeID getBlackHoleNode() const
246
248
  {