svf-lib 1.0.735 → 1.0.736

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.
Binary file
@@ -108,7 +108,7 @@ public:
108
108
  }
109
109
  } equalGEdge;
110
110
 
111
- inline bool operator==(const GenericEdge<NodeType>* rhs) const
111
+ virtual inline bool operator==(const GenericEdge<NodeType>* rhs) const
112
112
  {
113
113
  return (rhs->edgeFlag == this->edgeFlag && rhs->getSrcID() == this->getSrcID()
114
114
  && rhs->getDstID() == this->getDstID());
@@ -51,16 +51,15 @@ public:
51
51
  typedef Set<const SVFStmt*> PAGEdgeSet;
52
52
  typedef Map<const Value*,PAGEdgeSet> ValueToEdgeMap;
53
53
 
54
- private:
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
55
57
  bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
56
58
  NodeID nodeNumAfterPAGBuild; // initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
57
59
  u32_t totalPTAPAGEdge;
58
- SVFStmt::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap; // < SVFIR edge map containing all PAGEdges
59
- SVFStmt::PAGKindToEdgeSetMapTy PTAPAGEdgeKindToSetMap; // < SVFIR edge map containing only pointer-related edges, i.e, both RHS and RHS are of pointer type
60
60
  ValueToEdgeMap valueToEdgeMap; ///< Map llvm::Values to all corresponding PAGEdges
61
61
  SymbolTableInfo* symInfo;
62
62
 
63
- protected:
64
63
  /// Add a node into the graph
65
64
  inline NodeID addNode(SVFVar* node, NodeID i)
66
65
  {
@@ -75,6 +74,9 @@ protected:
75
74
  /// Return true if this labeled edge exits, including store, call and load
76
75
  /// two store edge can have same dst and src but located in different basic blocks, thus flags are needed to distinguish them
77
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
+
78
80
  /// Map a value to a set of edges
79
81
  inline void mapValueToEdge(const Value *V, SVFStmt *edge)
80
82
  {
@@ -102,17 +104,6 @@ public:
102
104
  {
103
105
  return fromFile;
104
106
  }
105
- /// Get edges set according to its kind
106
- inline SVFStmt::PAGEdgeSetTy& getEdgeSet(SVFStmt::PEDGEK kind)
107
- {
108
- return PAGEdgeKindToSetMap[kind];
109
- }
110
- /// Get PTA edges set according to its kind
111
- inline SVFStmt::PAGEdgeSetTy& getPTAEdgeSet(SVFStmt::PEDGEK kind)
112
- {
113
- return PTAPAGEdgeKindToSetMap[kind];
114
- }
115
-
116
107
  /// Get all SVFIR Edges that corresponds to an LLVM value
117
108
  inline const PAGEdgeSet& getValueEdges(const Value *V)
118
109
  {
@@ -561,70 +561,55 @@ protected:
561
561
  PAGNodeToActualRetMap[ret] = sNode;
562
562
  }
563
563
  /// Add an llvm PHI VFG node
564
- inline void addIntraPHIVFGNode(const PAGNode* phiResNode, SVFIR::CopyPEList& oplist)
564
+ inline void addIntraPHIVFGNode(const PhiPE* edge)
565
565
  {
566
- IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,phiResNode);
566
+ IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,edge->getRes());
567
567
  u32_t pos = 0;
568
- const PAGEdge* edge = nullptr;
569
- for(SVFIR::CopyPEList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
568
+ for(auto var : edge->getOpndVars())
570
569
  {
571
- edge = *it;
572
- sNode->setOpVerAndBB(pos, edge->getSrcNode(), edge->getICFGNode());
570
+ sNode->setOpVerAndBB(pos, var, edge->getICFGNode());
571
+ pos++;
573
572
  }
574
- assert(edge && "edge not found?");
575
573
  addVFGNode(sNode,edge->getICFGNode());
576
- setDef(phiResNode,sNode);
577
- PAGNodeToIntraPHIVFGNodeMap[phiResNode] = sNode;
574
+ setDef(edge->getRes(),sNode);
575
+ PAGNodeToIntraPHIVFGNodeMap[edge->getRes()] = sNode;
578
576
  }
579
577
  /// Add a Compare VFG node
580
- inline void addCmpVFGNode(const PAGNode* resNode, SVFIR::CmpPEList& oplist)
578
+ inline void addCmpVFGNode(const CmpPE* edge)
581
579
  {
582
- CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, resNode);
580
+ CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, edge->getRes());
583
581
  u32_t pos = 0;
584
- const PAGEdge* edge = nullptr;
585
- for(SVFIR::CmpPEList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
582
+ for(auto var : edge->getOpndVars())
586
583
  {
587
- edge = *it;
588
- sNode->setOpVer(pos, edge->getSrcNode());
584
+ sNode->setOpVer(pos, var);
585
+ pos++;
589
586
  }
590
- assert(edge && "edge not found?");
591
587
  addVFGNode(sNode,edge->getICFGNode());
592
- setDef(resNode,sNode);
593
- PAGNodeToCmpVFGNodeMap[resNode] = sNode;
588
+ setDef(edge->getRes(),sNode);
589
+ PAGNodeToCmpVFGNodeMap[edge->getRes()] = sNode;
594
590
  }
595
591
  /// Add a BinaryOperator VFG node
596
- inline void addBinaryOPVFGNode(const PAGNode* resNode, SVFIR::BinaryOPList& oplist)
592
+ inline void addBinaryOPVFGNode(const BinaryOPPE* edge)
597
593
  {
598
- BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, resNode);
594
+ BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, edge->getRes());
599
595
  u32_t pos = 0;
600
- const PAGEdge* edge = nullptr;
601
- for(SVFIR::BinaryOPList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
596
+ for(auto var : edge->getOpndVars())
602
597
  {
603
- edge = *it;
604
- sNode->setOpVer(pos, (*it)->getSrcNode());
598
+ sNode->setOpVer(pos, var);
599
+ pos++;
605
600
  }
606
-
607
- assert(edge && "edge not found?");
608
601
  addVFGNode(sNode,edge->getICFGNode());
609
- setDef(resNode,sNode);
610
- PAGNodeToBinaryOPVFGNodeMap[resNode] = sNode;
602
+ setDef(edge->getRes(),sNode);
603
+ PAGNodeToBinaryOPVFGNodeMap[edge->getRes()] = sNode;
611
604
  }
612
605
  /// Add a UnaryOperator VFG node
613
- inline void addUnaryOPVFGNode(const PAGNode* resNode, SVFIR::UnaryOPList& oplist)
606
+ inline void addUnaryOPVFGNode(const UnaryOPPE* edge)
614
607
  {
615
- UnaryOPVFGNode* sNode = new UnaryOPVFGNode(totalVFGNode++, resNode);
616
- u32_t pos = 0;
617
- const PAGEdge* edge = nullptr;
618
- for(SVFIR::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?");
608
+ UnaryOPVFGNode* sNode = new UnaryOPVFGNode(totalVFGNode++, edge->getDstNode());
609
+ sNode->setOpVer(0, edge->getSrcNode());
625
610
  addVFGNode(sNode,edge->getICFGNode());
626
- setDef(resNode,sNode);
627
- PAGNodeToUnaryOPVFGNodeMap[resNode] = sNode;
611
+ setDef(edge->getDstNode(),sNode);
612
+ PAGNodeToUnaryOPVFGNodeMap[edge->getDstNode()] = sNode;
628
613
  }
629
614
  };
630
615
 
@@ -330,7 +330,7 @@ public:
330
330
  CmpVFGNode(NodeID id,const PAGNode* r): VFGNode(id,Cmp), res(r)
331
331
  {
332
332
  const CmpInst* cmp = SVFUtil::dyn_cast<CmpInst>(r->getValue());
333
- assert(cmp && "not a binary operator?");
333
+ assert(cmp && "not a compare operator?");
334
334
  }
335
335
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
336
336
  //@{
@@ -1091,7 +1091,7 @@ public:
1091
1091
  return node->isPointer();
1092
1092
  }
1093
1093
  /// Return corresponding PAGNode
1094
- const PAGNode* getGNode() const
1094
+ const PAGNode* getPAGNode() const
1095
1095
  {
1096
1096
  return node;
1097
1097
  }
@@ -56,13 +56,7 @@ public:
56
56
  typedef std::vector<const SVFStmt*> PAGEdgeList;
57
57
  typedef std::vector<const SVFVar*> PAGNodeList;
58
58
  typedef std::vector<const CopyPE*> CopyPEList;
59
- typedef std::vector<const BinaryOPPE*> BinaryOPList;
60
- typedef std::vector<const UnaryOPPE*> UnaryOPList;
61
- typedef std::vector<const CmpPE*> CmpPEList;
62
- typedef Map<const SVFVar*,CopyPEList> PHINodeMap;
63
- typedef Map<const SVFVar*,BinaryOPList> BinaryNodeMap;
64
- typedef Map<const SVFVar*,UnaryOPList> UnaryNodeMap;
65
- typedef Map<const SVFVar*,CmpPEList> CmpNodeMap;
59
+ typedef Map<const SVFVar*,PhiPE*> PHINodeMap;
66
60
  typedef Map<const SVFFunction*,PAGNodeList> FunToArgsListMap;
67
61
  typedef Map<const CallBlockNode*,PAGNodeList> CSToArgsListMap;
68
62
  typedef Map<const RetBlockNode*,const SVFVar*> CSToRetMap;
@@ -87,9 +81,6 @@ private:
87
81
  MemObjToFieldsMap memToFieldsMap; ///< Map a mem object id to all its fields
88
82
  PAGEdgeSet globPAGEdgesSet; ///< Global PAGEdges without control flow information
89
83
  PHINodeMap phiNodeMap; ///< A set of phi copy edges
90
- BinaryNodeMap binaryNodeMap; ///< A set of binary edges
91
- UnaryNodeMap unaryNodeMap; ///< A set of unary edges
92
- CmpNodeMap cmpNodeMap; ///< A set of comparision edges
93
84
  FunToArgsListMap funArgsListMap; ///< Map a function to a list of all its formal parameters
94
85
  CSToArgsListMap callSiteArgsListMap; ///< Map a callsite to a list of all its actual parameters
95
86
  CSToRetMap callSiteRetMap; ///< Map a callsite to its callsite returns PAGNodes
@@ -166,16 +157,18 @@ public:
166
157
  {
167
158
  return SymbolTableInfo::SymbolInfo()->getModule();
168
159
  }
169
- inline void addCallSite(const CallBlockNode* call)
160
+ /// Get/set methods to get SVFStmts based on their kinds and ICFGNodes
161
+ //@{
162
+ /// Get edges set according to its kind
163
+ inline SVFStmt::PAGEdgeSetTy& getEdgeSet(SVFStmt::PEDGEK kind)
170
164
  {
171
- callSiteSet.insert(call);
165
+ return PAGEdgeKindToSetMap[kind];
172
166
  }
173
- inline const CallSiteSet& getCallSiteSet() const
167
+ /// Get PTA edges set according to its kind
168
+ inline SVFStmt::PAGEdgeSetTy& getPTAEdgeSet(SVFStmt::PEDGEK kind)
174
169
  {
175
- return callSiteSet;
170
+ return PTAPAGEdgeKindToSetMap[kind];
176
171
  }
177
- /// Get/set methods to get control flow information of a SVFStmt
178
- //@{
179
172
  /// Whether this instruction has SVFIR Edge
180
173
  inline bool hasPAGEdgeList(const ICFGNode* inst) const
181
174
  {
@@ -213,93 +206,31 @@ public:
213
206
  {
214
207
  return globPAGEdgesSet;
215
208
  }
216
- /// Add phi node information
217
- inline void addPhiNode(const SVFVar* res, const CopyPE* edge)
218
- {
219
- phiNodeMap[res].push_back(edge);
220
- }
221
- /// Whether this SVFVar is a result operand a of phi node
222
- inline bool isPhiNode(const SVFVar* node) const
223
- {
224
- return phiNodeMap.find(node) != phiNodeMap.end();
225
- }
226
- /// Get all phi copy edges
227
- inline PHINodeMap& getPhiNodeMap()
228
- {
229
- return phiNodeMap;
230
- }
231
- /// Get the corresponding PhiCopyPEs
232
- inline const CopyPEList& getPhiCopyPEs(const SVFVar* node) const{
233
- PHINodeMap::const_iterator it = phiNodeMap.find(node);
234
- assert(it != phiNodeMap.end() && "PhiCopyPEs not found!");
235
- return it->second;
236
- }
237
- /// Add phi node information
238
- inline void addBinaryNode(const SVFVar* res, const BinaryOPPE* edge)
239
- {
240
- binaryNodeMap[res].push_back(edge);
241
- }
242
- /// Whether this SVFVar is a result operand a of phi node
243
- inline bool isBinaryNode(const SVFVar* node) const
244
- {
245
- return binaryNodeMap.find(node) != binaryNodeMap.end();
246
- }
247
- /// Get all phi copy edges
248
- inline BinaryNodeMap& getBinaryNodeMap()
249
- {
250
- return binaryNodeMap;
251
- }
252
- /// Get the corresponding BinaryPEs
253
- inline const BinaryOPList& getBinaryPEs(const SVFVar* node) const{
254
- BinaryNodeMap::const_iterator it = binaryNodeMap.find(node);
255
- assert(it != binaryNodeMap.end() && "BinaryPEs not found!");
256
- return it->second;
257
- }
258
- /// Add unary node information
259
- inline void addUnaryNode(const SVFVar* res, const UnaryOPPE* edge)
260
- {
261
- unaryNodeMap[res].push_back(edge);
262
- }
263
- /// Whether this SVFVar is an unary node
264
- inline bool isUnaryNode(const SVFVar* node) const
265
- {
266
- return unaryNodeMap.find(node) != unaryNodeMap.end();
267
- }
268
- /// Get all unary edges
269
- inline UnaryNodeMap& getUnaryNodeMap()
209
+ inline void addCallSite(const CallBlockNode* call)
270
210
  {
271
- return unaryNodeMap;
272
- }
273
- /// Get the corresponding UnaryPEs
274
- inline const UnaryOPList& getUnaryPEs(const SVFVar* node) const{
275
- UnaryNodeMap::const_iterator it = unaryNodeMap.find(node);
276
- assert(it != unaryNodeMap.end() && "UnaryPEs not found!");
277
- return it->second;
211
+ callSiteSet.insert(call);
278
212
  }
279
- /// Add phi node information
280
- inline void addCmpNode(const SVFVar* res, const CmpPE* edge)
213
+ inline const CallSiteSet& getCallSiteSet() const
281
214
  {
282
- cmpNodeMap[res].push_back(edge);
215
+ return callSiteSet;
283
216
  }
284
217
  /// Whether this SVFVar is a result operand a of phi node
285
- inline bool isCmpNode(const SVFVar* node) const
286
- {
287
- return cmpNodeMap.find(node) != cmpNodeMap.end();
288
- }
289
- /// Get all phi copy edges
290
- inline CmpNodeMap& getCmpNodeMap()
218
+ inline bool isPhiNode(const SVFVar* node) const
291
219
  {
292
- return cmpNodeMap;
293
- }
294
- /// Get the corresponding CmpPEs
295
- inline const CmpPEList& getCmpPEs(const SVFVar* node) const{
296
- CmpNodeMap::const_iterator it = cmpNodeMap.find(node);
297
- assert(it != cmpNodeMap.end() && "CmpPEs not found!");
298
- return it->second;
220
+ return phiNodeMap.find(node) != phiNodeMap.end();
299
221
  }
300
- //@}
301
222
 
302
223
  private:
224
+ /// Map a SVFStatement type to a set of corresponding SVF statements
225
+ inline void addToStmt2TypeMap(SVFStmt* edge) {
226
+ bool added = PAGEdgeKindToSetMap[edge->getEdgeKind()].insert(edge).second;
227
+ assert(added && "duplicated edge, not added!!!");
228
+ if (edge->isPTAEdge())
229
+ {
230
+ totalPTAPAGEdge++;
231
+ PTAPAGEdgeKindToSetMap[edge->getEdgeKind()].insert(edge);
232
+ }
233
+ }
303
234
  /// Get/set method for function/callsite arguments and returns
304
235
  //@{
305
236
  /// Add function arguments
@@ -680,10 +611,12 @@ private:
680
611
  AddrPE* addAddrPE(NodeID src, NodeID dst);
681
612
  /// Add Copy edge
682
613
  CopyPE* addCopyPE(NodeID src, NodeID dst);
614
+ /// Add phi node information
615
+ PhiPE* addPhiNode(NodeID res, NodeID opnd);
683
616
  /// Add Copy edge
684
- CmpPE* addCmpPE(NodeID src, NodeID dst);
617
+ CmpPE* addCmpPE(NodeID op1, NodeID op2, NodeID dst);
685
618
  /// Add Copy edge
686
- BinaryOPPE* addBinaryOPPE(NodeID src, NodeID dst);
619
+ BinaryOPPE* addBinaryOPPE(NodeID op1, NodeID op2, NodeID dst);
687
620
  /// Add Unary edge
688
621
  UnaryOPPE* addUnaryOPPE(NodeID src, NodeID dst);
689
622
  /// Add Load edge
@@ -53,7 +53,7 @@ public:
53
53
  /// ThreadFork/ThreadJoin is to model parameter passings between thread spawners and spawnees.
54
54
  enum PEDGEK
55
55
  {
56
- Addr, Copy, Store, Load, Call, Ret, NormalGep, VariantGep, ThreadFork, ThreadJoin, Cmp, BinaryOp, UnaryOp
56
+ Addr, Copy, Store, Load, Call, Ret, NormalGep, VariantGep, Phi, Cmp, BinaryOp, UnaryOp, ThreadFork, ThreadJoin
57
57
  };
58
58
 
59
59
  private:
@@ -87,11 +87,11 @@ public:
87
87
  edge->getEdgeKind() == SVFStmt::Ret ||
88
88
  edge->getEdgeKind() == SVFStmt::NormalGep ||
89
89
  edge->getEdgeKind() == SVFStmt::VariantGep ||
90
- edge->getEdgeKind() == SVFStmt::ThreadFork ||
91
- edge->getEdgeKind() == SVFStmt::ThreadJoin ||
92
90
  edge->getEdgeKind() == SVFStmt::Cmp ||
93
91
  edge->getEdgeKind() == SVFStmt::BinaryOp ||
94
- edge->getEdgeKind() == SVFStmt::UnaryOp;
92
+ edge->getEdgeKind() == SVFStmt::UnaryOp ||
93
+ edge->getEdgeKind() == SVFStmt::ThreadFork ||
94
+ edge->getEdgeKind() == SVFStmt::ThreadJoin;
95
95
  }
96
96
  ///@}
97
97
 
@@ -135,6 +135,15 @@ public:
135
135
  }
136
136
  //@}
137
137
 
138
+ /// Compute the unique edgeFlag value from edge kind and second variable operand for MultiOpndStmt.
139
+ static inline GEdgeFlag makeEdgeFlagWithAddionalOpnd(GEdgeKind k, const SVFVar* var)
140
+ {
141
+ Var2LabelMap::const_iterator iter = var2LabelMap.find(var);
142
+ u64_t label = (iter != var2LabelMap.end()) ?
143
+ iter->second : multiOpndLabelCounter++;
144
+ return (label << EdgeKindMaskBits) | k;
145
+ }
146
+
138
147
  /// Compute the unique edgeFlag value from edge kind and call site Instruction.
139
148
  static inline GEdgeFlag makeEdgeFlagWithCallInst(GEdgeKind k, const ICFGNode* cs)
140
149
  {
@@ -172,13 +181,15 @@ public:
172
181
 
173
182
  private:
174
183
  typedef Map<const ICFGNode*, u32_t> Inst2LabelMap;
184
+ typedef Map<const SVFVar*, u32_t> Var2LabelMap;
175
185
  static Inst2LabelMap inst2LabelMap; ///< Call site Instruction to label map
186
+ static Var2LabelMap var2LabelMap; ///< Second operand of MultiOpndStmt to label map
176
187
  static u64_t callEdgeLabelCounter; ///< Call site Instruction counter
177
188
  static u64_t storeEdgeLabelCounter; ///< Store Instruction counter
189
+ static u64_t multiOpndLabelCounter; ///< MultiOpndStmt counter
178
190
  };
179
191
 
180
192
 
181
-
182
193
  /*!
183
194
  * Copy edge
184
195
  */
@@ -210,7 +221,7 @@ public:
210
221
  {
211
222
  }
212
223
 
213
- virtual const std::string toString() const;
224
+ virtual const std::string toString() const override;
214
225
  };
215
226
 
216
227
 
@@ -245,19 +256,131 @@ public:
245
256
  {
246
257
  }
247
258
 
248
- virtual const std::string toString() const;
259
+ virtual const std::string toString() const override;
260
+ };
261
+
262
+ class MultiOpndStmt : public SVFStmt{
263
+ public:
264
+ typedef std::vector<SVFVar*> OPVars;
265
+ protected:
266
+ OPVars opVars;
267
+ public:
268
+ /// Constructor, only used by subclassess but not external users
269
+ MultiOpndStmt(SVFVar* r, const OPVars& opnds, GEdgeFlag k): SVFStmt(opnds.at(0), r, k), opVars(opnds)
270
+ {
271
+ }
272
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
273
+ //@{
274
+ static inline bool classof(const MultiOpndStmt *)
275
+ {
276
+ return true;
277
+ }
278
+ static inline bool classof(const SVFStmt *node)
279
+ {
280
+ return node->getEdgeKind() == Phi ||
281
+ node->getEdgeKind() == BinaryOp ||
282
+ node->getEdgeKind() == Cmp;
283
+ }
284
+ static inline bool classof(const GenericPAGEdgeTy *node)
285
+ {
286
+ return node->getEdgeKind() == Phi ||
287
+ node->getEdgeKind() == BinaryOp ||
288
+ node->getEdgeKind() == Cmp;
289
+ }
290
+ //@}
291
+ /// Operands and result at a BinaryNode e.g., p = q + r, `p` is resVar and `r` is OpVar
292
+ //@{
293
+ /// Operand SVFVars
294
+ inline const SVFVar* getOpVar(u32_t pos) const
295
+ {
296
+ return opVars.at(pos);
297
+ }
298
+ /// Result SVFVar
299
+ inline const SVFVar* getRes() const
300
+ {
301
+ return getDstNode();
302
+ }
303
+
304
+ NodeID getOpVarID(u32_t pos) const;
305
+ NodeID getResID() const;
306
+
307
+ inline u32_t getOpVarNum() const
308
+ {
309
+ return opVars.size();
310
+ }
311
+ inline const OPVars& getOpndVars() const{
312
+ return opVars;
313
+ }
314
+ inline OPVars::const_iterator opVarBegin() const
315
+ {
316
+ return opVars.begin();
317
+ }
318
+ inline OPVars::const_iterator opVerEnd() const
319
+ {
320
+ return opVars.end();
321
+ }
322
+ //@}
323
+ };
324
+
325
+ /*!
326
+ * Phi instruction edge
327
+ */
328
+ class PhiPE: public MultiOpndStmt
329
+ {
330
+ private:
331
+ PhiPE(); ///< place holder
332
+ PhiPE(const PhiPE &); ///< place holder
333
+ void operator=(const PhiPE &); ///< place holder
334
+ SVFVar* getSrcNode(); ///< place holder, not allowed since this SVFStmt has multiple operands but not a single source
335
+ SVFVar* getDstNode(); ///< place holder, use getRes() instead
336
+ SVFVar* getSrcID(); ///< place holder, use getOpVarID(pos) instead
337
+ SVFVar* getDstID(); ///< place holder, use getResID() instead
338
+
339
+ public:
340
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
341
+ //@{
342
+ static inline bool classof(const PhiPE *)
343
+ {
344
+ return true;
345
+ }
346
+ static inline bool classof(const SVFStmt *edge)
347
+ {
348
+ return edge->getEdgeKind() == SVFStmt::Phi;
349
+ }
350
+ static inline bool classof(const MultiOpndStmt *edge)
351
+ {
352
+ return edge->getEdgeKind() == SVFStmt::Phi;
353
+ }
354
+ static inline bool classof(const GenericPAGEdgeTy *edge)
355
+ {
356
+ return edge->getEdgeKind() == SVFStmt::Phi;
357
+ }
358
+ //@}
359
+
360
+ /// constructor
361
+ PhiPE(SVFVar* s, const OPVars& opnds) : MultiOpndStmt(s,opnds,SVFStmt::Phi)
362
+ {
363
+ }
364
+ void addOpVar(SVFVar* op){
365
+ opVars.push_back(op);
366
+ }
367
+ virtual const std::string toString() const override;
249
368
  };
250
369
 
251
370
 
252
371
  /*!
253
372
  * Compare instruction edge
254
373
  */
255
- class CmpPE: public SVFStmt
374
+ class CmpPE: public MultiOpndStmt
256
375
  {
257
376
  private:
258
377
  CmpPE(); ///< place holder
259
378
  CmpPE(const CmpPE &); ///< place holder
260
379
  void operator=(const CmpPE &); ///< place holder
380
+ SVFVar* getSrcNode(); ///< place holder, not allowed since this SVFStmt has multiple operands but not a single source
381
+ SVFVar* getDstNode(); ///< place holder, use getRes() instead
382
+ SVFVar* getSrcID(); ///< place holder, use getOpVarID(pos) instead
383
+ SVFVar* getDstID(); ///< place holder, use getResID() instead
261
384
  public:
262
385
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
263
386
  //@{
@@ -269,6 +392,10 @@ public:
269
392
  {
270
393
  return edge->getEdgeKind() == SVFStmt::Cmp;
271
394
  }
395
+ static inline bool classof(const MultiOpndStmt *edge)
396
+ {
397
+ return edge->getEdgeKind() == SVFStmt::Cmp;
398
+ }
272
399
  static inline bool classof(const GenericPAGEdgeTy *edge)
273
400
  {
274
401
  return edge->getEdgeKind() == SVFStmt::Cmp;
@@ -276,23 +403,27 @@ public:
276
403
  //@}
277
404
 
278
405
  /// constructor
279
- CmpPE(SVFVar* s, SVFVar* d) : SVFStmt(s,d,SVFStmt::Cmp)
406
+ CmpPE(SVFVar* s, const OPVars& opnds) : MultiOpndStmt(s,opnds,SVFStmt::Cmp)
280
407
  {
281
408
  }
282
-
283
- virtual const std::string toString() const;
409
+ virtual const std::string toString() const override;
284
410
  };
285
411
 
286
412
 
287
413
  /*!
288
414
  * Binary instruction edge
289
415
  */
290
- class BinaryOPPE: public SVFStmt
416
+ class BinaryOPPE: public MultiOpndStmt
291
417
  {
292
418
  private:
293
419
  BinaryOPPE(); ///< place holder
294
420
  BinaryOPPE(const BinaryOPPE &); ///< place holder
295
421
  void operator=(const BinaryOPPE &); ///< place holder
422
+ SVFVar* getSrcNode(); ///< place holder, not allowed since this SVFStmt has multiple operands but not a single source
423
+ SVFVar* getDstNode(); ///< place holder, use getRes() instead
424
+ SVFVar* getSrcID(); ///< place holder, use getOpVarID(pos) instead
425
+ SVFVar* getDstID(); ///< place holder, use getResID() instead
426
+
296
427
  public:
297
428
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
298
429
  //@{
@@ -304,6 +435,10 @@ public:
304
435
  {
305
436
  return edge->getEdgeKind() == SVFStmt::BinaryOp;
306
437
  }
438
+ static inline bool classof(const MultiOpndStmt *edge)
439
+ {
440
+ return edge->getEdgeKind() == SVFStmt::BinaryOp;
441
+ }
307
442
  static inline bool classof(const GenericPAGEdgeTy *edge)
308
443
  {
309
444
  return edge->getEdgeKind() == SVFStmt::BinaryOp;
@@ -311,11 +446,10 @@ public:
311
446
  //@}
312
447
 
313
448
  /// constructor
314
- BinaryOPPE(SVFVar* s, SVFVar* d) : SVFStmt(s,d,SVFStmt::BinaryOp)
449
+ BinaryOPPE(SVFVar* s, const OPVars& opnds) : MultiOpndStmt(s,opnds,SVFStmt::BinaryOp)
315
450
  {
316
451
  }
317
-
318
- virtual const std::string toString() const;
452
+ virtual const std::string toString() const override;
319
453
  };
320
454
 
321
455
  /*!
@@ -349,7 +483,7 @@ public:
349
483
  {
350
484
  }
351
485
 
352
- virtual const std::string toString() const;
486
+ virtual const std::string toString() const override;
353
487
  };
354
488
 
355
489
 
@@ -386,7 +520,7 @@ public:
386
520
  {
387
521
  }
388
522
 
389
- virtual const std::string toString() const;
523
+ virtual const std::string toString() const override;
390
524
  };
391
525
 
392
526
 
@@ -422,7 +556,7 @@ public:
422
556
  {
423
557
  }
424
558
 
425
- virtual const std::string toString() const;
559
+ virtual const std::string toString() const override;
426
560
  };
427
561
 
428
562
 
@@ -513,7 +647,7 @@ public:
513
647
  return ls;
514
648
  }
515
649
 
516
- virtual const std::string toString() const;
650
+ virtual const std::string toString() const override;
517
651
  };
518
652
 
519
653
  /*!
@@ -550,7 +684,7 @@ public:
550
684
  /// constructor
551
685
  VariantGepPE(SVFVar* s, SVFVar* d) : GepPE(s,d,SVFStmt::VariantGep) {}
552
686
 
553
- virtual const std::string toString() const;
687
+ virtual const std::string toString() const override;
554
688
 
555
689
  };
556
690
 
@@ -603,7 +737,7 @@ public:
603
737
  }
604
738
  //@}
605
739
 
606
- virtual const std::string toString() const;
740
+ virtual const std::string toString() const override;
607
741
  };
608
742
 
609
743
 
@@ -655,7 +789,7 @@ public:
655
789
  }
656
790
  //@}
657
791
 
658
- virtual const std::string toString() const;
792
+ virtual const std::string toString() const override;
659
793
  };
660
794
 
661
795
 
@@ -293,16 +293,24 @@ public:
293
293
  return edge;
294
294
  }
295
295
  /// Add Copy edge
296
- inline CmpPE* addCmpEdge(NodeID src, NodeID dst)
296
+ inline PhiPE* addPhiNode(NodeID res, NodeID opnd)
297
297
  {
298
- CmpPE *edge = pag->addCmpPE(src, dst);
298
+ const CopyPE* copy = addCopyEdge(opnd, res);
299
+ PhiPE *edge = pag->addPhiNode(res,opnd);
299
300
  setCurrentBBAndValueForPAGEdge(edge);
300
301
  return edge;
301
302
  }
302
303
  /// Add Copy edge
303
- inline BinaryOPPE* addBinaryOPEdge(NodeID src, NodeID dst)
304
+ inline CmpPE* addCmpEdge(NodeID op1, NodeID op2, NodeID dst)
304
305
  {
305
- BinaryOPPE *edge = pag->addBinaryOPPE(src, dst);
306
+ CmpPE *edge = pag->addCmpPE(op1, op2, dst);
307
+ setCurrentBBAndValueForPAGEdge(edge);
308
+ return edge;
309
+ }
310
+ /// Add Copy edge
311
+ inline BinaryOPPE* addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst)
312
+ {
313
+ BinaryOPPE *edge = pag->addBinaryOPPE(op1, op2, dst);
306
314
  setCurrentBBAndValueForPAGEdge(edge);
307
315
  return edge;
308
316
  }
@@ -385,8 +393,6 @@ public:
385
393
 
386
394
  };
387
395
 
388
- typedef SVFIRBuilder PAGBuilder;
389
-
390
396
  } // End namespace SVF
391
397
 
392
398
  #endif /* PAGBUILDER_H_ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.735",
3
+ "version": "1.0.736",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {