svf-tools 1.0.1041 → 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 (104) hide show
  1. package/package.json +1 -1
  2. package/svf/include/AE/Svfexe/AbstractInterpretation.h +3 -3
  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 +6 -6
  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/{PTACallGraph.h → CallGraph.h} +55 -59
  10. package/svf/include/Graphs/ConsG.h +2 -2
  11. package/svf/include/Graphs/ICFG.h +13 -13
  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 +28 -46
  17. package/svf/include/Graphs/VFG.h +19 -19
  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 +25 -25
  22. package/svf/include/MSSA/MemSSA.h +10 -10
  23. package/svf/include/MTA/LockAnalysis.h +5 -5
  24. package/svf/include/MTA/MHP.h +10 -10
  25. package/svf/include/MTA/TCT.h +16 -16
  26. package/svf/include/MemoryModel/PointerAnalysis.h +9 -9
  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/SaberSVFGBuilder.h +1 -1
  33. package/svf/include/SABER/SrcSnkDDA.h +4 -4
  34. package/svf/include/SVFIR/SVFIR.h +23 -30
  35. package/svf/include/SVFIR/SVFValue.h +3 -2
  36. package/svf/include/SVFIR/SVFVariables.h +271 -71
  37. package/svf/include/Util/CDGBuilder.h +1 -1
  38. package/svf/include/Util/CallGraphBuilder.h +2 -2
  39. package/svf/include/Util/CxtStmt.h +6 -6
  40. package/svf/include/Util/ExtAPI.h +20 -16
  41. package/svf/include/Util/SVFUtil.h +16 -30
  42. package/svf/include/Util/ThreadAPI.h +2 -11
  43. package/svf/include/WPA/Andersen.h +2 -2
  44. package/svf/lib/AE/Svfexe/AEDetector.cpp +1 -1
  45. package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +3 -3
  46. package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +9 -9
  47. package/svf/lib/CFL/CFLAlias.cpp +1 -1
  48. package/svf/lib/DDA/ContextDDA.cpp +5 -5
  49. package/svf/lib/DDA/DDAClient.cpp +4 -4
  50. package/svf/lib/DDA/DDAPass.cpp +6 -6
  51. package/svf/lib/DDA/FlowDDA.cpp +5 -5
  52. package/svf/lib/Graphs/CHG.cpp +2 -2
  53. package/svf/lib/Graphs/{PTACallGraph.cpp → CallGraph.cpp} +91 -81
  54. package/svf/lib/Graphs/ICFG.cpp +21 -12
  55. package/svf/lib/Graphs/IRGraph.cpp +7 -7
  56. package/svf/lib/Graphs/SVFG.cpp +8 -8
  57. package/svf/lib/Graphs/SVFGReadWrite.cpp +4 -4
  58. package/svf/lib/Graphs/SVFGStat.cpp +1 -1
  59. package/svf/lib/Graphs/ThreadCallGraph.cpp +39 -18
  60. package/svf/lib/Graphs/VFG.cpp +7 -7
  61. package/svf/lib/MSSA/MemPartition.cpp +8 -8
  62. package/svf/lib/MSSA/MemRegion.cpp +21 -21
  63. package/svf/lib/MSSA/MemSSA.cpp +11 -10
  64. package/svf/lib/MSSA/SVFGBuilder.cpp +3 -3
  65. package/svf/lib/MTA/LockAnalysis.cpp +31 -30
  66. package/svf/lib/MTA/MHP.cpp +31 -31
  67. package/svf/lib/MTA/MTA.cpp +2 -1
  68. package/svf/lib/MTA/MTAStat.cpp +5 -4
  69. package/svf/lib/MTA/TCT.cpp +43 -43
  70. package/svf/lib/MemoryModel/PointerAnalysis.cpp +8 -8
  71. package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +2 -2
  72. package/svf/lib/SABER/DoubleFreeChecker.cpp +3 -3
  73. package/svf/lib/SABER/LeakChecker.cpp +9 -9
  74. package/svf/lib/SABER/SaberCondAllocator.cpp +8 -8
  75. package/svf/lib/SABER/SaberSVFGBuilder.cpp +4 -4
  76. package/svf/lib/SVFIR/SVFIR.cpp +15 -1
  77. package/svf/lib/SVFIR/SVFVariables.cpp +51 -20
  78. package/svf/lib/Util/CDGBuilder.cpp +6 -6
  79. package/svf/lib/Util/CallGraphBuilder.cpp +9 -9
  80. package/svf/lib/Util/ExtAPI.cpp +28 -29
  81. package/svf/lib/Util/PTAStat.cpp +7 -7
  82. package/svf/lib/Util/SVFBugReport.cpp +1 -1
  83. package/svf/lib/Util/SVFStat.cpp +4 -4
  84. package/svf/lib/Util/SVFUtil.cpp +27 -9
  85. package/svf/lib/Util/ThreadAPI.cpp +17 -5
  86. package/svf/lib/WPA/Andersen.cpp +2 -2
  87. package/svf/lib/WPA/FlowSensitive.cpp +2 -2
  88. package/svf/lib/WPA/TypeAnalysis.cpp +3 -3
  89. package/svf/lib/WPA/VersionedFlowSensitive.cpp +2 -2
  90. package/svf/lib/WPA/WPAPass.cpp +2 -2
  91. package/svf-llvm/include/SVF-LLVM/LLVMModule.h +83 -7
  92. package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +9 -1
  93. package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +6 -3
  94. package/svf-llvm/lib/CHGBuilder.cpp +12 -12
  95. package/svf-llvm/lib/DCHG.cpp +3 -3
  96. package/svf-llvm/lib/ICFGBuilder.cpp +8 -8
  97. package/svf-llvm/lib/LLVMLoopAnalysis.cpp +1 -1
  98. package/svf-llvm/lib/LLVMModule.cpp +127 -12
  99. package/svf-llvm/lib/LLVMUtil.cpp +35 -10
  100. package/svf-llvm/lib/SVFIRBuilder.cpp +189 -105
  101. package/svf-llvm/lib/SVFIRExtAPI.cpp +5 -5
  102. package/svf-llvm/lib/SymbolTableBuilder.cpp +10 -10
  103. package/svf-llvm/tools/AE/ae.cpp +1 -1
  104. package/svf-llvm/tools/Example/svf-ex.cpp +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.1041",
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": {
@@ -106,7 +106,7 @@ class AbstractInterpretation
106
106
  friend class BufOverflowDetector;
107
107
 
108
108
  public:
109
- typedef SCCDetection<PTACallGraph*> CallGraphSCC;
109
+ typedef SCCDetection<CallGraph*> CallGraphSCC;
110
110
  /// Constructor
111
111
  AbstractInterpretation();
112
112
 
@@ -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);
@@ -49,8 +49,8 @@ class DDAVFSolver
49
49
  friend class DDAStat;
50
50
  public:
51
51
  typedef SCCDetection<SVFG*> SVFGSCC;
52
- typedef SCCDetection<PTACallGraph*> CallGraphSCC;
53
- typedef PTACallGraphEdge::CallInstSet CallInstSet;
52
+ typedef SCCDetection<CallGraph*> CallGraphSCC;
53
+ typedef CallGraphEdge::CallInstSet CallInstSet;
54
54
  typedef SVFIR::CallSiteSet CallSiteSet;
55
55
  typedef OrderedSet<DPIm> DPTItemSet;
56
56
  typedef OrderedMap<DPIm, CPtSet> DPImToCPtSetMap;
@@ -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
@@ -624,7 +624,7 @@ protected:
624
624
  return (getSVFGSCCRepNode(edge->getSrcID()) == getSVFGSCCRepNode(edge->getDstID()));
625
625
  }
626
626
  /// Set callgraph
627
- inline void setCallGraph (PTACallGraph* cg)
627
+ inline void setCallGraph (CallGraph* cg)
628
628
  {
629
629
  _callGraph = cg;
630
630
  }
@@ -774,7 +774,7 @@ protected:
774
774
  SVFG* _svfg; ///< SVFG
775
775
  AndersenWaveDiff* _ander; ///< Andersen's analysis
776
776
  NodeBS candidateQueries; ///< candidate pointers;
777
- PTACallGraph* _callGraph; ///< PTACallGraph
777
+ CallGraph* _callGraph; ///< PTACallGraph
778
778
  CallGraphSCC* _callGraphSCC; ///< SCC for PTACallGraph
779
779
  SVFGSCC* _svfgSCC; ///< SCC for SVFG
780
780
  DPTItemSet backwardVisited; ///< visited map during backward traversing
@@ -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;
@@ -38,7 +38,7 @@
38
38
  namespace SVF
39
39
  {
40
40
 
41
- class PTACallGraphNode;
41
+ class CallGraphNode;
42
42
  class SVFModule;
43
43
  class CallGraph;
44
44
 
@@ -48,8 +48,8 @@ class CallGraph;
48
48
  * Multiple calls from function A to B are merged into one call edge
49
49
  * Each call edge has a set of direct callsites and a set of indirect callsites
50
50
  */
51
- typedef GenericEdge<PTACallGraphNode> GenericPTACallGraphEdgeTy;
52
- class PTACallGraphEdge : public GenericPTACallGraphEdgeTy
51
+ typedef GenericEdge<CallGraphNode> GenericPTACallGraphEdgeTy;
52
+ class CallGraphEdge : public GenericPTACallGraphEdgeTy
53
53
  {
54
54
 
55
55
  public:
@@ -66,12 +66,12 @@ private:
66
66
  CallSiteID csId;
67
67
  public:
68
68
  /// Constructor
69
- PTACallGraphEdge(PTACallGraphNode* s, PTACallGraphNode* d, CEDGEK kind, CallSiteID cs) :
69
+ CallGraphEdge(CallGraphNode* s, CallGraphNode* d, CEDGEK kind, CallSiteID cs) :
70
70
  GenericPTACallGraphEdgeTy(s, d, makeEdgeFlagWithInvokeID(kind, cs)), csId(cs)
71
71
  {
72
72
  }
73
73
  /// Destructor
74
- virtual ~PTACallGraphEdge()
74
+ virtual ~CallGraphEdge()
75
75
  {
76
76
  }
77
77
  /// Compute the unique edgeFlag value from edge kind and CallSiteID.
@@ -141,21 +141,21 @@ public:
141
141
 
142
142
  /// ClassOf
143
143
  //@{
144
- static inline bool classof(const PTACallGraphEdge*)
144
+ static inline bool classof(const CallGraphEdge*)
145
145
  {
146
146
  return true;
147
147
  }
148
148
  static inline bool classof(const GenericPTACallGraphEdgeTy *edge)
149
149
  {
150
- return edge->getEdgeKind() == PTACallGraphEdge::CallRetEdge ||
151
- edge->getEdgeKind() == PTACallGraphEdge::TDForkEdge ||
152
- edge->getEdgeKind() == PTACallGraphEdge::TDJoinEdge;
150
+ return edge->getEdgeKind() == CallGraphEdge::CallRetEdge ||
151
+ edge->getEdgeKind() == CallGraphEdge::TDForkEdge ||
152
+ edge->getEdgeKind() == CallGraphEdge::TDJoinEdge;
153
153
  }
154
154
  //@}
155
155
 
156
156
  /// Overloading operator << for dumping ICFG node ID
157
157
  //@{
158
- friend OutStream& operator<< (OutStream &o, const PTACallGraphEdge&edge)
158
+ friend OutStream& operator<< (OutStream &o, const CallGraphEdge&edge)
159
159
  {
160
160
  o << edge.toString();
161
161
  return o;
@@ -164,33 +164,32 @@ public:
164
164
 
165
165
  virtual const std::string toString() const;
166
166
 
167
- typedef GenericNode<PTACallGraphNode, PTACallGraphEdge>::GEdgeSetTy CallGraphEdgeSet;
167
+ typedef GenericNode<CallGraphNode, CallGraphEdge>::GEdgeSetTy CallGraphEdgeSet;
168
168
 
169
169
  };
170
170
 
171
+ class FunObjVar;
172
+
171
173
  /*
172
174
  * Call Graph node representing a function
173
175
  */
174
- typedef GenericNode<PTACallGraphNode, PTACallGraphEdge> GenericPTACallGraphNodeTy;
175
- class PTACallGraphNode : public GenericPTACallGraphNodeTy
176
+ typedef GenericNode<CallGraphNode, CallGraphEdge> GenericPTACallGraphNodeTy;
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
- PTACallGraphNode(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
  }
@@ -201,7 +200,7 @@ public:
201
200
 
202
201
  /// Overloading operator << for dumping ICFG node ID
203
202
  //@{
204
- friend OutStream& operator<< (OutStream &o, const PTACallGraphNode&node)
203
+ friend OutStream& operator<< (OutStream &o, const CallGraphNode&node)
205
204
  {
206
205
  o << node.toString();
207
206
  return o;
@@ -212,7 +211,7 @@ public:
212
211
 
213
212
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
214
213
  //@{
215
- static inline bool classof(const PTACallGraphNode*)
214
+ static inline bool classof(const CallGraphNode*)
216
215
  {
217
216
  return true;
218
217
  }
@@ -232,18 +231,18 @@ public:
232
231
  /*!
233
232
  * Pointer Analysis Call Graph used internally for various pointer analysis
234
233
  */
235
- typedef GenericGraph<PTACallGraphNode, PTACallGraphEdge> GenericPTACallGraphTy;
236
- class PTACallGraph : public GenericPTACallGraphTy
234
+ typedef GenericGraph<CallGraphNode, CallGraphEdge> GenericPTACallGraphTy;
235
+ class CallGraph : public GenericPTACallGraphTy
237
236
  {
238
237
 
239
238
  public:
240
- typedef PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
241
- typedef Map<const SVFFunction*, PTACallGraphNode*> FunToCallGraphNodeMap;
239
+ typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
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())
@@ -291,7 +290,7 @@ protected:
291
290
  }
292
291
 
293
292
  /// Add call graph edge
294
- inline void addEdge(PTACallGraphEdge* edge)
293
+ inline void addEdge(CallGraphEdge* edge)
295
294
  {
296
295
  edge->getDstNode()->addIncomingEdge(edge);
297
296
  edge->getSrcNode()->addOutgoingEdge(edge);
@@ -299,13 +298,13 @@ protected:
299
298
 
300
299
  public:
301
300
  /// Constructor
302
- PTACallGraph(CGEK k = NormCallGraph);
301
+ CallGraph(CGEK k = NormCallGraph);
303
302
 
304
303
  /// Copy constructor
305
- PTACallGraph(const PTACallGraph& other);
304
+ CallGraph(const CallGraph& other);
306
305
 
307
306
  /// Destructor
308
- virtual ~PTACallGraph()
307
+ virtual ~CallGraph()
309
308
  {
310
309
  destroy();
311
310
  }
@@ -352,20 +351,20 @@ 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
  //@{
361
360
 
362
- const PTACallGraphNode* getCallGraphNode(const std::string& name);
361
+ const CallGraphNode* getCallGraphNode(const std::string& name);
363
362
 
364
- inline PTACallGraphNode* getCallGraphNode(NodeID id) const
363
+ inline CallGraphNode* getCallGraphNode(NodeID id) const
365
364
  {
366
365
  return getGNode(id);
367
366
  }
368
- inline PTACallGraphNode* 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,21 +398,18 @@ 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
  }
410
406
  //@}
411
407
  /// Whether we have already created this call graph edge
412
- PTACallGraphEdge* hasGraphEdge(PTACallGraphNode* src, PTACallGraphNode* dst,
413
- PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const;
408
+ CallGraphEdge* hasGraphEdge(CallGraphNode* src, CallGraphNode* dst,
409
+ CallGraphEdge::CEDGEK kind, CallSiteID csId) const;
414
410
  /// Get call graph edge via nodes
415
- PTACallGraphEdge* getGraphEdge(PTACallGraphNode* src, PTACallGraphNode* dst,
416
- PTACallGraphEdge::CEDGEK kind, CallSiteID csId);
411
+ CallGraphEdge* getGraphEdge(CallGraphNode* src, CallGraphNode* dst,
412
+ CallGraphEdge::CEDGEK kind, CallSiteID csId);
417
413
 
418
414
  /// Get all callees for a callsite
419
415
  inline void getCallees(const CallICFGNode* cs, FunctionSet& callees)
@@ -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, PTACallGraphEdge::CallInstSet& csSet);
463
- void getDirCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet);
464
- void getIndCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::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);
@@ -482,19 +478,19 @@ namespace SVF
482
478
  * GenericGraphTraits specializations for generic graph algorithms.
483
479
  * Provide graph traits for traversing from a constraint node using standard graph traversals.
484
480
  */
485
- template<> struct GenericGraphTraits<SVF::PTACallGraphNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::PTACallGraphNode,SVF::PTACallGraphEdge>* >
481
+ template<> struct GenericGraphTraits<SVF::CallGraphNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::CallGraphNode,SVF::CallGraphEdge>* >
486
482
  {
487
483
  };
488
484
 
489
485
  /// Inverse GenericGraphTraits specializations for call graph node, it is used for inverse traversal.
490
486
  template<>
491
- struct GenericGraphTraits<Inverse<SVF::PTACallGraphNode*> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::PTACallGraphNode,SVF::PTACallGraphEdge>* > >
487
+ struct GenericGraphTraits<Inverse<SVF::CallGraphNode*> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::CallGraphNode,SVF::CallGraphEdge>* > >
492
488
  {
493
489
  };
494
490
 
495
- template<> struct GenericGraphTraits<SVF::PTACallGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::PTACallGraphNode,SVF::PTACallGraphEdge>* >
491
+ template<> struct GenericGraphTraits<SVF::CallGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::CallGraphNode,SVF::CallGraphEdge>* >
496
492
  {
497
- typedef SVF::PTACallGraphNode*NodeRef;
493
+ typedef SVF::CallGraphNode*NodeRef;
498
494
  };
499
495
 
500
496
  } // End namespace llvm
@@ -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
  }