svf-lib 1.0.2509 → 1.0.2511

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
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -78,7 +78,7 @@ public:
78
78
  AddressValue getGepObjAddrs(u32_t pointer, IntervalValue offset);
79
79
 
80
80
  // initObjVar
81
- void initObjVar(ObjVar* objVar);
81
+ void initObjVar(const ObjVar* objVar);
82
82
  // getElementIndex
83
83
  IntervalValue getElementIndex(const GepStmt* gep);
84
84
  // getByteOffset
@@ -344,9 +344,9 @@ protected:
344
344
  }
345
345
  }
346
346
  /// GetDefinition SVFG
347
- inline const SVFGNode* getDefSVFGNode(const PAGNode* pagNode) const
347
+ inline const SVFGNode* getDefSVFGNode(const ValVar* valVar) const
348
348
  {
349
- return getSVFG()->getDefSVFGNode(pagNode);
349
+ return getSVFG()->getDefSVFGNode(valVar);
350
350
  }
351
351
  /// Backward traverse along indirect value flows
352
352
  void backtraceAlongIndirectVF(CPtSet& pts, const DPIm& oldDpm)
@@ -497,7 +497,7 @@ protected:
497
497
  {
498
498
  NodeID funPtr = _pag->getFunPtr(cbn);
499
499
  DPIm funPtrDpm(dpm);
500
- funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->getSVFVar(funPtr)),funPtr);
500
+ funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->getValVar(funPtr)),funPtr);
501
501
  findPT(funPtrDpm);
502
502
  }
503
503
  }
@@ -510,7 +510,7 @@ protected:
510
510
  {
511
511
  NodeID funPtr = _pag->getFunPtr(*it);
512
512
  DPIm funPtrDpm(dpm);
513
- funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->getSVFVar(funPtr)),funPtr);
513
+ funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->getValVar(funPtr)),funPtr);
514
514
  findPT(funPtrDpm);
515
515
  }
516
516
  }
@@ -74,7 +74,7 @@ class SVFG : public VFG
74
74
 
75
75
  public:
76
76
  typedef VFGNodeIDToNodeMapTy SVFGNodeIDToNodeMapTy;
77
- typedef Map<const SVFVar*, NodeID> SVFVarToDefMapTy;
77
+ typedef Map<const ValVar*, NodeID> ValVarToDefMapTy;
78
78
  typedef Map<const MRVer*, NodeID> MSSAVarToDefMapTy;
79
79
  typedef NodeBS ActualINSVFGNodeSet;
80
80
  typedef NodeBS ActualOUTSVFGNodeSet;
@@ -167,16 +167,16 @@ public:
167
167
  /// Connect SVFG nodes between caller and callee for indirect call site
168
168
  virtual void connectCallerAndCallee(const CallICFGNode* cs, const FunObjVar* callee, SVFGEdgeSetTy& edges);
169
169
 
170
- /// Given a svfVar, return its definition site
171
- inline const SVFGNode* getDefSVFGNode(const SVFVar* svfVar) const
170
+ /// Given a valVar, return its definition site
171
+ inline const SVFGNode* getDefSVFGNode(const ValVar* valVar) const
172
172
  {
173
- return getSVFGNode(getDef(svfVar));
173
+ return getSVFGNode(getDef(valVar));
174
174
  }
175
175
 
176
- /// Given a svfVar, return whether it has definition site
177
- inline bool hasDefSVFGNode(const SVFVar* svfVar) const
176
+ /// Given a valVar, return whether it has definition site
177
+ inline bool hasDefSVFGNode(const ValVar* valVar) const
178
178
  {
179
- return hasDef(svfVar) && hasSVFGNode(getDef(svfVar));
179
+ return hasDef(valVar) && hasSVFGNode(getDef(valVar));
180
180
  }
181
181
 
182
182
  /// Given a ValVar and its SVFGNode, find the definition-site ICFGNode
@@ -323,7 +323,7 @@ protected:
323
323
 
324
324
  /// Get inter value flow edges between indirect call site and callee.
325
325
  //@{
326
- virtual inline void getInterVFEdgeAtIndCSFromAPToFP(const SVFVar* cs_arg, const SVFVar* fun_arg, const CallICFGNode*, CallSiteID csId, SVFGEdgeSetTy& edges)
326
+ virtual inline void getInterVFEdgeAtIndCSFromAPToFP(const ValVar* cs_arg, const ValVar* fun_arg, const CallICFGNode*, CallSiteID csId, SVFGEdgeSetTy& edges)
327
327
  {
328
328
  SVFGNode* actualParam = getSVFGNode(getDef(cs_arg));
329
329
  SVFGNode* formalParam = getSVFGNode(getDef(fun_arg));
@@ -332,7 +332,7 @@ protected:
332
332
  edges.insert(edge);
333
333
  }
334
334
 
335
- virtual inline void getInterVFEdgeAtIndCSFromFRToAR(const SVFVar* fun_ret, const SVFVar* cs_ret, CallSiteID csId, SVFGEdgeSetTy& edges)
335
+ virtual inline void getInterVFEdgeAtIndCSFromFRToAR(const ValVar* fun_ret, const ValVar* cs_ret, CallSiteID csId, SVFGEdgeSetTy& edges)
336
336
  {
337
337
  SVFGNode* formalRet = getSVFGNode(getDef(fun_ret));
338
338
  SVFGNode* actualRet = getSVFGNode(getDef(cs_ret));
@@ -363,19 +363,19 @@ protected:
363
363
  //@}
364
364
 
365
365
 
366
- /// Given a SVFVar, set/get its def SVFG node (definition of top level pointers)
366
+ /// Given a ValVar, set/get its def SVFG node (definition of top level pointers)
367
367
  //@{
368
- inline void setDef(const SVFVar* svfVar, const SVFGNode* node)
368
+ inline void setDef(const ValVar* valVar, const SVFGNode* node)
369
369
  {
370
- VFG::setDef(svfVar, node);
370
+ VFG::setDef(valVar, node);
371
371
  }
372
- inline NodeID getDef(const SVFVar* svfVar) const
372
+ inline NodeID getDef(const ValVar* valVar) const
373
373
  {
374
- return VFG::getDef(svfVar);
374
+ return VFG::getDef(valVar);
375
375
  }
376
- inline bool hasDef(const SVFVar* svfVar) const
376
+ inline bool hasDef(const ValVar* valVar) const
377
377
  {
378
- return VFG::hasDef(svfVar);
378
+ return VFG::hasDef(valVar);
379
379
  }
380
380
  //@}
381
381
 
@@ -95,7 +95,7 @@ protected:
95
95
 
96
96
  /// Connect SVFG nodes between caller and callee for indirect call sites
97
97
  //@{
98
- inline void connectAParamAndFParam(const SVFVar* cs_arg, const SVFVar* fun_arg, const CallICFGNode*, CallSiteID csId, SVFGEdgeSetTy& edges) override
98
+ inline void connectAParamAndFParam(const ValVar* cs_arg, const ValVar* fun_arg, const CallICFGNode*, CallSiteID csId, SVFGEdgeSetTy& edges) override
99
99
  {
100
100
  NodeID phiId = getDef(fun_arg);
101
101
  SVFGEdge* edge = addCallEdge(getDef(cs_arg), phiId, csId);
@@ -107,7 +107,7 @@ protected:
107
107
  }
108
108
  }
109
109
  /// Connect formal-ret and actual ret
110
- inline void connectFRetAndARet(const SVFVar* fun_ret, const SVFVar* cs_ret, CallSiteID csId, SVFGEdgeSetTy& edges) override
110
+ inline void connectFRetAndARet(const ValVar* fun_ret, const ValVar* cs_ret, CallSiteID csId, SVFGEdgeSetTy& edges) override
111
111
  {
112
112
  NodeID phiId = getDef(cs_ret);
113
113
  NodeID retdef = getDef(fun_ret);
@@ -244,7 +244,7 @@ private:
244
244
  return (inter1 && inter2);
245
245
  }
246
246
 
247
- inline void addInterPHIOperands(PHISVFGNode* phi, const SVFVar* operand)
247
+ inline void addInterPHIOperands(PHISVFGNode* phi, const ValVar* operand)
248
248
  {
249
249
  phi->setOpVer(phi->getOpVerNum(), operand);
250
250
  }
@@ -267,10 +267,10 @@ private:
267
267
  return sNode;
268
268
  }
269
269
 
270
- inline void resetDef(const SVFVar* svfVar, const SVFGNode* node)
270
+ inline void resetDef(const ValVar* valVar, const SVFGNode* node)
271
271
  {
272
- SVFVarToDefMapTy::iterator it = SVFVarToDefMap.find(svfVar);
273
- assert(it != SVFVarToDefMap.end() && "a SVFIR node doesn't have definition before");
272
+ ValVarToDefMapTy::iterator it = ValVarToDefMap.find(valVar);
273
+ assert(it != ValVarToDefMap.end() && "a SVFIR node doesn't have definition before");
274
274
  it->second = node->getId();
275
275
  }
276
276
 
@@ -59,7 +59,7 @@ public:
59
59
 
60
60
  typedef OrderedMap<NodeID, VFGNode *> VFGNodeIDToNodeMapTy;
61
61
  typedef Set<VFGNode*> VFGNodeSet;
62
- typedef Map<const SVFVar*, NodeID> SVFVarToDefMapTy;
62
+ typedef Map<const ValVar*, NodeID> ValVarToDefMapTy;
63
63
  typedef Map<std::pair<NodeID,const CallICFGNode*>, ActualParmVFGNode *> SVFVarToActualParmMapTy;
64
64
  typedef Map<const SVFVar*, ActualRetVFGNode *> SVFVarToActualRetMapTy;
65
65
  typedef Map<const SVFVar*, FormalParmVFGNode *> SVFVarToFormalParmMapTy;
@@ -86,7 +86,7 @@ public:
86
86
 
87
87
  protected:
88
88
  NodeID totalVFGNode;
89
- SVFVarToDefMapTy SVFVarToDefMap; ///< map a pag node to its definition SVG node
89
+ ValVarToDefMapTy ValVarToDefMap; ///< map a pag node to its definition SVG node
90
90
  SVFVarToActualParmMapTy SVFVarToActualParmMap; ///< map a SVFVar to an actual parameter
91
91
  SVFVarToActualRetMapTy SVFVarToActualRetMap; ///< map a SVFVar to an actual return
92
92
  SVFVarToFormalParmMapTy SVFVarToFormalParmMap; ///< map a SVFVar to a formal parameter
@@ -185,10 +185,10 @@ public:
185
185
  }
186
186
  //@}
187
187
 
188
- /// Given a svfVar, return its definition site
189
- inline const VFGNode* getDefVFGNode(const SVFVar* svfVar) const
188
+ /// Given a valVar, return its definition site
189
+ inline const VFGNode* getDefVFGNode(const ValVar* valVar) const
190
190
  {
191
- return getVFGNode(getDef(svfVar));
191
+ return getVFGNode(getDef(valVar));
192
192
  }
193
193
 
194
194
  // Given an VFG node, return true if it has a left hand side top level pointer (PAGnode)
@@ -324,11 +324,11 @@ public:
324
324
  const FunObjVar* isFunEntryVFGNode(const VFGNode* node) const;
325
325
 
326
326
  /// Whether a SVFVar has a blackhole or const object as its definition
327
- inline bool hasBlackHoleConstObjAddrAsDef(const SVFVar* svfVar) const
327
+ inline bool hasBlackHoleConstObjAddrAsDef(const ValVar* valVar) const
328
328
  {
329
- if (hasDef(svfVar))
329
+ if (hasDef(valVar))
330
330
  {
331
- const VFGNode* defNode = getVFGNode(getDef(svfVar));
331
+ const VFGNode* defNode = getVFGNode(getDef(valVar));
332
332
  if (const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(defNode))
333
333
  {
334
334
  if (SVFIR::getPAG()->isBlkObjOrConstantObj(addr->getSVFStmt()->getSrcID()))
@@ -445,7 +445,7 @@ protected:
445
445
  /// Connect VFG nodes between caller and callee for indirect call site
446
446
  //@{
447
447
  /// Connect actual-param and formal param
448
- virtual inline void connectAParamAndFParam(const SVFVar* csArg, const SVFVar* funArg, const CallICFGNode* cbn, CallSiteID csId, VFGEdgeSetTy& edges)
448
+ virtual inline void connectAParamAndFParam(const ValVar* csArg, const ValVar* funArg, const CallICFGNode* cbn, CallSiteID csId, VFGEdgeSetTy& edges)
449
449
  {
450
450
  NodeID actualParam = getActualParmVFGNode(csArg, cbn)->getId();
451
451
  NodeID formalParam = getFormalParmVFGNode(funArg)->getId();
@@ -454,7 +454,7 @@ protected:
454
454
  edges.insert(edge);
455
455
  }
456
456
  /// Connect formal-ret and actual ret
457
- virtual inline void connectFRetAndARet(const SVFVar* funReturn, const SVFVar* csReturn, CallSiteID csId, VFGEdgeSetTy& edges)
457
+ virtual inline void connectFRetAndARet(const ValVar* funReturn, const ValVar* csReturn, CallSiteID csId, VFGEdgeSetTy& edges)
458
458
  {
459
459
  NodeID formalRet = getFormalRetVFGNode(funReturn)->getId();
460
460
  NodeID actualRet = getActualRetVFGNode(csReturn)->getId();
@@ -464,30 +464,30 @@ protected:
464
464
  }
465
465
  //@}
466
466
 
467
- /// Given a SVFVar, set/get its def VFG node (definition of top level pointers)
467
+ /// Given a ValVar, set/get its def VFG node (definition of top level pointers)
468
468
  //@{
469
- inline void setDef(const SVFVar* svfVar, const VFGNode* node)
469
+ inline void setDef(const ValVar* valVar, const VFGNode* node)
470
470
  {
471
- SVFVarToDefMapTy::iterator it = SVFVarToDefMap.find(svfVar);
472
- if(it == SVFVarToDefMap.end())
471
+ ValVarToDefMapTy::iterator it = ValVarToDefMap.find(valVar);
472
+ if(it == ValVarToDefMap.end())
473
473
  {
474
- SVFVarToDefMap[svfVar] = node->getId();
474
+ ValVarToDefMap[valVar] = node->getId();
475
475
  assert(hasVFGNode(node->getId()) && "not in the map!!");
476
476
  }
477
477
  else
478
478
  {
479
- assert((it->second == node->getId()) && "a SVFVar can only have unique definition ");
479
+ assert((it->second == node->getId()) && "a ValVar can only have unique definition ");
480
480
  }
481
481
  }
482
- inline NodeID getDef(const SVFVar* svfVar) const
482
+ inline NodeID getDef(const ValVar* valVar) const
483
483
  {
484
- SVFVarToDefMapTy::const_iterator it = SVFVarToDefMap.find(svfVar);
485
- assert(it!=SVFVarToDefMap.end() && "SVFVar does not have a definition??");
484
+ ValVarToDefMapTy::const_iterator it = ValVarToDefMap.find(valVar);
485
+ assert(it!=ValVarToDefMap.end() && "ValVar does not have a definition??");
486
486
  return it->second;
487
487
  }
488
- inline bool hasDef(const SVFVar* svfVar) const
488
+ inline bool hasDef(const ValVar* valVar) const
489
489
  {
490
- return (SVFVarToDefMap.find(svfVar) != SVFVarToDefMap.end());
490
+ return (ValVarToDefMap.find(valVar) != ValVarToDefMap.end());
491
491
  }
492
492
  //@}
493
493
 
@@ -544,7 +544,7 @@ protected:
544
544
  }
545
545
  /// Add a Dummy VFG node for null pointer definition
546
546
  /// To be noted for black hole pointer it has already has address edge connected
547
- inline void addNullPtrVFGNode(const SVFVar* svfVar)
547
+ inline void addNullPtrVFGNode(const ValVar* svfVar)
548
548
  {
549
549
  NullPtrVFGNode* sNode = new NullPtrVFGNode(totalVFGNode++,svfVar);
550
550
  addVFGNode(sNode, pag->getICFG()->getGlobalICFGNode());
@@ -555,7 +555,7 @@ protected:
555
555
  {
556
556
  AddrVFGNode* sNode = new AddrVFGNode(totalVFGNode++,addr);
557
557
  addStmtVFGNode(sNode, addr);
558
- setDef(addr->getLHSVar(),sNode);
558
+ setDef(SVFUtil::cast<ValVar>(addr->getLHSVar()),sNode);
559
559
  }
560
560
  /// Add a Copy VFG node
561
561
  inline void addCopyVFGNode(const CopyStmt* copy)
@@ -589,7 +589,7 @@ protected:
589
589
  /// Add an actual parameter VFG node
590
590
  /// To be noted that multiple actual parameters may have same value (SVFVar)
591
591
  /// So we need to make a pair <SVFVarID,CallSiteID> to find the right VFGParmNode
592
- inline void addActualParmVFGNode(const SVFVar* aparm, const CallICFGNode* cs)
592
+ inline void addActualParmVFGNode(const ValVar* aparm, const CallICFGNode* cs)
593
593
  {
594
594
  ActualParmVFGNode* sNode = new ActualParmVFGNode(totalVFGNode++,aparm,cs);
595
595
  addVFGNode(sNode, const_cast<CallICFGNode*>(cs));
@@ -597,7 +597,7 @@ protected:
597
597
  /// do not set def here, this node is not a variable definition
598
598
  }
599
599
  /// Add a formal parameter VFG node
600
- inline void addFormalParmVFGNode(const SVFVar* fparm, const FunObjVar* fun, CallPESet& callPEs)
600
+ inline void addFormalParmVFGNode(const ValVar* fparm, const FunObjVar* fun, CallPESet& callPEs)
601
601
  {
602
602
  FormalParmVFGNode* sNode = new FormalParmVFGNode(totalVFGNode++,fparm,fun);
603
603
  addVFGNode(sNode, pag->getICFG()->getFunEntryICFGNode(fun));
@@ -611,7 +611,7 @@ protected:
611
611
  /// Add a callee Return VFG node
612
612
  /// To be noted that here we assume returns of a procedure have already been unified into one
613
613
  /// Otherwise, we need to handle formalRet using <SVFVarID,CallSiteID> pair to find FormalRetVFG node same as handling actual parameters
614
- inline void addFormalRetVFGNode(const SVFVar* uniqueFunRet, const FunObjVar* fun, RetPESet& retPEs)
614
+ inline void addFormalRetVFGNode(const ValVar* uniqueFunRet, const FunObjVar* fun, RetPESet& retPEs)
615
615
  {
616
616
  FormalRetVFGNode *sNode = new FormalRetVFGNode(totalVFGNode++, uniqueFunRet, fun);
617
617
  addVFGNode(sNode, pag->getICFG()->getFunExitICFGNode(fun));
@@ -630,7 +630,7 @@ protected:
630
630
  }
631
631
  }
632
632
  /// Add a callsite Receive VFG node
633
- inline void addActualRetVFGNode(const SVFVar* ret,const CallICFGNode* cs)
633
+ inline void addActualRetVFGNode(const ValVar* ret,const CallICFGNode* cs)
634
634
  {
635
635
  ActualRetVFGNode* sNode = new ActualRetVFGNode(totalVFGNode++,ret,cs);
636
636
  addVFGNode(sNode, const_cast<RetICFGNode*>(cs->getRetICFGNode()));
@@ -640,7 +640,8 @@ protected:
640
640
  /// Add an llvm PHI VFG node
641
641
  inline void addIntraPHIVFGNode(const MultiOpndStmt* edge)
642
642
  {
643
- IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,edge->getRes());
643
+ const ValVar* res = SVFUtil::cast<ValVar>(edge->getRes());
644
+ IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,res);
644
645
  u32_t pos = 0;
645
646
  for(auto var : edge->getOpndVars())
646
647
  {
@@ -648,13 +649,14 @@ protected:
648
649
  pos++;
649
650
  }
650
651
  addVFGNode(sNode,edge->getICFGNode());
651
- setDef(edge->getRes(),sNode);
652
- SVFVarToIntraPHIVFGNodeMap[edge->getRes()] = sNode;
652
+ setDef(res,sNode);
653
+ SVFVarToIntraPHIVFGNodeMap[res] = sNode;
653
654
  }
654
655
  /// Add a Compare VFG node
655
656
  inline void addCmpVFGNode(const CmpStmt* edge)
656
657
  {
657
- CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, edge->getRes());
658
+ const ValVar* res = SVFUtil::cast<ValVar>(edge->getRes());
659
+ CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, res);
658
660
  u32_t pos = 0;
659
661
  for(auto var : edge->getOpndVars())
660
662
  {
@@ -662,13 +664,14 @@ protected:
662
664
  pos++;
663
665
  }
664
666
  addVFGNode(sNode,edge->getICFGNode());
665
- setDef(edge->getRes(),sNode);
666
- SVFVarToCmpVFGNodeMap[edge->getRes()] = sNode;
667
+ setDef(res,sNode);
668
+ SVFVarToCmpVFGNodeMap[res] = sNode;
667
669
  }
668
670
  /// Add a BinaryOperator VFG node
669
671
  inline void addBinaryOPVFGNode(const BinaryOPStmt* edge)
670
672
  {
671
- BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, edge->getRes());
673
+ const ValVar* res = SVFUtil::cast<ValVar>(edge->getRes());
674
+ BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, res);
672
675
  u32_t pos = 0;
673
676
  for(auto var : edge->getOpndVars())
674
677
  {
@@ -676,8 +679,8 @@ protected:
676
679
  pos++;
677
680
  }
678
681
  addVFGNode(sNode,edge->getICFGNode());
679
- setDef(edge->getRes(),sNode);
680
- SVFVarToBinaryOPVFGNodeMap[edge->getRes()] = sNode;
682
+ setDef(res,sNode);
683
+ SVFVarToBinaryOPVFGNodeMap[res] = sNode;
681
684
  }
682
685
  /// Add a UnaryOperator VFG node
683
686
  inline void addUnaryOPVFGNode(const UnaryOPStmt* edge)
@@ -209,6 +209,22 @@ public:
209
209
  LoadVFGNode(NodeID id, const LoadStmt* edge): StmtVFGNode(id, edge,Load)
210
210
  {
211
211
 
212
+ }
213
+ inline const ValVar* getSrcNode() const
214
+ {
215
+ return SVFUtil::cast<ValVar>(StmtVFGNode::getSrcNode());
216
+ }
217
+ inline const ValVar* getDstNode() const
218
+ {
219
+ return SVFUtil::cast<ValVar>(StmtVFGNode::getDstNode());
220
+ }
221
+ inline const ValVar* getRHSVar() const
222
+ {
223
+ return getSrcNode();
224
+ }
225
+ inline const ValVar* getLHSVar() const
226
+ {
227
+ return getDstNode();
212
228
  }
213
229
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
214
230
  //@{
@@ -254,6 +270,22 @@ public:
254
270
  StoreVFGNode(NodeID id,const StoreStmt* edge): StmtVFGNode(id,edge,Store)
255
271
  {
256
272
 
273
+ }
274
+ inline const ValVar* getSrcNode() const
275
+ {
276
+ return SVFUtil::cast<ValVar>(StmtVFGNode::getSrcNode());
277
+ }
278
+ inline const ValVar* getDstNode() const
279
+ {
280
+ return SVFUtil::cast<ValVar>(StmtVFGNode::getDstNode());
281
+ }
282
+ inline const ValVar* getRHSVar() const
283
+ {
284
+ return getSrcNode();
285
+ }
286
+ inline const ValVar* getLHSVar() const
287
+ {
288
+ return getDstNode();
257
289
  }
258
290
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
259
291
  //@{
@@ -299,6 +331,22 @@ public:
299
331
  CopyVFGNode(NodeID id,const CopyStmt* copy): StmtVFGNode(id,copy,Copy)
300
332
  {
301
333
 
334
+ }
335
+ inline const ValVar* getSrcNode() const
336
+ {
337
+ return SVFUtil::cast<ValVar>(StmtVFGNode::getSrcNode());
338
+ }
339
+ inline const ValVar* getDstNode() const
340
+ {
341
+ return SVFUtil::cast<ValVar>(StmtVFGNode::getDstNode());
342
+ }
343
+ inline const ValVar* getRHSVar() const
344
+ {
345
+ return getSrcNode();
346
+ }
347
+ inline const ValVar* getLHSVar() const
348
+ {
349
+ return getDstNode();
302
350
  }
303
351
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
304
352
  //@{
@@ -337,9 +385,9 @@ public:
337
385
  class CmpVFGNode: public VFGNode
338
386
  {
339
387
  public:
340
- typedef Map<u32_t,const SVFVar*> OPVers;
388
+ typedef Map<u32_t,const ValVar*> OPVers;
341
389
  protected:
342
- const SVFVar* res;
390
+ const ValVar* res;
343
391
  OPVers opVers;
344
392
 
345
393
  private:
@@ -349,7 +397,7 @@ private:
349
397
 
350
398
  public:
351
399
  /// Constructor
352
- CmpVFGNode(NodeID id,const SVFVar* r): VFGNode(id,Cmp), res(r) { }
400
+ CmpVFGNode(NodeID id,const ValVar* r): VFGNode(id,Cmp), res(r) { }
353
401
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
354
402
  //@{
355
403
  static inline bool classof(const CmpVFGNode *)
@@ -371,17 +419,17 @@ public:
371
419
  //@}
372
420
  /// Operands at a BinaryNode
373
421
  //@{
374
- inline const SVFVar* getOpVer(u32_t pos) const
422
+ inline const ValVar* getOpVer(u32_t pos) const
375
423
  {
376
424
  OPVers::const_iterator it = opVers.find(pos);
377
425
  assert(it!=opVers.end() && "version is nullptr, did not rename?");
378
426
  return it->second;
379
427
  }
380
- inline void setOpVer(u32_t pos, const SVFVar* node)
428
+ inline void setOpVer(u32_t pos, const ValVar* node)
381
429
  {
382
430
  opVers[pos] = node;
383
431
  }
384
- inline const SVFVar* getRes() const
432
+ inline const ValVar* getRes() const
385
433
  {
386
434
  return res;
387
435
  }
@@ -414,9 +462,9 @@ public:
414
462
  class BinaryOPVFGNode: public VFGNode
415
463
  {
416
464
  public:
417
- typedef Map<u32_t,const SVFVar*> OPVers;
465
+ typedef Map<u32_t,const ValVar*> OPVers;
418
466
  protected:
419
- const SVFVar* res;
467
+ const ValVar* res;
420
468
  OPVers opVers;
421
469
 
422
470
  private:
@@ -426,7 +474,7 @@ private:
426
474
 
427
475
  public:
428
476
  /// Constructor
429
- BinaryOPVFGNode(NodeID id,const SVFVar* r): VFGNode(id,BinaryOp), res(r) { }
477
+ BinaryOPVFGNode(NodeID id,const ValVar* r): VFGNode(id,BinaryOp), res(r) { }
430
478
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
431
479
  //@{
432
480
  static inline bool classof(const BinaryOPVFGNode *)
@@ -448,17 +496,17 @@ public:
448
496
  //@}
449
497
  /// Operands at a BinaryNode
450
498
  //@{
451
- inline const SVFVar* getOpVer(u32_t pos) const
499
+ inline const ValVar* getOpVer(u32_t pos) const
452
500
  {
453
501
  OPVers::const_iterator it = opVers.find(pos);
454
502
  assert(it!=opVers.end() && "version is nullptr, did not rename?");
455
503
  return it->second;
456
504
  }
457
- inline void setOpVer(u32_t pos, const SVFVar* node)
505
+ inline void setOpVer(u32_t pos, const ValVar* node)
458
506
  {
459
507
  opVers[pos] = node;
460
508
  }
461
- inline const SVFVar* getRes() const
509
+ inline const ValVar* getRes() const
462
510
  {
463
511
  return res;
464
512
  }
@@ -488,9 +536,9 @@ public:
488
536
  class UnaryOPVFGNode: public VFGNode
489
537
  {
490
538
  public:
491
- typedef Map<u32_t,const SVFVar*> OPVers;
539
+ typedef Map<u32_t,const ValVar*> OPVers;
492
540
  protected:
493
- const SVFVar* res;
541
+ const ValVar* res;
494
542
  OPVers opVers;
495
543
 
496
544
  private:
@@ -500,7 +548,7 @@ private:
500
548
 
501
549
  public:
502
550
  /// Constructor
503
- UnaryOPVFGNode(NodeID id, const SVFVar *r) : VFGNode(id, UnaryOp), res(r) { }
551
+ UnaryOPVFGNode(NodeID id, const ValVar *r) : VFGNode(id, UnaryOp), res(r) { }
504
552
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
505
553
  //@{
506
554
  static inline bool classof(const UnaryOPVFGNode *)
@@ -522,21 +570,21 @@ public:
522
570
  //@}
523
571
  /// Operands at a UnaryNode
524
572
  //@{
525
- inline const SVFVar* getOpVer(u32_t pos) const
573
+ inline const ValVar* getOpVer(u32_t pos) const
526
574
  {
527
575
  OPVers::const_iterator it = opVers.find(pos);
528
576
  assert(it!=opVers.end() && "version is nullptr, did not rename?");
529
577
  return it->second;
530
578
  }
531
- inline void setOpVer(u32_t pos, const SVFVar* node)
579
+ inline void setOpVer(u32_t pos, const ValVar* node)
532
580
  {
533
581
  opVers[pos] = node;
534
582
  }
535
- inline const SVFVar* getRes() const
583
+ inline const ValVar* getRes() const
536
584
  {
537
585
  return res;
538
586
  }
539
- inline const SVFVar* getOpVar() const
587
+ inline const ValVar* getOpVar() const
540
588
  {
541
589
  assert(getOpVerNum()==1 && "UnaryNode can only have one operand!");
542
590
  return getOpVer(0);
@@ -634,6 +682,22 @@ public:
634
682
  GepVFGNode(NodeID id,const GepStmt* edge): StmtVFGNode(id,edge,Gep)
635
683
  {
636
684
 
685
+ }
686
+ inline const ValVar* getSrcNode() const
687
+ {
688
+ return SVFUtil::cast<ValVar>(StmtVFGNode::getSrcNode());
689
+ }
690
+ inline const ValVar* getDstNode() const
691
+ {
692
+ return SVFUtil::cast<ValVar>(StmtVFGNode::getDstNode());
693
+ }
694
+ inline const ValVar* getRHSVar() const
695
+ {
696
+ return getSrcNode();
697
+ }
698
+ inline const ValVar* getLHSVar() const
699
+ {
700
+ return getDstNode();
637
701
  }
638
702
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
639
703
  //@{
@@ -671,14 +735,14 @@ class PHIVFGNode : public VFGNode
671
735
  {
672
736
 
673
737
  public:
674
- typedef Map<u32_t,const SVFVar*> OPVers;
738
+ typedef Map<u32_t,const ValVar*> OPVers;
675
739
  protected:
676
- const SVFVar* res;
740
+ const ValVar* res;
677
741
  OPVers opVers;
678
742
 
679
743
  public:
680
744
  /// Constructor
681
- PHIVFGNode(NodeID id, const SVFVar* r,VFGNodeK k = TPhi);
745
+ PHIVFGNode(NodeID id, const ValVar* r,VFGNodeK k = TPhi);
682
746
 
683
747
  /// Whether this phi node is of pointer type (used for pointer analysis).
684
748
  inline bool isPTANode() const
@@ -688,17 +752,17 @@ public:
688
752
 
689
753
  /// Operands at a llvm PHINode
690
754
  //@{
691
- inline const SVFVar* getOpVer(u32_t pos) const
755
+ inline const ValVar* getOpVer(u32_t pos) const
692
756
  {
693
757
  OPVers::const_iterator it = opVers.find(pos);
694
758
  assert(it!=opVers.end() && "version is nullptr, did not rename?");
695
759
  return it->second;
696
760
  }
697
- inline void setOpVer(u32_t pos, const SVFVar* node)
761
+ inline void setOpVer(u32_t pos, const ValVar* node)
698
762
  {
699
763
  opVers[pos] = node;
700
764
  }
701
- inline const SVFVar* getRes() const
765
+ inline const ValVar* getRes() const
702
766
  {
703
767
  return res;
704
768
  }
@@ -756,7 +820,7 @@ private:
756
820
  OPIncomingBBs opIncomingBBs;
757
821
  public:
758
822
  /// Constructor
759
- IntraPHIVFGNode(NodeID id, const SVFVar* r): PHIVFGNode(id, r, TIntraPhi)
823
+ IntraPHIVFGNode(NodeID id, const ValVar* r): PHIVFGNode(id, r, TIntraPhi)
760
824
  {
761
825
  }
762
826
 
@@ -766,7 +830,7 @@ public:
766
830
  assert(it!=opIncomingBBs.end() && "version is nullptr, did not rename?");
767
831
  return it->second;
768
832
  }
769
- inline void setOpVerAndBB(u32_t pos, const SVFVar* node, const ICFGNode* bb)
833
+ inline void setOpVerAndBB(u32_t pos, const ValVar* node, const ICFGNode* bb)
770
834
  {
771
835
  opVers[pos] = node;
772
836
  opIncomingBBs[pos] = bb;
@@ -812,6 +876,22 @@ public:
812
876
  AddrVFGNode(NodeID id, const AddrStmt* edge): StmtVFGNode(id, edge,Addr)
813
877
  {
814
878
 
879
+ }
880
+ inline const ObjVar* getSrcNode() const
881
+ {
882
+ return SVFUtil::cast<ObjVar>(StmtVFGNode::getSrcNode());
883
+ }
884
+ inline const ValVar* getDstNode() const
885
+ {
886
+ return SVFUtil::cast<ValVar>(StmtVFGNode::getDstNode());
887
+ }
888
+ inline const ValVar* getLHSVar() const
889
+ {
890
+ return getDstNode();
891
+ }
892
+ inline const ObjVar* getRHSVar() const
893
+ {
894
+ return getSrcNode();
815
895
  }
816
896
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
817
897
  //@{
@@ -847,11 +927,11 @@ class ArgumentVFGNode : public VFGNode
847
927
  {
848
928
 
849
929
  protected:
850
- const SVFVar* param;
930
+ const ValVar* param;
851
931
 
852
932
  public:
853
933
  /// Constructor
854
- ArgumentVFGNode(NodeID id, const SVFVar* p, VFGNodeK k): VFGNode(id,k), param(p)
934
+ ArgumentVFGNode(NodeID id, const ValVar* p, VFGNodeK k): VFGNode(id,k), param(p)
855
935
  {
856
936
  }
857
937
 
@@ -894,7 +974,7 @@ private:
894
974
  const CallICFGNode* cs;
895
975
  public:
896
976
  /// Constructor
897
- ActualParmVFGNode(NodeID id, const SVFVar* n, const CallICFGNode* c) :
977
+ ActualParmVFGNode(NodeID id, const ValVar* n, const CallICFGNode* c) :
898
978
  ArgumentVFGNode(id, n, AParm), cs(c)
899
979
  {
900
980
  }
@@ -906,7 +986,7 @@ public:
906
986
  }
907
987
 
908
988
  /// Return parameter
909
- inline const SVFVar* getParam() const
989
+ inline const ValVar* getParam() const
910
990
  {
911
991
  return param;
912
992
  }
@@ -952,13 +1032,13 @@ private:
952
1032
 
953
1033
  public:
954
1034
  /// Constructor
955
- FormalParmVFGNode(NodeID id, const SVFVar* n, const FunObjVar* f):
1035
+ FormalParmVFGNode(NodeID id, const ValVar* n, const FunObjVar* f):
956
1036
  ArgumentVFGNode(id, n, FParm), fun(f)
957
1037
  {
958
1038
  }
959
1039
 
960
1040
  /// Return parameter
961
- inline const SVFVar* getParam() const
1041
+ inline const ValVar* getParam() const
962
1042
  {
963
1043
  return param;
964
1044
  }
@@ -1028,7 +1108,7 @@ private:
1028
1108
 
1029
1109
  public:
1030
1110
  /// Constructor
1031
- ActualRetVFGNode(NodeID id, const SVFVar* n, const CallICFGNode* c) :
1111
+ ActualRetVFGNode(NodeID id, const ValVar* n, const CallICFGNode* c) :
1032
1112
  ArgumentVFGNode(id, n, ARet), cs(c)
1033
1113
  {
1034
1114
  }
@@ -1043,7 +1123,7 @@ public:
1043
1123
  return cs->getCaller();
1044
1124
  }
1045
1125
  /// Receive parameter at callsite
1046
- inline const SVFVar* getRev() const
1126
+ inline const ValVar* getRev() const
1047
1127
  {
1048
1128
  return param;
1049
1129
  }
@@ -1091,10 +1171,10 @@ private:
1091
1171
 
1092
1172
  public:
1093
1173
  /// Constructor
1094
- FormalRetVFGNode(NodeID id, const SVFVar* n, const FunObjVar* f);
1174
+ FormalRetVFGNode(NodeID id, const ValVar* n, const FunObjVar* f);
1095
1175
 
1096
1176
  /// Return value at callee
1097
- inline const SVFVar* getRet() const
1177
+ inline const ValVar* getRet() const
1098
1178
  {
1099
1179
  return param;
1100
1180
  }
@@ -41,6 +41,7 @@ namespace SVF
41
41
  {
42
42
 
43
43
  class SVFVar;
44
+ class ValVar;
44
45
 
45
46
 
46
47
  /*
@@ -58,7 +59,7 @@ public:
58
59
  NonOverlap, Overlap, Subset, Superset, Same
59
60
  };
60
61
 
61
- typedef std::pair<const SVFVar*, const SVFType*> IdxOperandPair;
62
+ typedef std::pair<const ValVar*, const SVFType*> IdxOperandPair;
62
63
  typedef std::vector<IdxOperandPair> IdxOperandPairs;
63
64
 
64
65
  /// Constructor
@@ -144,7 +145,7 @@ public:
144
145
  u32_t getElementNum(const SVFType* type) const;
145
146
 
146
147
 
147
- bool addOffsetVarAndGepTypePair(const SVFVar* var, const SVFType* gepIterType);
148
+ bool addOffsetVarAndGepTypePair(const ValVar* var, const SVFType* gepIterType);
148
149
 
149
150
  /// Return TRUE if this is a constant location set.
150
151
  bool isConstantOffset() const;
@@ -156,13 +157,13 @@ public:
156
157
  }
157
158
 
158
159
  /// Return byte offset from the beginning of the structure to the field where it is located for struct type
159
- u32_t getStructFieldOffset(const SVFVar* idxOperandVar, const SVFStructType* idxOperandType) const;
160
+ u32_t getStructFieldOffset(const ValVar* idxOperandVar, const SVFStructType* idxOperandType) const;
160
161
 
161
162
  /// Dump location set
162
163
  std::string dump() const;
163
164
 
164
165
  protected:
165
- inline void addIdxOperandPair(std::pair<const SVFVar*, const SVFType*> pair)
166
+ inline void addIdxOperandPair(std::pair<const ValVar*, const SVFType*> pair)
166
167
  {
167
168
  idxOperandPairs.push_back(pair);
168
169
  }
@@ -60,7 +60,7 @@ public:
60
60
  }
61
61
 
62
62
  /// Add ActualParmVFGNode
63
- inline void addActualParmVFGNode(const SVFVar* svfVar, const CallICFGNode* cs)
63
+ inline void addActualParmVFGNode(const ValVar* svfVar, const CallICFGNode* cs)
64
64
  {
65
65
  svfg->addActualParmVFGNode(svfVar, cs);
66
66
  }
@@ -55,12 +55,12 @@ public:
55
55
  typedef Map<NodeID,CallSiteSet> FunPtrToCallSitesMap;
56
56
  typedef Map<NodeID,NodeBS> MemObjToFieldsMap;
57
57
  typedef std::vector<const SVFStmt*> SVFStmtList;
58
- typedef std::vector<const SVFVar*> SVFVarList;
58
+ typedef std::vector<const ValVar*> ValVarList;
59
59
  typedef Map<const SVFVar*,PhiStmt*> PHINodeMap;
60
- typedef Map<const FunObjVar*,SVFVarList> FunToArgsListMap;
61
- typedef Map<const CallICFGNode*,SVFVarList> CSToArgsListMap;
62
- typedef Map<const RetICFGNode*,const SVFVar*> CSToRetMap;
63
- typedef Map<const FunObjVar*,const SVFVar*> FunToRetMap;
60
+ typedef Map<const FunObjVar*,ValVarList> FunToArgsListMap;
61
+ typedef Map<const CallICFGNode*,ValVarList> CSToArgsListMap;
62
+ typedef Map<const RetICFGNode*,const ValVar*> CSToRetMap;
63
+ typedef Map<const FunObjVar*,const ValVar*> FunToRetMap;
64
64
  typedef Map<const FunObjVar*,SVFStmtSet> FunToPAGEdgeSetMap;
65
65
  typedef Map<const ICFGNode*,SVFStmtList> ICFGNode2SVFStmtsMap;
66
66
  typedef Map<NodeID, NodeID> NodeToNodeMap;
@@ -132,6 +132,16 @@ public:
132
132
  {
133
133
  return getGNode(id);
134
134
  }
135
+ inline const ValVar* getValVar(NodeID id) const
136
+ {
137
+ if(const SVFVar* var = getSVFVar(id))
138
+ return SVFUtil::dyn_cast<ValVar>(var);
139
+ else
140
+ {
141
+ assert(false && "the Node is not a ValVar");
142
+ return nullptr;
143
+ }
144
+ }
135
145
  inline const ObjVar* getObjVar(NodeID id) const
136
146
  {
137
147
  if(const SVFVar* var = getSVFVar(id))
@@ -355,7 +365,7 @@ public:
355
365
  return funArgsListMap;
356
366
  }
357
367
  /// Get function arguments list
358
- inline const SVFVarList& getFunArgsList(const FunObjVar* func) const
368
+ inline const ValVarList& getFunArgsList(const FunObjVar* func) const
359
369
  {
360
370
  FunToArgsListMap::const_iterator it = funArgsListMap.find(func);
361
371
  assert(it != funArgsListMap.end() && "this function doesn't have arguments");
@@ -372,7 +382,7 @@ public:
372
382
  return callSiteArgsListMap;
373
383
  }
374
384
  /// Get callsite argument list
375
- inline const SVFVarList& getCallSiteArgsList(const CallICFGNode* cs) const
385
+ inline const ValVarList& getCallSiteArgsList(const CallICFGNode* cs) const
376
386
  {
377
387
  CSToArgsListMap::const_iterator it = callSiteArgsListMap.find(cs);
378
388
  assert(it != callSiteArgsListMap.end() && "this call site doesn't have arguments");
@@ -384,7 +394,7 @@ public:
384
394
  return callSiteRetMap;
385
395
  }
386
396
  /// Get callsite return
387
- inline const SVFVar* getCallSiteRet(const RetICFGNode* cs) const
397
+ inline const ValVar* getCallSiteRet(const RetICFGNode* cs) const
388
398
  {
389
399
  CSToRetMap::const_iterator it = callSiteRetMap.find(cs);
390
400
  assert(it != callSiteRetMap.end() && "this call site doesn't have return");
@@ -400,7 +410,7 @@ public:
400
410
  return funRetMap;
401
411
  }
402
412
  /// Get function return list
403
- inline const SVFVar* getFunRet(const FunObjVar* func) const
413
+ inline const ValVar* getFunRet(const FunObjVar* func) const
404
414
  {
405
415
  FunToRetMap::const_iterator it = funRetMap.find(func);
406
416
  assert(it != funRetMap.end() && "this function doesn't have return");
@@ -595,25 +605,25 @@ private:
595
605
  /// Get/set method for function/callsite arguments and returns
596
606
  //@{
597
607
  /// Add function arguments
598
- inline void addFunArgs(const FunObjVar* fun, const SVFVar* arg)
608
+ inline void addFunArgs(const FunObjVar* fun, const ValVar* arg)
599
609
  {
600
610
  FunEntryICFGNode* funEntryBlockNode = icfg->getFunEntryICFGNode(fun);
601
611
  addFunArgs(funEntryBlockNode, fun, arg);
602
612
  }
603
613
 
604
- inline void addFunArgs(FunEntryICFGNode* funEntryBlockNode, const FunObjVar* fun, const SVFVar* arg)
614
+ inline void addFunArgs(FunEntryICFGNode* funEntryBlockNode, const FunObjVar* fun, const ValVar* arg)
605
615
  {
606
616
  funEntryBlockNode->addFormalParms(arg);
607
617
  funArgsListMap[fun].push_back(arg);
608
618
  }
609
619
  /// Add function returns
610
- inline void addFunRet(const FunObjVar* fun, const SVFVar* ret)
620
+ inline void addFunRet(const FunObjVar* fun, const ValVar* ret)
611
621
  {
612
622
  FunExitICFGNode* funExitBlockNode = icfg->getFunExitICFGNode(fun);
613
623
  addFunRet(funExitBlockNode, fun, ret);
614
624
  }
615
625
 
616
- inline void addFunRet(FunExitICFGNode* funExitBlockNode, const FunObjVar* fun, const SVFVar* ret)
626
+ inline void addFunRet(FunExitICFGNode* funExitBlockNode, const FunObjVar* fun, const ValVar* ret)
617
627
  {
618
628
  funExitBlockNode->addFormalRet(ret);
619
629
  funRetMap[fun] = ret;
@@ -625,7 +635,7 @@ private:
625
635
  callSiteArgsListMap[callBlockNode].push_back(arg);
626
636
  }
627
637
  /// Add callsite returns
628
- inline void addCallSiteRets(RetICFGNode* retBlockNode,const SVFVar* arg)
638
+ inline void addCallSiteRets(RetICFGNode* retBlockNode,const ValVar* arg)
629
639
  {
630
640
  retBlockNode->addActualRet(arg);
631
641
  callSiteRetMap[retBlockNode]= arg;
@@ -38,6 +38,8 @@ namespace SVF
38
38
  {
39
39
 
40
40
  class SVFVar;
41
+ class ValVar;
42
+ class ObjVar;
41
43
  class ICFGNode;
42
44
  class IntraICFGNode;
43
45
  class CallICFGNode;
@@ -423,6 +425,11 @@ public:
423
425
  {
424
426
  return true;
425
427
  }
428
+
429
+ const ValVar* getLHSVar() const;
430
+ const ObjVar* getRHSVar() const;
431
+ const ValVar* getDstNode() const;
432
+ const ObjVar* getSrcNode() const;
426
433
  };
427
434
 
428
435
  /*!
@@ -507,6 +514,11 @@ public:
507
514
  /// constructor
508
515
  CopyStmt(SVFVar* s, SVFVar* d, CopyKind k) : AssignStmt(s, d, SVFStmt::Copy), copyKind(k) {}
509
516
 
517
+ const ValVar* getRHSVar() const;
518
+ const ValVar* getLHSVar() const;
519
+ const ValVar* getSrcNode() const;
520
+ const ValVar* getDstNode() const;
521
+
510
522
  virtual const std::string toString() const override;
511
523
 
512
524
  private:
@@ -544,6 +556,11 @@ public:
544
556
  /// constructor
545
557
  StoreStmt(SVFVar* s, SVFVar* d, const ICFGNode* st);
546
558
 
559
+ const ValVar* getRHSVar() const;
560
+ const ValVar* getLHSVar() const;
561
+ const ValVar* getSrcNode() const;
562
+ const ValVar* getDstNode() const;
563
+
547
564
  virtual const std::string toString() const override;
548
565
 
549
566
  };
@@ -579,6 +596,11 @@ public:
579
596
  /// constructor
580
597
  LoadStmt(SVFVar* s, SVFVar* d) : AssignStmt(s, d, SVFStmt::Load) {}
581
598
 
599
+ const ValVar* getRHSVar() const;
600
+ const ValVar* getLHSVar() const;
601
+ const ValVar* getSrcNode() const;
602
+ const ValVar* getDstNode() const;
603
+
582
604
  virtual const std::string toString() const override;
583
605
  };
584
606
 
@@ -660,6 +682,11 @@ public:
660
682
  {
661
683
  }
662
684
 
685
+ const ValVar* getRHSVar() const;
686
+ const ValVar* getLHSVar() const;
687
+ const ValVar* getSrcNode() const;
688
+ const ValVar* getDstNode() const;
689
+
663
690
  virtual const std::string toString() const;
664
691
 
665
692
 
@@ -719,6 +746,11 @@ public:
719
746
  }
720
747
  //@}
721
748
 
749
+ const ValVar* getRHSVar() const;
750
+ const ValVar* getLHSVar() const;
751
+ const ValVar* getSrcNode() const;
752
+ const ValVar* getDstNode() const;
753
+
722
754
  virtual const std::string toString() const override;
723
755
  };
724
756
 
@@ -775,6 +807,11 @@ public:
775
807
  }
776
808
  //@}
777
809
 
810
+ const ValVar* getRHSVar() const;
811
+ const ValVar* getLHSVar() const;
812
+ const ValVar* getSrcNode() const;
813
+ const ValVar* getDstNode() const;
814
+
778
815
  virtual const std::string toString() const override;
779
816
 
780
817
  };
@@ -786,10 +823,8 @@ class MultiOpndStmt : public SVFStmt
786
823
  {
787
824
  friend class GraphDBClient;
788
825
 
789
-
790
-
791
826
  public:
792
- typedef std::vector<SVFVar*> OPVars;
827
+ typedef std::vector<ValVar*> OPVars;
793
828
 
794
829
  private:
795
830
  MultiOpndStmt(); ///< place holder
@@ -803,7 +838,7 @@ private:
803
838
  protected:
804
839
  OPVars opVars;
805
840
  /// Constructor, only used by subclasses but not external users
806
- MultiOpndStmt(SVFVar* r, const OPVars& opnds, GEdgeFlag k);
841
+ MultiOpndStmt(ValVar* r, const OPVars& opnds, GEdgeFlag k);
807
842
 
808
843
  public:
809
844
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -827,7 +862,7 @@ public:
827
862
  /// `r` is OpVar
828
863
  //@{
829
864
  /// Operand SVFVars
830
- inline const SVFVar* getOpVar(u32_t pos) const
865
+ inline const ValVar* getOpVar(u32_t pos) const
831
866
  {
832
867
  return opVars.at(pos);
833
868
  }
@@ -897,13 +932,13 @@ public:
897
932
  //@}
898
933
 
899
934
  /// constructor
900
- PhiStmt(SVFVar* res, const OPVars& opnds, const OpICFGNodeVec& icfgNodes)
935
+ PhiStmt(ValVar* res, const OPVars& opnds, const OpICFGNodeVec& icfgNodes)
901
936
  : MultiOpndStmt(res, opnds, SVFStmt::Phi), opICFGNodes(icfgNodes)
902
937
  {
903
938
  assert(opnds.size() == icfgNodes.size() &&
904
939
  "Numbers of operands and their ICFGNodes are not consistent?");
905
940
  }
906
- void addOpVar(SVFVar* op, const ICFGNode* inode)
941
+ void addOpVar(ValVar* op, const ICFGNode* inode)
907
942
  {
908
943
  opVars.push_back(op);
909
944
  opICFGNodes.push_back(inode);
@@ -971,18 +1006,18 @@ public:
971
1006
  //@}
972
1007
 
973
1008
  /// constructor
974
- SelectStmt(SVFVar* res, const OPVars& opnds, const SVFVar* cond);
1009
+ SelectStmt(ValVar* res, const OPVars& opnds, const SVFVar* cond);
975
1010
  virtual const std::string toString() const override;
976
1011
 
977
1012
  inline const SVFVar* getCondition() const
978
1013
  {
979
1014
  return condition;
980
1015
  }
981
- inline const SVFVar* getTrueValue() const
1016
+ inline const ValVar* getTrueValue() const
982
1017
  {
983
1018
  return getOpVar(0);
984
1019
  }
985
- inline const SVFVar* getFalseValue() const
1020
+ inline const ValVar* getFalseValue() const
986
1021
  {
987
1022
  return getOpVar(1);
988
1023
  }
@@ -1061,7 +1096,7 @@ public:
1061
1096
  //@}
1062
1097
 
1063
1098
  /// constructor
1064
- CmpStmt(SVFVar* res, const OPVars& opnds, u32_t pre);
1099
+ CmpStmt(ValVar* res, const OPVars& opnds, u32_t pre);
1065
1100
 
1066
1101
  u32_t getPredicate() const
1067
1102
  {
@@ -1128,7 +1163,7 @@ public:
1128
1163
  //@}
1129
1164
 
1130
1165
  /// constructor
1131
- BinaryOPStmt(SVFVar* res, const OPVars& opnds, u32_t oc);
1166
+ BinaryOPStmt(ValVar* res, const OPVars& opnds, u32_t oc);
1132
1167
 
1133
1168
  u32_t getOpcode() const
1134
1169
  {
@@ -1180,23 +1215,14 @@ public:
1180
1215
  //@}
1181
1216
 
1182
1217
  /// constructor
1183
- UnaryOPStmt(SVFVar* s, SVFVar* d, u32_t oc)
1184
- : SVFStmt(s, d, SVFStmt::UnaryOp), opcode(oc)
1185
- {
1186
- }
1218
+ UnaryOPStmt(ValVar* s, ValVar* d, u32_t oc);
1187
1219
 
1188
1220
  u32_t getOpcode() const
1189
1221
  {
1190
1222
  return opcode;
1191
1223
  }
1192
- inline const SVFVar* getOpVar() const
1193
- {
1194
- return SVFStmt::getSrcNode();
1195
- }
1196
- inline const SVFVar* getRes() const
1197
- {
1198
- return SVFStmt::getDstNode();
1199
- }
1224
+ const ValVar* getOpVar() const;
1225
+ const ValVar* getRes() const;
1200
1226
  NodeID getOpVarID() const;
1201
1227
  NodeID getResID() const;
1202
1228
 
@@ -1223,8 +1249,8 @@ private:
1223
1249
  NodeID getDstID(); ///< place holder, use getResID() instead
1224
1250
 
1225
1251
  SuccAndCondPairVec successors;
1226
- const SVFVar* cond;
1227
- const SVFVar* brInst;
1252
+ const ValVar* cond;
1253
+ const ValVar* brInst;
1228
1254
 
1229
1255
  public:
1230
1256
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -1244,19 +1270,15 @@ public:
1244
1270
  //@}
1245
1271
 
1246
1272
  /// constructor
1247
- BranchStmt(SVFVar* inst, SVFVar* c, const SuccAndCondPairVec& succs)
1248
- : SVFStmt(c, inst, SVFStmt::Branch), successors(succs), cond(c),
1249
- brInst(inst)
1250
- {
1251
- }
1273
+ BranchStmt(ValVar* inst, ValVar* c, const SuccAndCondPairVec& succs);
1252
1274
 
1253
1275
  /// The branch is unconditional if cond is a null value
1254
1276
  bool isUnconditional() const;
1255
1277
  /// The branch is conditional if cond is not a null value
1256
1278
  bool isConditional() const;
1257
1279
  /// Return the condition
1258
- const SVFVar* getCondition() const;
1259
- const SVFVar* getBranchInst() const
1280
+ const ValVar* getCondition() const;
1281
+ const ValVar* getBranchInst() const
1260
1282
  {
1261
1283
  return brInst;
1262
1284
  }
@@ -1327,6 +1349,11 @@ public:
1327
1349
  {
1328
1350
  }
1329
1351
 
1352
+ const ValVar* getRHSVar() const;
1353
+ const ValVar* getLHSVar() const;
1354
+ const ValVar* getSrcNode() const;
1355
+ const ValVar* getDstNode() const;
1356
+
1330
1357
  virtual const std::string toString() const;
1331
1358
 
1332
1359
  };
@@ -1366,6 +1393,11 @@ public:
1366
1393
  {
1367
1394
  }
1368
1395
 
1396
+ const ValVar* getRHSVar() const;
1397
+ const ValVar* getLHSVar() const;
1398
+ const ValVar* getSrcNode() const;
1399
+ const ValVar* getDstNode() const;
1400
+
1369
1401
  virtual const std::string toString() const;
1370
1402
 
1371
1403
  };
@@ -300,6 +300,8 @@ public:
300
300
 
301
301
  void printAbstractState() const;
302
302
 
303
+ std::string toString() const;
304
+
303
305
  u32_t hash() const;
304
306
 
305
307
  // lhs == rhs for varToValMap
@@ -109,11 +109,11 @@ public:
109
109
  detectors.push_back(std::move(detector));
110
110
  }
111
111
 
112
- /// Retrieve the abstract state from the trace for a given ICFG node; asserts if no trace exists
113
- AbstractState& getAbstractState(const ICFGNode* node);
114
-
115
- /// Check if an abstract state exists in the trace for a given ICFG node
116
- bool hasAbstractState(const ICFGNode* node);
112
+ /// Retrieve SVFVar given its ID; asserts if no such variable exists
113
+ inline const SVFVar* getSVFVar(NodeID varId) const
114
+ {
115
+ return svfir->getSVFVar(varId);
116
+ }
117
117
 
118
118
  /// Retrieve abstract value for a top-level variable at a given ICFG node
119
119
  const AbstractValue& getAbstractValue(const ICFGNode* node, const ValVar* var);
@@ -124,6 +124,24 @@ public:
124
124
  /// Retrieve abstract value for any SVF variable at a given ICFG node
125
125
  const AbstractValue& getAbstractValue(const ICFGNode* node, const SVFVar* var);
126
126
 
127
+ /// Set abstract value for a top-level variable at a given ICFG node
128
+ void updateAbstractValue(const ICFGNode* node, const ValVar* var, const AbstractValue& val);
129
+
130
+ /// Set abstract value for an address-taken variable at a given ICFG node
131
+ void updateAbstractValue(const ICFGNode* node, const ObjVar* var, const AbstractValue& val);
132
+
133
+ /// Set abstract value for any SVF variable at a given ICFG node
134
+ void updateAbstractValue(const ICFGNode* node, const SVFVar* var, const AbstractValue& val);
135
+
136
+ /// Propagate an ObjVar's abstract value from defSite to all its use-site ICFGNodes via SVFG
137
+ void propagateObjVarAbsVal(const ObjVar* var, const ICFGNode* defSite);
138
+
139
+ /// Retrieve the abstract state from the trace for a given ICFG node; asserts if no trace exists
140
+ AbstractState& getAbstractState(const ICFGNode* node);
141
+
142
+ /// Check if an abstract state exists in the trace for a given ICFG node
143
+ bool hasAbstractState(const ICFGNode* node);
144
+
127
145
  /// Retrieve abstract state filtered to specific top-level variables
128
146
  void getAbstractState(const ICFGNode* node, const Set<const ValVar*>& vars, AbstractState& result);
129
147
 
@@ -65,6 +65,12 @@ public:
65
65
  {
66
66
  return callGraphSCC;
67
67
  }
68
+ SVFG* getSVFG() const
69
+ {
70
+ return svfg;
71
+ }
72
+ /// Given an ObjVar and its def-site ICFGNode, find all use-site ICFGNodes
73
+ const Set<const ICFGNode*> getUseSitesOfObjVar(const ObjVar* obj, const ICFGNode* node) const;
68
74
 
69
75
  /// Build WTO for each function using call graph SCC
70
76
  void initWTO();
@@ -78,6 +84,7 @@ public:
78
84
  private:
79
85
  SVFIR* svfir;
80
86
  ICFG* icfg;
87
+ SVFG* svfg;
81
88
  AndersenWaveDiff* pta;
82
89
  CallGraph* callGraph;
83
90
  CallGraphSCC* callGraphSCC;
@@ -181,19 +181,19 @@ public:
181
181
 
182
182
  /// Given a ValVar and its SVFGNode, find the definition-site ICFGNode
183
183
  /// by following incoming direct VFGEdges (asserts unique definition)
184
- const ICFGNode* getDefSiteOfValVar(const ValVar* var, const SVFGNode* node) const;
184
+ const ICFGNode* getDefSiteOfValVar(const ValVar* var) const;
185
185
 
186
- /// Given an ObjVar and its SVFGNode, find the definition-site ICFGNode
186
+ /// Given an ObjVar and its use-site ICFGNode, find the definition-site ICFGNode
187
187
  /// by following incoming IndirectSVFGEdges whose pts contains the ObjVar (asserts unique definition)
188
- const ICFGNode* getDefSiteOfObjVar(const ObjVar* obj, const SVFGNode* node) const;
188
+ const ICFGNode* getDefSiteOfObjVar(const ObjVar* obj, const ICFGNode* node) const;
189
189
 
190
- /// Given a ValVar and its SVFStmt, find all use-site ICFGNodes
191
- /// by following outgoing direct VFGEdges from its definition SVFGNode
192
- const Set<const ICFGNode*> getUseSitesOfValVar(const ValVar* var, const SVFGNode* vNode) const;
190
+ /// Given a ValVar, find all use-site ICFGNodes
191
+ /// by following outgoing direct VFGEdges from its unique definition SVFGNode
192
+ const Set<const ICFGNode*> getUseSitesOfValVar(const ValVar* var) const;
193
193
 
194
- /// Given an ObjVar and its SVFStmt, find all use-site ICFGNodes
194
+ /// Given an ObjVar and its def-site ICFGNode, find all use-site ICFGNodes
195
195
  /// by following outgoing IndirectSVFGEdges whose pts contains the ObjVar
196
- const Set<const ICFGNode*> getUseSitesOfObjVar(const ObjVar* obj, const SVFGNode* vNode) const;
196
+ const Set<const ICFGNode*> getUseSitesOfObjVar(const ObjVar* obj, const ICFGNode* node) const;
197
197
 
198
198
  /// Perform statistics
199
199
  void performStat();
@@ -240,6 +240,7 @@ public:
240
240
  static const Option<u32_t> LoopBound;
241
241
 
242
242
  // Abstract Execution
243
+ static const Option<bool> SparseAE;
243
244
  static const Option<u32_t> WidenDelay;
244
245
  /// recursion handling mode, Default: TOP
245
246
  static const OptionMap<u32_t> HandleRecur;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2509",
3
+ "version": "1.0.2511",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {