svf-lib 1.0.733 → 1.0.737

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 (59) hide show
  1. package/SVF-linux/Release-build/lib/libSvf.a +0 -0
  2. package/SVF-linux/include/DDA/ContextDDA.h +1 -1
  3. package/SVF-linux/include/DDA/DDAClient.h +8 -8
  4. package/SVF-linux/include/DDA/DDAVFSolver.h +5 -5
  5. package/SVF-linux/include/DDA/FlowDDA.h +1 -1
  6. package/SVF-linux/include/Graphs/CHG.h +351 -0
  7. package/SVF-linux/include/Graphs/ConsG.h +6 -6
  8. package/SVF-linux/include/Graphs/ConsGEdge.h +2 -2
  9. package/SVF-linux/include/Graphs/ConsGNode.h +1 -1
  10. package/SVF-linux/include/Graphs/ExternalPAG.h +14 -14
  11. package/SVF-linux/include/Graphs/GenericGraph.h +1 -1
  12. package/SVF-linux/include/Graphs/ICFGNode.h +14 -14
  13. package/SVF-linux/include/Graphs/IRGraph.h +236 -0
  14. package/SVF-linux/include/Graphs/OfflineConsG.h +1 -1
  15. package/SVF-linux/include/Graphs/SVFG.h +1 -1
  16. package/SVF-linux/include/Graphs/SVFGOPT.h +3 -3
  17. package/SVF-linux/include/Graphs/VFG.h +53 -52
  18. package/SVF-linux/include/Graphs/VFGNode.h +60 -8
  19. package/SVF-linux/include/MSSA/MemRegion.h +11 -11
  20. package/SVF-linux/include/MSSA/MemSSA.h +4 -4
  21. package/SVF-linux/include/MTA/FSMPTA.h +1 -1
  22. package/SVF-linux/include/MemoryModel/PAGBuilderFromFile.h +8 -8
  23. package/SVF-linux/include/MemoryModel/PTAStat.h +31 -31
  24. package/SVF-linux/include/MemoryModel/PointerAnalysis.h +9 -9
  25. package/SVF-linux/include/MemoryModel/PointerAnalysisImpl.h +3 -3
  26. package/SVF-linux/include/MemoryModel/SVFIR.h +525 -233
  27. package/SVF-linux/include/MemoryModel/SVFStatements.h +970 -0
  28. package/SVF-linux/include/MemoryModel/SVFVariables.h +842 -0
  29. package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +346 -55
  30. package/SVF-linux/include/SABER/SaberSVFGBuilder.h +0 -2
  31. package/SVF-linux/include/SABER/SrcSnkDDA.h +3 -3
  32. package/SVF-linux/include/SVF-FE/CHGBuilder.h +69 -0
  33. package/SVF-linux/include/SVF-FE/DCHG.h +1 -1
  34. package/SVF-linux/include/SVF-FE/Graph2Json.h +1 -3
  35. package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +405 -0
  36. package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +0 -1
  37. package/SVF-linux/include/Util/CFLSolver.h +1 -1
  38. package/SVF-linux/include/Util/ExtAPI.h +1 -1
  39. package/SVF-linux/include/Util/IRAnnotator.h +6 -6
  40. package/SVF-linux/include/Util/Options.h +1 -1
  41. package/SVF-linux/include/Util/TypeBasedHeapCloning.h +11 -11
  42. package/SVF-linux/include/WPA/Andersen.h +11 -11
  43. package/SVF-linux/include/WPA/AndersenSFR.h +4 -4
  44. package/SVF-linux/include/WPA/FlowSensitive.h +2 -2
  45. package/SVF-linux/include/WPA/FlowSensitiveTBHC.h +1 -1
  46. package/SVF-linux/include/WPA/Steensgaard.h +2 -2
  47. package/SVF-linux/include/WPA/TypeAnalysis.h +1 -1
  48. package/SVF-linux/include/WPA/VersionedFlowSensitive.h +2 -2
  49. package/SVF-linux/include/WPA/WPAStat.h +1 -2
  50. package/SVF-osx/Release-build/lib/CUDD/libCudd.a +0 -0
  51. package/SVF-osx/Release-build/lib/libSvf.a +0 -0
  52. package/SVF-osx/include/Graphs/GenericGraph.h +1 -1
  53. package/SVF-osx/include/Graphs/IRGraph.h +6 -15
  54. package/SVF-osx/include/Graphs/VFG.h +26 -41
  55. package/SVF-osx/include/Graphs/VFGNode.h +2 -2
  56. package/SVF-osx/include/MemoryModel/SVFIR.h +29 -96
  57. package/SVF-osx/include/MemoryModel/SVFStatements.h +156 -22
  58. package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +12 -6
  59. package/package.json +1 -1
@@ -41,8 +41,8 @@ class ICFGNode;
41
41
  class RetBlockNode;
42
42
  class CallPE;
43
43
  class RetPE;
44
- class PAGEdge;
45
- class PAGNode;
44
+ class SVFStmt;
45
+ class SVFVar;
46
46
  class VFGNode;
47
47
 
48
48
  /*!
@@ -67,7 +67,7 @@ public:
67
67
  typedef Set<const CallPE *> CallPESet;
68
68
  typedef Set<const RetPE *> RetPESet;
69
69
  typedef std::list<const VFGNode*> VFGNodeList;
70
- typedef std::list<const PAGEdge*> PAGEdgeList;
70
+ typedef std::list<const SVFStmt*> PAGEdgeList;
71
71
 
72
72
  public:
73
73
  /// Constructor
@@ -113,7 +113,7 @@ public:
113
113
 
114
114
  /// Set/Get methods of VFGNodes
115
115
  ///@{
116
- inline void addPAGEdge(const PAGEdge *edge)
116
+ inline void addPAGEdge(const SVFStmt *edge)
117
117
  {
118
118
  pagEdges.push_back(edge);
119
119
  }
@@ -252,7 +252,7 @@ class FunEntryBlockNode : public InterBlockNode
252
252
  {
253
253
 
254
254
  public:
255
- typedef std::vector<const PAGNode *> FormalParmNodeVec;
255
+ typedef std::vector<const SVFVar *> FormalParmNodeVec;
256
256
  private:
257
257
  FormalParmNodeVec FPNodes;
258
258
  public:
@@ -271,7 +271,7 @@ public:
271
271
  }
272
272
 
273
273
  /// Add formal parameters
274
- inline void addFormalParms(const PAGNode *fp)
274
+ inline void addFormalParms(const SVFVar *fp)
275
275
  {
276
276
  FPNodes.push_back(fp);
277
277
  }
@@ -310,7 +310,7 @@ class FunExitBlockNode : public InterBlockNode
310
310
 
311
311
  private:
312
312
  const SVFFunction* fun;
313
- const PAGNode *formalRet;
313
+ const SVFVar *formalRet;
314
314
  public:
315
315
  FunExitBlockNode(NodeID id, const SVFFunction* f);
316
316
 
@@ -321,13 +321,13 @@ public:
321
321
  }
322
322
 
323
323
  /// Return actual return parameter
324
- inline const PAGNode *getFormalRet() const
324
+ inline const SVFVar *getFormalRet() const
325
325
  {
326
326
  return formalRet;
327
327
  }
328
328
 
329
329
  /// Add actual return parameter
330
- inline void addFormalRet(const PAGNode *fr)
330
+ inline void addFormalRet(const SVFVar *fr)
331
331
  {
332
332
  formalRet = fr;
333
333
  }
@@ -365,7 +365,7 @@ class CallBlockNode : public InterBlockNode
365
365
  {
366
366
 
367
367
  public:
368
- typedef std::vector<const PAGNode *> ActualParmVFGNodeVec;
368
+ typedef std::vector<const SVFVar *> ActualParmVFGNodeVec;
369
369
  private:
370
370
  const Instruction* cs;
371
371
  const RetBlockNode* ret;
@@ -421,7 +421,7 @@ public:
421
421
  }
422
422
 
423
423
  /// Add actual parameters
424
- inline void addActualParms(const PAGNode *ap)
424
+ inline void addActualParms(const SVFVar *ap)
425
425
  {
426
426
  APNodes.push_back(ap);
427
427
  }
@@ -461,7 +461,7 @@ class RetBlockNode : public InterBlockNode
461
461
 
462
462
  private:
463
463
  const Instruction* cs;
464
- const PAGNode *actualRet;
464
+ const SVFVar *actualRet;
465
465
  const CallBlockNode* callBlockNode;
466
466
  public:
467
467
  RetBlockNode(NodeID id, const Instruction* c, CallBlockNode* cb) :
@@ -482,13 +482,13 @@ public:
482
482
  return callBlockNode;
483
483
  }
484
484
  /// Return actual return parameter
485
- inline const PAGNode *getActualRet() const
485
+ inline const SVFVar *getActualRet() const
486
486
  {
487
487
  return actualRet;
488
488
  }
489
489
 
490
490
  /// Add actual return parameter
491
- inline void addActualRet(const PAGNode *ar)
491
+ inline void addActualRet(const SVFVar *ar)
492
492
  {
493
493
  actualRet = ar;
494
494
  }
@@ -0,0 +1,236 @@
1
+ //===- SVFIR.h -- SVF IR Graph or PAG (Program Assignment Graph)--------------------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2017> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * IRGraph.h
25
+ *
26
+ * Created on: Nov 1, 2013
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+
31
+ #ifndef IRGRAPH_H_
32
+ #define IRGRAPH_H_
33
+
34
+ #include "MemoryModel/SVFStatements.h"
35
+ #include "MemoryModel/SVFVariables.h"
36
+ #include "Util/NodeIDAllocator.h"
37
+ #include "Util/SVFUtil.h"
38
+ #include "Graphs/ICFG.h"
39
+
40
+ namespace SVF
41
+ {
42
+ typedef SVFVar PAGNode;
43
+ typedef SVFStmt PAGEdge;
44
+
45
+ /*
46
+ * Graph representation of SVF IR. It can be seen as a program assignment graph (PAG)
47
+ */
48
+ class IRGraph : public GenericGraph<SVFVar,SVFStmt>
49
+ {
50
+ public:
51
+ typedef Set<const SVFStmt*> PAGEdgeSet;
52
+ typedef Map<const Value*,PAGEdgeSet> ValueToEdgeMap;
53
+
54
+ protected:
55
+ SVFStmt::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap; // < SVFIR edge map containing all PAGEdges
56
+ SVFStmt::PAGKindToEdgeSetMapTy PTAPAGEdgeKindToSetMap; // < SVFIR edge map containing only pointer-related edges, i.e, both RHS and RHS are of pointer type
57
+ bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
58
+ NodeID nodeNumAfterPAGBuild; // initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
59
+ u32_t totalPTAPAGEdge;
60
+ ValueToEdgeMap valueToEdgeMap; ///< Map llvm::Values to all corresponding PAGEdges
61
+ SymbolTableInfo* symInfo;
62
+
63
+ /// Add a node into the graph
64
+ inline NodeID addNode(SVFVar* node, NodeID i)
65
+ {
66
+ addGNode(i,node);
67
+ return i;
68
+ }
69
+ /// Add an edge into the graph
70
+ bool addEdge(SVFVar* src, SVFVar* dst, SVFStmt* edge);
71
+
72
+ //// Return true if this edge exits
73
+ SVFStmt* hasNonlabeledEdge(SVFVar* src, SVFVar* dst, SVFStmt::PEDGEK kind);
74
+ /// Return true if this labeled edge exits, including store, call and load
75
+ /// two store edge can have same dst and src but located in different basic blocks, thus flags are needed to distinguish them
76
+ SVFStmt* hasLabeledEdge(SVFVar* src, SVFVar* dst, SVFStmt::PEDGEK kind, const ICFGNode* cs);
77
+ /// Return MultiOpndStmt since it has more than one operands (we use operand 2 here to make the flag)
78
+ SVFStmt* hasLabeledEdge(SVFVar* src, SVFVar* op1, SVFStmt::PEDGEK kind, const SVFVar* op2);
79
+
80
+ /// Map a value to a set of edges
81
+ inline void mapValueToEdge(const Value *V, SVFStmt *edge)
82
+ {
83
+ auto inserted = valueToEdgeMap.emplace(V, PAGEdgeSet{edge});
84
+ if (!inserted.second) {
85
+ inserted.first->second.emplace(edge);
86
+ }
87
+ }
88
+ /// get MemObj according to LLVM value
89
+ inline const MemObj* getMemObj(const Value* val) const{
90
+ return symInfo->getObj(symInfo->getObjSym(val));
91
+ }
92
+
93
+ public:
94
+ IRGraph(bool buildFromFile): fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0){
95
+ symInfo = SymbolTableInfo::SymbolInfo();
96
+ // insert dummy value if a correct value cannot be found
97
+ valueToEdgeMap[nullptr] = PAGEdgeSet();
98
+ }
99
+
100
+ virtual ~IRGraph();
101
+
102
+ /// Whether this SVFIR built from a txt file
103
+ inline bool isBuiltFromFile()
104
+ {
105
+ return fromFile;
106
+ }
107
+ /// Get all SVFIR Edges that corresponds to an LLVM value
108
+ inline const PAGEdgeSet& getValueEdges(const Value *V)
109
+ {
110
+ auto it = valueToEdgeMap.find(V);
111
+ if (it == valueToEdgeMap.end()) {
112
+ //special empty set
113
+ return valueToEdgeMap.at(nullptr);
114
+ }
115
+ return it->second;
116
+ }
117
+
118
+ /// Get SVFIR Node according to LLVM value
119
+ ///getNode - Return the node corresponding to the specified pointer.
120
+ inline NodeID getValueNode(const Value *V)
121
+ {
122
+ return symInfo->getValSym(V);
123
+ }
124
+ inline bool hasValueNode(const Value* V)
125
+ {
126
+ return symInfo->hasValSym(V);
127
+ }
128
+ /// getObject - Return the obj node id refer to the memory object for the
129
+ /// specified global, heap or alloca instruction according to llvm value.
130
+ inline NodeID getObjectNode(const Value *V)
131
+ {
132
+ return symInfo->getObjSym(V);
133
+ }
134
+ /// GetReturnNode - Return the unique node representing the return value of a function
135
+ inline NodeID getReturnNode(const SVFFunction* func) const
136
+ {
137
+ return symInfo->getRetSym(func->getLLVMFun());
138
+ }
139
+ /// getVarargNode - Return the unique node representing the variadic argument of a variadic function.
140
+ inline NodeID getVarargNode(const SVFFunction* func) const
141
+ {
142
+ return symInfo->getVarargSym(func->getLLVMFun());
143
+ }
144
+ inline NodeID getBlackHoleNode() const
145
+ {
146
+ return symInfo->blackholeSymID();
147
+ }
148
+ inline NodeID getConstantNode() const
149
+ {
150
+ return symInfo->constantSymID();
151
+ }
152
+ inline NodeID getBlkPtr() const
153
+ {
154
+ return symInfo->blkPtrSymID();
155
+ }
156
+ inline NodeID getNullPtr() const
157
+ {
158
+ return symInfo->nullPtrSymID();
159
+ }
160
+ inline const MemObj* getBlackHoleObj() const
161
+ {
162
+ return symInfo->getBlkObj();
163
+ }
164
+ inline const MemObj* getConstantObj() const
165
+ {
166
+ return symInfo->getConstantObj();
167
+ }
168
+
169
+ inline Size_t getValueNodeNum() const
170
+ {
171
+ return symInfo->valSyms().size();
172
+ }
173
+ inline Size_t getObjectNodeNum() const
174
+ {
175
+ return symInfo->idToObjMap().size();
176
+ }
177
+ inline u32_t getNodeNumAfterPAGBuild() const
178
+ {
179
+ return nodeNumAfterPAGBuild;
180
+ }
181
+ inline void setNodeNumAfterPAGBuild(u32_t num)
182
+ {
183
+ nodeNumAfterPAGBuild = num;
184
+ }
185
+
186
+ inline Size_t getPAGNodeNum() const
187
+ {
188
+ return nodeNum;
189
+ }
190
+ inline Size_t getPAGEdgeNum() const
191
+ {
192
+ return edgeNum;
193
+ }
194
+ inline Size_t getPTAPAGEdgeNum() const
195
+ {
196
+ return totalPTAPAGEdge;
197
+ }
198
+ /// Return graph name
199
+ inline std::string getGraphName() const
200
+ {
201
+ return "SVFIR";
202
+ }
203
+
204
+ /// Dump SVFIR
205
+ void dump(std::string name);
206
+
207
+ /// View graph from the debugger
208
+ void view();
209
+ };
210
+
211
+ }
212
+
213
+
214
+ namespace llvm
215
+ {
216
+
217
+ /* !
218
+ * GraphTraits specializations of SVFIR to be used for the generic graph algorithms.
219
+ * Provide graph traits for tranversing from a SVFIR node using standard graph traversals.
220
+ */
221
+ template<> struct GraphTraits<SVF::SVFVar*> : public GraphTraits<SVF::GenericNode<SVF::SVFVar,SVF::SVFStmt>* >
222
+ {
223
+ };
224
+
225
+ /// Inverse GraphTraits specializations for SVFIR node, it is used for inverse traversal.
226
+ template<> struct GraphTraits<Inverse<SVF::SVFVar *> > : public GraphTraits<Inverse<SVF::GenericNode<SVF::SVFVar,SVF::SVFStmt>* > >
227
+ {
228
+ };
229
+
230
+ template<> struct GraphTraits<SVF::IRGraph*> : public GraphTraits<SVF::GenericGraph<SVF::SVFVar,SVF::SVFStmt>* >
231
+ {
232
+ typedef SVF::SVFVar *NodeRef;
233
+ };
234
+
235
+ } // End namespace llvm
236
+ #endif /* IRGRAPH_H_ */
@@ -55,7 +55,7 @@ protected:
55
55
  NodeToRepMap norToRepMap; // for each *a construct a --> rep, i.e., mapping a node of to a rep node for online constraint solving
56
56
 
57
57
  public:
58
- OfflineConsG(PAG *p) : ConstraintGraph(p),
58
+ OfflineConsG(SVFIR *p) : ConstraintGraph(p),
59
59
  nodeToRefMap( {}), norToRepMap({})
60
60
  {
61
61
  buildOfflineCG();
@@ -369,7 +369,7 @@ protected:
369
369
  }
370
370
  else
371
371
  {
372
- assert((it->second == node->getId()) && "a PAG node can only have unique definition ");
372
+ assert((it->second == node->getId()) && "a SVFIR node can only have unique definition ");
373
373
  }
374
374
  }
375
375
  inline NodeID getDef(const MRVer* mvar) const
@@ -259,7 +259,7 @@ private:
259
259
  inline void resetDef(const PAGNode* pagNode, const SVFGNode* node)
260
260
  {
261
261
  PAGNodeToDefMapTy::iterator it = PAGNodeToDefMap.find(pagNode);
262
- assert(it != PAGNodeToDefMap.end() && "a PAG node doesn't have definition before");
262
+ assert(it != PAGNodeToDefMap.end() && "a SVFIR node doesn't have definition before");
263
263
  PAGNodeToDefMap[pagNode] = node->getId();
264
264
  }
265
265
 
@@ -290,11 +290,11 @@ private:
290
290
  //@{
291
291
  inline bool actualInOfIndCS(const ActualINSVFGNode* ai) const
292
292
  {
293
- return (PAG::getPAG()->isIndirectCallSites(ai->getCallSite()));
293
+ return (SVFIR::getPAG()->isIndirectCallSites(ai->getCallSite()));
294
294
  }
295
295
  inline bool actualOutOfIndCS(const ActualOUTSVFGNode* ao) const
296
296
  {
297
- return (PAG::getPAG()->isIndirectCallSites(ao->getCallSite()));
297
+ return (SVFIR::getPAG()->isIndirectCallSites(ao->getCallSite()));
298
298
  }
299
299
  //@}
300
300
 
@@ -31,7 +31,7 @@
31
31
  #define INCLUDE_UTIL_VFG_H_
32
32
 
33
33
 
34
- #include "Graphs/PAG.h"
34
+ #include "MemoryModel/SVFIR.h"
35
35
  #include "Graphs/PTACallGraph.h"
36
36
  #include "Graphs/VFGNode.h"
37
37
  #include "Graphs/VFGEdge.h"
@@ -68,6 +68,7 @@ public:
68
68
  typedef Map<const PAGNode*, IntraPHIVFGNode*> PAGNodeToPHIVFGNodeMapTy;
69
69
  typedef Map<const PAGNode*, BinaryOPVFGNode*> PAGNodeToBinaryOPVFGNodeMapTy;
70
70
  typedef Map<const PAGNode*, UnaryOPVFGNode*> PAGNodeToUnaryOPVFGNodeMapTy;
71
+ typedef Map<const PAGNode*, BranchVFGNode*> PAGNodeToBranchVFGNodeMapTy;
71
72
  typedef Map<const PAGNode*, CmpVFGNode*> PAGNodeToCmpVFGNodeMapTy;
72
73
  typedef Map<const SVFFunction*, VFGNodeSet > FunToVFGNodesMapTy;
73
74
 
@@ -78,7 +79,7 @@ public:
78
79
  typedef VFGEdge::VFGEdgeSetTy::iterator VFGNodeIter;
79
80
  typedef VFGNodeIDToNodeMapTy::iterator iterator;
80
81
  typedef VFGNodeIDToNodeMapTy::const_iterator const_iterator;
81
- typedef PAG::PAGEdgeSet PAGEdgeSet;
82
+ typedef SVFIR::PAGEdgeSet PAGEdgeSet;
82
83
  typedef Set<const VFGNode*> GlobalVFGNodeSet;
83
84
  typedef Set<const PAGNode*> PAGNodeSet;
84
85
 
@@ -93,13 +94,14 @@ protected:
93
94
  PAGNodeToPHIVFGNodeMapTy PAGNodeToIntraPHIVFGNodeMap; ///< map a PAGNode to its PHIVFGNode
94
95
  PAGNodeToBinaryOPVFGNodeMapTy PAGNodeToBinaryOPVFGNodeMap; ///< map a PAGNode to its BinaryOPVFGNode
95
96
  PAGNodeToUnaryOPVFGNodeMapTy PAGNodeToUnaryOPVFGNodeMap; ///< map a PAGNode to its UnaryOPVFGNode
97
+ PAGNodeToBranchVFGNodeMapTy PAGNodeToBranchVFGNodeMap; ///< map a PAGNode to its BranchVFGNode
96
98
  PAGNodeToCmpVFGNodeMapTy PAGNodeToCmpVFGNodeMap; ///< map a PAGNode to its CmpVFGNode
97
99
  PAGEdgeToStmtVFGNodeMapTy PAGEdgeToStmtVFGNodeMap; ///< map a PAGEdge to its StmtVFGNode
98
100
  FunToVFGNodesMapTy funToVFGNodesMap; ///< map a function to its VFGNodes;
99
101
 
100
102
  GlobalVFGNodeSet globalVFGNodes; ///< set of global store VFG nodes
101
103
  PTACallGraph* callgraph;
102
- PAG* pag;
104
+ SVFIR* pag;
103
105
  VFGK kind;
104
106
 
105
107
  /// Clean up memory
@@ -127,8 +129,8 @@ public:
127
129
  return (kind == PTRONLYSVFG) || (kind == PTRONLYSVFG_OPT);
128
130
  }
129
131
 
130
- /// Return PAG
131
- inline PAG* getPAG() const
132
+ /// Return SVFIR
133
+ inline SVFIR* getPAG() const
132
134
  {
133
135
  return pag;
134
136
  }
@@ -218,6 +220,12 @@ public:
218
220
  assert(it != PAGNodeToUnaryOPVFGNodeMap.end() && "UnaryOPVFGNode can not be found??");
219
221
  return it->second;
220
222
  }
223
+ inline BranchVFGNode* getBranchVFGNode(const PAGNode* pagNode) const
224
+ {
225
+ PAGNodeToBranchVFGNodeMapTy::const_iterator it = PAGNodeToBranchVFGNodeMap.find(pagNode);
226
+ assert(it != PAGNodeToBranchVFGNodeMap.end() && "BranchVFGNode can not be found??");
227
+ return it->second;
228
+ }
221
229
  inline CmpVFGNode* getCmpVFGNode(const PAGNode* pagNode) const
222
230
  {
223
231
  PAGNodeToCmpVFGNodeMapTy::const_iterator it = PAGNodeToCmpVFGNodeMap.find(pagNode);
@@ -261,12 +269,12 @@ public:
261
269
  const VFGNode* defNode = getVFGNode(getDef(pagNode));
262
270
  if (const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(defNode))
263
271
  {
264
- if (PAG::getPAG()->isBlkObjOrConstantObj(addr->getPAGEdge()->getSrcID()))
272
+ if (SVFIR::getPAG()->isBlkObjOrConstantObj(addr->getPAGEdge()->getSrcID()))
265
273
  return true;
266
274
  }
267
275
  else if(const CopyVFGNode* copy = SVFUtil::dyn_cast<CopyVFGNode>(defNode))
268
276
  {
269
- if (PAG::getPAG()->isNullPtr(copy->getPAGEdge()->getSrcID()))
277
+ if (SVFIR::getPAG()->isNullPtr(copy->getPAGEdge()->getSrcID()))
270
278
  return true;
271
279
  }
272
280
  }
@@ -400,13 +408,13 @@ protected:
400
408
  }
401
409
  else
402
410
  {
403
- assert((it->second == node->getId()) && "a PAG node can only have unique definition ");
411
+ assert((it->second == node->getId()) && "a SVFIR node can only have unique definition ");
404
412
  }
405
413
  }
406
414
  inline NodeID getDef(const PAGNode* pagNode) const
407
415
  {
408
416
  PAGNodeToDefMapTy::const_iterator it = PAGNodeToDefMap.find(pagNode);
409
- assert(it!=PAGNodeToDefMap.end() && "PAG node does not have a definition??");
417
+ assert(it!=PAGNodeToDefMap.end() && "SVFIR node does not have a definition??");
410
418
  return it->second;
411
419
  }
412
420
  inline bool hasDef(const PAGNode* pagNode) const
@@ -503,7 +511,7 @@ protected:
503
511
  setDef(load->getDstNode(),sNode);
504
512
  }
505
513
  /// Add a Store VFG node,
506
- /// To be noted store does not create a new pointer, we do not set def for any PAG node
514
+ /// To be noted store does not create a new pointer, we do not set def for any SVFIR node
507
515
  void addStoreVFGNode(const StorePE* store)
508
516
  {
509
517
  StoreVFGNode* sNode = new StoreVFGNode(totalVFGNode++,store);
@@ -545,7 +553,7 @@ protected:
545
553
  PAGNodeToFormalRetMap[uniqueFunRet] = sNode;
546
554
  /// if this uniqueFunRet is a phi node, which means it will receive values from multiple return instructions of fun
547
555
  /// we will set this phi node's def later
548
- /// Ideally, every function uniqueFunRet should be a PhiNode (PAGBuilder.cpp), unless it does not have ret instruction
556
+ /// Ideally, every function uniqueFunRet should be a PhiNode (SVFIRBuilder.cpp), unless it does not have ret instruction
549
557
  if (!pag->isPhiNode(uniqueFunRet)){
550
558
  std::string warn = fun->getName().str();
551
559
  SVFUtil::writeWrnMsg(warn + " does not have any ret instruction!");
@@ -561,70 +569,63 @@ protected:
561
569
  PAGNodeToActualRetMap[ret] = sNode;
562
570
  }
563
571
  /// Add an llvm PHI VFG node
564
- inline void addIntraPHIVFGNode(const PAGNode* phiResNode, PAG::CopyPEList& oplist)
572
+ inline void addIntraPHIVFGNode(const PhiPE* edge)
565
573
  {
566
- IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,phiResNode);
574
+ IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,edge->getRes());
567
575
  u32_t pos = 0;
568
- const PAGEdge* edge = nullptr;
569
- for(PAG::CopyPEList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
576
+ for(auto var : edge->getOpndVars())
570
577
  {
571
- edge = *it;
572
- sNode->setOpVerAndBB(pos, edge->getSrcNode(), edge->getICFGNode());
578
+ sNode->setOpVerAndBB(pos, var, edge->getICFGNode());
579
+ pos++;
573
580
  }
574
- assert(edge && "edge not found?");
575
581
  addVFGNode(sNode,edge->getICFGNode());
576
- setDef(phiResNode,sNode);
577
- PAGNodeToIntraPHIVFGNodeMap[phiResNode] = sNode;
582
+ setDef(edge->getRes(),sNode);
583
+ PAGNodeToIntraPHIVFGNodeMap[edge->getRes()] = sNode;
578
584
  }
579
585
  /// Add a Compare VFG node
580
- inline void addCmpVFGNode(const PAGNode* resNode, PAG::CmpPEList& oplist)
586
+ inline void addCmpVFGNode(const CmpPE* edge)
581
587
  {
582
- CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, resNode);
588
+ CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, edge->getRes());
583
589
  u32_t pos = 0;
584
- const PAGEdge* edge = nullptr;
585
- for(PAG::CmpPEList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
590
+ for(auto var : edge->getOpndVars())
586
591
  {
587
- edge = *it;
588
- sNode->setOpVer(pos, edge->getSrcNode());
592
+ sNode->setOpVer(pos, var);
593
+ pos++;
589
594
  }
590
- assert(edge && "edge not found?");
591
595
  addVFGNode(sNode,edge->getICFGNode());
592
- setDef(resNode,sNode);
593
- PAGNodeToCmpVFGNodeMap[resNode] = sNode;
596
+ setDef(edge->getRes(),sNode);
597
+ PAGNodeToCmpVFGNodeMap[edge->getRes()] = sNode;
594
598
  }
595
599
  /// Add a BinaryOperator VFG node
596
- inline void addBinaryOPVFGNode(const PAGNode* resNode, PAG::BinaryOPList& oplist)
600
+ inline void addBinaryOPVFGNode(const BinaryOPPE* edge)
597
601
  {
598
- BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, resNode);
602
+ BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, edge->getRes());
599
603
  u32_t pos = 0;
600
- const PAGEdge* edge = nullptr;
601
- for(PAG::BinaryOPList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
604
+ for(auto var : edge->getOpndVars())
602
605
  {
603
- edge = *it;
604
- sNode->setOpVer(pos, (*it)->getSrcNode());
606
+ sNode->setOpVer(pos, var);
607
+ pos++;
605
608
  }
606
-
607
- assert(edge && "edge not found?");
608
609
  addVFGNode(sNode,edge->getICFGNode());
609
- setDef(resNode,sNode);
610
- PAGNodeToBinaryOPVFGNodeMap[resNode] = sNode;
610
+ setDef(edge->getRes(),sNode);
611
+ PAGNodeToBinaryOPVFGNodeMap[edge->getRes()] = sNode;
611
612
  }
612
613
  /// Add a UnaryOperator VFG node
613
- inline void addUnaryOPVFGNode(const PAGNode* resNode, PAG::UnaryOPList& oplist)
614
+ inline void addUnaryOPVFGNode(const UnaryOPPE* edge)
614
615
  {
615
- UnaryOPVFGNode* sNode = new UnaryOPVFGNode(totalVFGNode++, resNode);
616
- u32_t pos = 0;
617
- const PAGEdge* edge = nullptr;
618
- for(PAG::UnaryOPList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
619
- {
620
- edge = *it;
621
- sNode->setOpVer(pos, (*it)->getSrcNode());
622
- }
623
-
624
- assert(edge && "edge not found?");
616
+ UnaryOPVFGNode* sNode = new UnaryOPVFGNode(totalVFGNode++, edge->getRes());
617
+ sNode->setOpVer(0, edge->getOpVar());
618
+ addVFGNode(sNode,edge->getICFGNode());
619
+ setDef(edge->getRes(),sNode);
620
+ PAGNodeToUnaryOPVFGNodeMap[edge->getRes()] = sNode;
621
+ }
622
+ /// Add a BranchVFGNode
623
+ inline void addBranchVFGNode(const BranchStmt* edge)
624
+ {
625
+ BranchVFGNode* sNode = new BranchVFGNode(totalVFGNode++, edge);
625
626
  addVFGNode(sNode,edge->getICFGNode());
626
- setDef(resNode,sNode);
627
- PAGNodeToUnaryOPVFGNodeMap[resNode] = sNode;
627
+ setDef(edge->getBranchInst(),sNode);
628
+ PAGNodeToBranchVFGNodeMap[edge->getBranchInst()] = sNode;
628
629
  }
629
630
  };
630
631