svf-tools 1.0.1195 → 1.0.1197

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.1195",
3
+ "version": "1.0.1197",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -100,7 +100,7 @@ public:
100
100
  protected:
101
101
  void addCandidate(NodeID id)
102
102
  {
103
- if (pag->isValidTopLevelPtr(pag->getGNode(id)))
103
+ if (pag->isValidTopLevelPtr(pag->getSVFVar(id)))
104
104
  candidateQueries.insert(id);
105
105
  }
106
106
 
@@ -475,7 +475,7 @@ protected:
475
475
  assert(baseObj && "base object is null??");
476
476
  if(SVFUtil::isa<StackObjVar>(baseObj))
477
477
  {
478
- if(const FunObjVar* svffun = _pag->getGNode(id)->getFunction())
478
+ if(const FunObjVar* svffun = _pag->getSVFVar(id)->getFunction())
479
479
  {
480
480
  return _callGraphSCC->isInCycle(_callGraph->getCallGraphNode(svffun)->getId());
481
481
  }
@@ -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->getGNode(funPtr)),funPtr);
500
+ funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->getSVFVar(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->getGNode(funPtr)),funPtr);
513
+ funPtrDpm.setLocVar(getSVFG()->getDefSVFGNode(_pag->getSVFVar(funPtr)),funPtr);
514
514
  findPT(funPtrDpm);
515
515
  }
516
516
  }
@@ -312,9 +312,9 @@ public:
312
312
  {
313
313
  return pag->getAllFieldsObjVars(id);
314
314
  }
315
- inline NodeID getBaseObjVar(NodeID id)
315
+ inline NodeID getBaseObjVarID(NodeID id)
316
316
  {
317
- return pag->getBaseObjVar(id);
317
+ return pag->getBaseObjVarID(id);
318
318
  }
319
319
  inline bool isSingleFieldObj(NodeID id) const
320
320
  {
@@ -312,11 +312,11 @@ public:
312
312
  ///@{
313
313
  inline bool isFIObjNode(NodeID id) const
314
314
  {
315
- return (SVFUtil::isa<BaseObjVar>(pag->getGNode(id)));
315
+ return (SVFUtil::isa<BaseObjVar>(pag->getSVFVar(id)));
316
316
  }
317
- inline NodeID getBaseObjVar(NodeID id)
317
+ inline NodeID getBaseObjVarID(NodeID id)
318
318
  {
319
- return pag->getBaseObjVar(id);
319
+ return pag->getBaseObjVarID(id);
320
320
  }
321
321
  inline NodeID getFIObjVar(NodeID id)
322
322
  {
@@ -348,7 +348,7 @@ public:
348
348
  expandedCpts = cpts;;
349
349
  for(typename CPtSet::const_iterator cit = cpts.begin(), ecit=cpts.end(); cit!=ecit; ++cit)
350
350
  {
351
- if(pag->getBaseObjVar(cit->get_id())==cit->get_id())
351
+ if(pag->getBaseObjVarID(cit->get_id())==cit->get_id())
352
352
  {
353
353
  NodeBS& fields = pag->getAllFieldsObjVars(cit->get_id());
354
354
  for(NodeBS::iterator it = fields.begin(), eit = fields.end(); it!=eit; ++it)
@@ -564,7 +564,7 @@ public:
564
564
  {
565
565
  for (OrderedNodeSet::iterator nIter = this->getAllValidPtrs().begin(); nIter != this->getAllValidPtrs().end(); ++nIter)
566
566
  {
567
- const PAGNode* node = this->getPAG()->getGNode(*nIter);
567
+ const SVFVar* node = this->getPAG()->getSVFVar(*nIter);
568
568
  if (this->getPAG()->isValidTopLevelPtr(node))
569
569
  {
570
570
  if (SVFUtil::isa<DummyObjVar>(node))
@@ -64,9 +64,9 @@ public:
64
64
  typedef Map<const FunObjVar*,SVFStmtSet> FunToPAGEdgeSetMap;
65
65
  typedef Map<const ICFGNode*,SVFStmtList> ICFGNode2SVFStmtsMap;
66
66
  typedef Map<NodeID, NodeID> NodeToNodeMap;
67
- typedef std::pair<NodeID, APOffset> NodeOffset;
67
+ typedef std::pair<NodeID, APOffset> GepOffset;
68
68
  typedef std::pair<NodeID, AccessPath> NodeAccessPath;
69
- typedef Map<NodeOffset,NodeID> NodeOffsetMap;
69
+ typedef Map<GepOffset,NodeID> OffsetToGepVarMap;
70
70
  typedef Map<NodeAccessPath,NodeID> NodeAccessPathMap;
71
71
  typedef Map<NodeID, NodeAccessPathMap> GepValueVarMap;
72
72
  typedef std::pair<const SVFType*, std::vector<AccessPath>> SVFTypeLocSetsPair;
@@ -80,7 +80,7 @@ private:
80
80
  ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap; ///< Map an ICFGNode to its PointerAnalysis related SVFStmts
81
81
  GepValueVarMap GepValObjMap; ///< Map a pair<base,off> to a gep value node id
82
82
  TypeLocSetsMap typeLocSetsMap; ///< Map an arg to its base SVFType* and all its field location sets
83
- NodeOffsetMap GepObjVarMap; ///< Map a pair<base,off> to a gep obj node id
83
+ OffsetToGepVarMap GepObjVarMap; ///< Map a pair<base,off> to a gep obj node id
84
84
  MemObjToFieldsMap memToFieldsMap; ///< Map a mem object id to all its fields
85
85
  SVFStmtSet globSVFStmtSet; ///< Global PAGEdges without control flow information
86
86
  PHINodeMap phiNodeMap; ///< A set of phi copy edges
@@ -126,13 +126,67 @@ public:
126
126
  pag = nullptr;
127
127
  }
128
128
  //@}
129
+ /// ObjVar/GepObjVar/BaseObjVar
130
+ //@{
131
+ inline const SVFVar* getSVFVar(NodeID id) const
132
+ {
133
+ return getGNode(id);
134
+ }
135
+ inline const ObjVar* getObjVar(NodeID id) const
136
+ {
137
+ if(const SVFVar* var = getSVFVar(id))
138
+ return SVFUtil::dyn_cast<ObjVar>(var);
139
+ else
140
+ {
141
+ assert(false && "the Node is not an ObjVar");
142
+ return nullptr;
143
+ }
144
+ }
145
+ inline const BaseObjVar* getBaseObjVar(NodeID id) const
146
+ {
147
+ if(const SVFVar* var = getSVFVar(id))
148
+ return SVFUtil::dyn_cast<BaseObjVar>(var);
149
+ else
150
+ {
151
+ assert(false && "the Node is not a BaseObjVar");
152
+ return nullptr;
153
+ }
154
+ }
155
+ inline const GepObjVar* getGepObjVar(NodeID id) const
156
+ {
157
+ if(const SVFVar* var = getSVFVar(id))
158
+ return SVFUtil::dyn_cast<GepObjVar>(var);
159
+ else
160
+ {
161
+ assert(false && "the Node is not a GepObjVar");
162
+ return nullptr;
163
+ }
164
+ }
165
+ inline bool isObjVar(NodeID id) const
166
+ {
167
+ return SVFUtil::isa<ObjVar>(getSVFVar(id));
168
+ }
169
+ inline bool isBaseObjVar(NodeID id) const
170
+ {
171
+ return SVFUtil::isa<BaseObjVar>(getSVFVar(id));
172
+ }
173
+ inline bool isGepObjVar(NodeID id) const
174
+ {
175
+ return SVFUtil::isa<GepObjVar>(getSVFVar(id));
176
+ }
177
+ /// Return the entire SVFID to SVFVar map
178
+ inline const IDToNodeMapTy& getSVFVarMap() const
179
+ {
180
+ return IDToNodeMap;
181
+ }
182
+ //@}
129
183
  /// Return memToFieldsMap
130
184
  inline MemObjToFieldsMap& getMemToFieldsMap()
131
185
  {
132
186
  return memToFieldsMap;
133
187
  }
134
188
  /// Return GepObjVarMap
135
- inline NodeOffsetMap& getGepObjNodeMap()
189
+ inline OffsetToGepVarMap& getGepObjNodeMap()
136
190
  {
137
191
  return GepObjVarMap;
138
192
  }
@@ -423,17 +477,17 @@ public:
423
477
  //@{
424
478
  inline const BaseObjVar* getBaseObject(NodeID id) const
425
479
  {
426
- const SVFVar* node = getGNode(id);
480
+ const SVFVar* node = getSVFVar(id);
427
481
  if(const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(node))
428
482
  return SVFUtil::dyn_cast<BaseObjVar>(
429
- getGNode(gepObjVar->getBaseNode()));
483
+ getSVFVar(gepObjVar->getBaseNode()));
430
484
  else
431
485
  return SVFUtil::dyn_cast<BaseObjVar>(node);
432
486
  }
433
487
 
434
488
  inline const ValVar* getBaseValVar(NodeID id) const
435
489
  {
436
- const SVFVar* node = getGNode(id);
490
+ const SVFVar* node = getSVFVar(id);
437
491
  if(const GepValVar* gepVar = SVFUtil::dyn_cast<GepValVar>(node))
438
492
  return gepVar->getBaseNode();
439
493
  else
@@ -453,7 +507,7 @@ public:
453
507
  }
454
508
  inline NodeID getFIObjVar(NodeID id) const
455
509
  {
456
- return getBaseObjVar(id);
510
+ return getBaseObjVarID(id);
457
511
  }
458
512
  //@}
459
513
 
@@ -477,7 +531,7 @@ public:
477
531
  /// Base and Offset methods for Value and Object node
478
532
  //@{
479
533
  /// Get a base pointer node given a field pointer
480
- inline NodeID getBaseObjVar(NodeID id) const
534
+ inline NodeID getBaseObjVarID(NodeID id) const
481
535
  {
482
536
  return getBaseObject(id)->getId();
483
537
  }
@@ -172,7 +172,7 @@ AddressValue AbstractState::getGepObjAddrs(u32_t pointer, IntervalValue offset)
172
172
  for (const auto& addr : addrs.getAddrs())
173
173
  {
174
174
  s64_t baseObj = getIDFromAddr(addr);
175
- assert(SVFUtil::isa<ObjVar>(PAG::getPAG()->getGNode(baseObj)) && "Fail to get the base object address!");
175
+ assert(SVFUtil::isa<ObjVar>(PAG::getPAG()->getSVFVar(baseObj)) && "Fail to get the base object address!");
176
176
  NodeID gepObj = PAG::getPAG()->getGepObjVar(baseObj, i);
177
177
  (*this)[gepObj] = AddressValue(AbstractState::getVirtualMemAddress(gepObj));
178
178
  gepAddrs.insert(AbstractState::getVirtualMemAddress(gepObj));
@@ -313,7 +313,7 @@ void BufOverflowDetector::detectExtAPI(AbstractState& as,
313
313
  IntervalValue BufOverflowDetector::getAccessOffset(SVF::AbstractState& as, SVF::NodeID objId, const SVF::GepStmt* gep)
314
314
  {
315
315
  SVFIR* svfir = PAG::getPAG();
316
- auto obj = svfir->getGNode(objId);
316
+ auto obj = svfir->getSVFVar(objId);
317
317
 
318
318
  if (SVFUtil::isa<BaseObjVar>(obj))
319
319
  {
@@ -351,7 +351,7 @@ void BufOverflowDetector::updateGepObjOffsetFromBase(AbstractState& as, SVF::Add
351
351
  for (const auto& objAddr : objAddrs)
352
352
  {
353
353
  NodeID objId = as.getIDFromAddr(objAddr);
354
- auto obj = svfir->getGNode(objId);
354
+ auto obj = svfir->getSVFVar(objId);
355
355
 
356
356
  if (SVFUtil::isa<BaseObjVar>(obj))
357
357
  {
@@ -361,7 +361,7 @@ void BufOverflowDetector::updateGepObjOffsetFromBase(AbstractState& as, SVF::Add
361
361
  for (const auto& gepAddr : gepAddrs)
362
362
  {
363
363
  NodeID gepObj = as.getIDFromAddr(gepAddr);
364
- if (const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(svfir->getGNode(gepObj)))
364
+ if (const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(svfir->getSVFVar(gepObj)))
365
365
  {
366
366
  addToGepObjOffsetFromBase(gepObjVar, offset);
367
367
  }
@@ -380,7 +380,7 @@ void BufOverflowDetector::updateGepObjOffsetFromBase(AbstractState& as, SVF::Add
380
380
  for (const auto& gepAddr : gepAddrs)
381
381
  {
382
382
  NodeID gepObj = as.getIDFromAddr(gepAddr);
383
- if (const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(svfir->getGNode(gepObj)))
383
+ if (const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(svfir->getSVFVar(gepObj)))
384
384
  {
385
385
  if (hasGepObjOffsetFromBase(objVar))
386
386
  {
@@ -520,11 +520,11 @@ bool BufOverflowDetector::canSafelyAccessMemory(AbstractState& as, const SVF::SV
520
520
 
521
521
  IntervalValue offset(0);
522
522
  // if the object is a GepObjVar, get the offset from the base object
523
- if (SVFUtil::isa<GepObjVar>(svfir->getGNode(objId)))
523
+ if (SVFUtil::isa<GepObjVar>(svfir->getSVFVar(objId)))
524
524
  {
525
- offset = getGepObjOffsetFromBase(SVFUtil::cast<GepObjVar>(svfir->getGNode(objId))) + len;
525
+ offset = getGepObjOffsetFromBase(SVFUtil::cast<GepObjVar>(svfir->getSVFVar(objId))) + len;
526
526
  }
527
- else if (SVFUtil::isa<BaseObjVar>(svfir->getGNode(objId)))
527
+ else if (SVFUtil::isa<BaseObjVar>(svfir->getSVFVar(objId)))
528
528
  {
529
529
  // if the object is a BaseObjVar, get the offset directly
530
530
  offset = len;
@@ -165,7 +165,7 @@ void AbsExtAPI::initExtFunMap()
165
165
  for (auto vaddr: Addrs.getAddrs())
166
166
  {
167
167
  u32_t objId = as.getIDFromAddr(vaddr);
168
- AbstractValue range = getRangeLimitFromType(svfir->getGNode(objId)->getType());
168
+ AbstractValue range = getRangeLimitFromType(svfir->getSVFVar(objId)->getType());
169
169
  as.store(vaddr, range);
170
170
  }
171
171
  }
@@ -185,7 +185,7 @@ void AbsExtAPI::initExtFunMap()
185
185
  for (auto vaddr: Addrs.getAddrs())
186
186
  {
187
187
  u32_t objId = as.getIDFromAddr(vaddr);
188
- AbstractValue range = getRangeLimitFromType(svfir->getGNode(objId)->getType());
188
+ AbstractValue range = getRangeLimitFromType(svfir->getSVFVar(objId)->getType());
189
189
  as.store(vaddr, range);
190
190
  }
191
191
  }
@@ -423,7 +423,7 @@ void AbsExtAPI::handleExtAPI(const CallICFGNode *call)
423
423
  else if (extType == MEMCPY)
424
424
  {
425
425
  IntervalValue len = as[call->getArgument(2)->getId()].getInterval();
426
- svfir->getGNode(call->getArgument(0)->getId());
426
+ (void)svfir->getSVFVar(call->getArgument(0)->getId());
427
427
  handleMemcpy(as, call->getArgument(0), call->getArgument(1), len, 0);
428
428
  }
429
429
  else if (extType == MEMSET)
@@ -465,7 +465,7 @@ u32_t AbsExtAPI::getElementSize(AbstractState& as, const SVFVar* var)
465
465
  if (var->getType()->isArrayTy())
466
466
  {
467
467
  return SVFUtil::dyn_cast<SVFArrayType>(var->getType())
468
- ->getTypeOfElement()->getByteSize();
468
+ ->getTypeOfElement()->getByteSize();
469
469
  }
470
470
  if (var->getType()->isPointerTy())
471
471
  {
@@ -473,7 +473,7 @@ u32_t AbsExtAPI::getElementSize(AbstractState& as, const SVFVar* var)
473
473
  {
474
474
  if (elemType->isArrayTy())
475
475
  return SVFUtil::dyn_cast<SVFArrayType>(elemType)
476
- ->getTypeOfElement()->getByteSize();
476
+ ->getTypeOfElement()->getByteSize();
477
477
  return elemType->getByteSize();
478
478
  }
479
479
  return 1;
@@ -593,8 +593,8 @@ void AbsExtAPI::handleStrncat(const CallICFGNode *call)
593
593
 
594
594
  /// Core memcpy: copy `len` bytes from src to dst starting at dst[start_idx].
595
595
  void AbsExtAPI::handleMemcpy(AbstractState& as, const SVF::SVFVar *dst,
596
- const SVF::SVFVar *src, IntervalValue len,
597
- u32_t start_idx)
596
+ const SVF::SVFVar *src, IntervalValue len,
597
+ u32_t start_idx)
598
598
  {
599
599
  if (!isValidLength(len)) return;
600
600
 
@@ -634,7 +634,7 @@ void AbsExtAPI::handleMemcpy(AbstractState& as, const SVF::SVFVar *dst,
634
634
  /// wchar_t[100], elemSize = sizeof(wchar_t[100]), so range_val reflects the
635
635
  /// number of top-level GEP fields, not individual array elements.
636
636
  void AbsExtAPI::handleMemset(AbstractState& as, const SVF::SVFVar *dst,
637
- IntervalValue elem, IntervalValue len)
637
+ IntervalValue elem, IntervalValue len)
638
638
  {
639
639
  if (!isValidLength(len)) return;
640
640
 
@@ -643,7 +643,7 @@ void AbsExtAPI::handleMemset(AbstractState& as, const SVF::SVFVar *dst,
643
643
  if (dst->getType()->isArrayTy())
644
644
  {
645
645
  elemSize = SVFUtil::dyn_cast<SVFArrayType>(dst->getType())
646
- ->getTypeOfElement()->getByteSize();
646
+ ->getTypeOfElement()->getByteSize();
647
647
  }
648
648
  else if (dst->getType()->isPointerTy())
649
649
  {
@@ -360,7 +360,7 @@ bool AbstractInterpretation::isCmpBranchFeasible(const CmpStmt* cmpStmt, s64_t s
360
360
  const LoadStmt *load_op0 = nullptr;
361
361
  const LoadStmt *load_op1 = nullptr;
362
362
  // get '%1 = load i32 s', and load inst may not exist
363
- SVFVar* loadVar0 = svfir->getGNode(op0);
363
+ const SVFVar* loadVar0 = svfir->getSVFVar(op0);
364
364
  if (!loadVar0->getInEdges().empty())
365
365
  {
366
366
  SVFStmt *loadVar0InStmt = *loadVar0->getInEdges().begin();
@@ -370,7 +370,7 @@ bool AbstractInterpretation::isCmpBranchFeasible(const CmpStmt* cmpStmt, s64_t s
370
370
  }
371
371
  else if (const CopyStmt *copyStmt = SVFUtil::dyn_cast<CopyStmt>(loadVar0InStmt))
372
372
  {
373
- loadVar0 = svfir->getGNode(copyStmt->getRHSVarID());
373
+ loadVar0 = svfir->getSVFVar(copyStmt->getRHSVarID());
374
374
  if (!loadVar0->getInEdges().empty())
375
375
  {
376
376
  SVFStmt *loadVar0InStmt2 = *loadVar0->getInEdges().begin();
@@ -382,7 +382,7 @@ bool AbstractInterpretation::isCmpBranchFeasible(const CmpStmt* cmpStmt, s64_t s
382
382
  }
383
383
  }
384
384
 
385
- SVFVar* loadVar1 = svfir->getGNode(op1);
385
+ const SVFVar* loadVar1 = svfir->getSVFVar(op1);
386
386
  if (!loadVar1->getInEdges().empty())
387
387
  {
388
388
  SVFStmt *loadVar1InStmt = *loadVar1->getInEdges().begin();
@@ -392,7 +392,7 @@ bool AbstractInterpretation::isCmpBranchFeasible(const CmpStmt* cmpStmt, s64_t s
392
392
  }
393
393
  else if (const CopyStmt *copyStmt = SVFUtil::dyn_cast<CopyStmt>(loadVar1InStmt))
394
394
  {
395
- loadVar1 = svfir->getGNode(copyStmt->getRHSVarID());
395
+ loadVar1 = svfir->getSVFVar(copyStmt->getRHSVarID());
396
396
  if (!loadVar1->getInEdges().empty())
397
397
  {
398
398
  SVFStmt *loadVar1InStmt2 = *loadVar1->getInEdges().begin();
@@ -954,7 +954,7 @@ const FunObjVar* AbstractInterpretation::getCallee(const CallICFGNode* callNode)
954
954
  return nullptr;
955
955
 
956
956
  NodeID addr = *Addrs.getAddrs().begin();
957
- SVFVar* func_var = svfir->getGNode(as.getIDFromAddr(addr));
957
+ const SVFVar* func_var = svfir->getSVFVar(as.getIDFromAddr(addr));
958
958
  return SVFUtil::dyn_cast<FunObjVar>(func_var);
959
959
  }
960
960
 
@@ -79,7 +79,7 @@ const CxtPtSet& ContextDDA::computeDDAPts(const CxtVar& var)
79
79
  LocDPItem::setMaxBudget(Options::CxtBudget());
80
80
 
81
81
  NodeID id = var.get_id();
82
- PAGNode* node = getPAG()->getGNode(id);
82
+ const SVFVar* node = getPAG()->getSVFVar(id);
83
83
  CxtLocDPItem dpm = getDPIm(var, getDefSVFGNode(node));
84
84
 
85
85
  // start DDA analysis
@@ -191,7 +191,7 @@ bool ContextDDA::testIndCallReachability(CxtLocDPItem& dpm, const FunObjVar* cal
191
191
  if(getPAG()->isIndirectCallSites(cs))
192
192
  {
193
193
  NodeID id = getPAG()->getFunPtr(cs);
194
- PAGNode* node = getPAG()->getGNode(id);
194
+ const SVFVar* node = getPAG()->getSVFVar(id);
195
195
  CxtVar funptrVar(dpm.getCondVar().get_cond(), id);
196
196
  CxtLocDPItem funptrDpm = getDPIm(funptrVar,getDefSVFGNode(node));
197
197
  PointsTo pts = getBVPointsTo(findPT(funptrDpm));
@@ -342,11 +342,11 @@ bool ContextDDA::isHeapCondMemObj(const CxtVar& var, const StoreSVFGNode*)
342
342
  {
343
343
  if (!isa<DummyObjVar>(baseVar))
344
344
  {
345
- PAGNode *pnode = _pag->getGNode(getPtrNodeID(var));
346
- GepObjVar* gepobj = SVFUtil::dyn_cast<GepObjVar>(pnode);
345
+ const SVFVar* pnode = _pag->getSVFVar(getPtrNodeID(var));
346
+ const GepObjVar* gepobj = SVFUtil::dyn_cast<GepObjVar>(pnode);
347
347
  if (gepobj != nullptr)
348
348
  {
349
- assert(SVFUtil::isa<DummyObjVar>(_pag->getGNode(gepobj->getBaseNode()))
349
+ assert(SVFUtil::isa<DummyObjVar>(_pag->getSVFVar(gepobj->getBaseNode()))
350
350
  && "empty refVal in a gep object whose base is a non-dummy object");
351
351
  }
352
352
  else
@@ -58,7 +58,7 @@ void DDAClient::answerQueries(PointerAnalysis* pta)
58
58
  for (OrderedNodeSet::iterator nIter = candidateQueries.begin();
59
59
  nIter != candidateQueries.end(); ++nIter,++count)
60
60
  {
61
- PAGNode* node = pta->getPAG()->getGNode(*nIter);
61
+ const SVFVar* node = pta->getPAG()->getSVFVar(*nIter);
62
62
  if(pta->getPAG()->isValidTopLevelPtr(node))
63
63
  {
64
64
  DBOUT(DGENERAL,outs() << "\n@@Computing PointsTo for :" << node->getId() <<
@@ -282,10 +282,10 @@ AliasResult DDAPass::alias(NodeID node1, NodeID node2)
282
282
  {
283
283
  SVFIR* pag = _pta->getPAG();
284
284
 
285
- if(pag->isValidTopLevelPtr(pag->getGNode(node1)))
285
+ if(pag->isValidTopLevelPtr(pag->getSVFVar(node1)))
286
286
  _pta->computeDDAPts(node1);
287
287
 
288
- if(pag->isValidTopLevelPtr(pag->getGNode(node2)))
288
+ if(pag->isValidTopLevelPtr(pag->getSVFVar(node2)))
289
289
  _pta->computeDDAPts(node2);
290
290
 
291
291
  return _pta->alias(node1,node2);
@@ -45,7 +45,7 @@ void FlowDDA::computeDDAPts(NodeID id)
45
45
  resetQuery();
46
46
  LocDPItem::setMaxBudget(Options::FlowBudget());
47
47
 
48
- PAGNode* node = getPAG()->getGNode(id);
48
+ const SVFVar* node = getPAG()->getSVFVar(id);
49
49
  LocDPItem dpm = getDPIm(node->getId(),getDefSVFGNode(node));
50
50
 
51
51
  /// start DDA analysis
@@ -163,7 +163,7 @@ void ConstraintGraph::clearSolitaries()
163
163
  {
164
164
  if (it->second->hasIncomingEdge() || it->second->hasOutgoingEdge())
165
165
  continue;
166
- if (pag->getGNode(it->first)->isPointer())
166
+ if (pag->getSVFVar(it->first)->isPointer())
167
167
  continue;
168
168
  if (retFromIndCalls.find(it->first)!=retFromIndCalls.end())
169
169
  continue;
@@ -188,8 +188,7 @@ AddrCGEdge::AddrCGEdge(ConstraintNode* s, ConstraintNode* d, EdgeID id)
188
188
  : ConstraintEdge(s,d,Addr,id)
189
189
  {
190
190
  // Retarget addr edges may lead s to be a dummy node
191
- PAGNode* node = SVFIR::getPAG()->getGNode(s->getId());
192
- (void)node; // Suppress warning of unused variable under release build
191
+ const SVFVar* node = SVFIR::getPAG()->getSVFVar(s->getId());
193
192
  if (!SVFIR::pagReadFromTXT())
194
193
  {
195
194
  assert(!SVFUtil::isa<DummyValVar>(node) && "a dummy node??");
@@ -730,7 +729,7 @@ ConstraintNode::const_iterator ConstraintNode::directInEdgeEnd() const
730
729
 
731
730
  const std::string ConstraintNode::toString() const
732
731
  {
733
- return SVFIR::getPAG()->getGNode(getId())->toString();
732
+ return SVFIR::getPAG()->getSVFVar(getId())->toString();
734
733
  }
735
734
 
736
735
  /*!
@@ -764,7 +763,7 @@ struct DOTGraphTraits<ConstraintGraph*> : public DOTGraphTraits<SVFIR*>
764
763
  /// Either you can choose to display the name of the value or the whole instruction
765
764
  static std::string getNodeLabel(NodeType *n, ConstraintGraph*)
766
765
  {
767
- PAGNode* node = SVFIR::getPAG()->getGNode(n->getId());
766
+ const SVFVar* node = SVFIR::getPAG()->getSVFVar(n->getId());
768
767
  bool briefDisplay = Options::BriefConsCGDotGraph();
769
768
  bool nameDisplay = true;
770
769
  std::string str;
@@ -797,7 +796,7 @@ struct DOTGraphTraits<ConstraintGraph*> : public DOTGraphTraits<SVFIR*>
797
796
 
798
797
  static std::string getNodeAttributes(NodeType *n, ConstraintGraph*)
799
798
  {
800
- PAGNode* node = SVFIR::getPAG()->getGNode(n->getId());
799
+ const SVFVar* node = SVFIR::getPAG()->getSVFVar(n->getId());
801
800
  if (SVFUtil::isa<ValVar>(node))
802
801
  {
803
802
  if(SVFUtil::isa<GepValVar>(node))
@@ -595,8 +595,8 @@ void SVFG::getInterVFEdgesForIndirectCallSite(const CallICFGNode* callICFGNode,
595
595
  SVFIR::SVFVarList::const_iterator funArgIt = funArgList.begin(), funArgEit = funArgList.end();
596
596
  for (; funArgIt != funArgEit && csArgIt != csArgEit; funArgIt++, csArgIt++)
597
597
  {
598
- const PAGNode *cs_arg = *csArgIt;
599
- const PAGNode *fun_arg = *funArgIt;
598
+ const SVFVar *cs_arg = *csArgIt;
599
+ const SVFVar *fun_arg = *funArgIt;
600
600
  if (isInterestedPAGNode(fun_arg) && isInterestedPAGNode(cs_arg))
601
601
  getInterVFEdgeAtIndCSFromAPToFP(cs_arg, fun_arg, callICFGNode, csId, edges);
602
602
  }
@@ -604,12 +604,12 @@ void SVFG::getInterVFEdgesForIndirectCallSite(const CallICFGNode* callICFGNode,
604
604
  if (callee->isVarArg())
605
605
  {
606
606
  NodeID varFunArg = pag->getVarargNode(callee);
607
- const PAGNode* varFunArgNode = pag->getGNode(varFunArg);
607
+ const SVFVar* varFunArgNode = pag->getSVFVar(varFunArg);
608
608
  if (isInterestedPAGNode(varFunArgNode))
609
609
  {
610
610
  for (; csArgIt != csArgEit; csArgIt++)
611
611
  {
612
- const PAGNode *cs_arg = *csArgIt;
612
+ const SVFVar *cs_arg = *csArgIt;
613
613
  if (isInterestedPAGNode(cs_arg))
614
614
  getInterVFEdgeAtIndCSFromAPToFP(cs_arg, varFunArgNode, callICFGNode, csId, edges);
615
615
  }
@@ -620,8 +620,8 @@ void SVFG::getInterVFEdgesForIndirectCallSite(const CallICFGNode* callICFGNode,
620
620
  // Find inter direct return edges between actual return and formal return.
621
621
  if (pag->funHasRet(callee) && pag->callsiteHasRet(retICFGNode))
622
622
  {
623
- const PAGNode* cs_return = pag->getCallSiteRet(retICFGNode);
624
- const PAGNode* fun_return = pag->getFunRet(callee);
623
+ const SVFVar* cs_return = pag->getCallSiteRet(retICFGNode);
624
+ const SVFVar* fun_return = pag->getFunRet(callee);
625
625
  if (isInterestedPAGNode(cs_return) && isInterestedPAGNode(fun_return))
626
626
  getInterVFEdgeAtIndCSFromFRToAR(fun_return, cs_return, csId, edges);
627
627
  }
@@ -101,7 +101,7 @@ void ThreadCallGraph::updateCallGraph(PointerAnalysis* pta)
101
101
  const NodeBS targets = pta->getPts(forkedval->getId()).toNodeBS();
102
102
  for (NodeBS::iterator ii = targets.begin(), ie = targets.end(); ii != ie; ii++)
103
103
  {
104
- if(ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(pag->getGNode(*ii)))
104
+ if(const ObjVar* objPN = pag->getObjVar(*ii))
105
105
  {
106
106
  const BaseObjVar* obj = pag->getBaseObject(objPN->getId());
107
107
  if(obj->isFunction())
@@ -212,7 +212,7 @@ const std::string PHIVFGNode::toString() const
212
212
  std::string str;
213
213
  std::stringstream rawstr(str);
214
214
  rawstr << "PHIVFGNode ID: " << getId() << " ";
215
- rawstr << "PAGNode: [" << res->getId() << " = PHI(";
215
+ rawstr << "SVFVar: [" << res->getId() << " = PHI(";
216
216
  for(PHIVFGNode::OPVers::const_iterator it = opVerBegin(), eit = opVerEnd();
217
217
  it != eit; it++)
218
218
  rawstr << it->second->getId() << ", ";
@@ -227,7 +227,7 @@ const std::string IntraPHIVFGNode::toString() const
227
227
  std::string str;
228
228
  std::stringstream rawstr(str);
229
229
  rawstr << "IntraPHIVFGNode ID: " << getId() << " ";
230
- rawstr << "PAGNode: [" << res->getId() << " = PHI(";
230
+ rawstr << "SVFVar: [" << res->getId() << " = PHI(";
231
231
  for(PHIVFGNode::OPVers::const_iterator it = opVerBegin(), eit = opVerEnd();
232
232
  it != eit; it++)
233
233
  rawstr << it->second->getId() << ", ";
@@ -337,9 +337,9 @@ const std::string InterPHIVFGNode::toString() const
337
337
  std::string str;
338
338
  std::stringstream rawstr(str);
339
339
  if(isFormalParmPHI())
340
- rawstr << "FormalParmPHI ID: " << getId() << " PAGNode ID: " << res->getId() << "\n" << res->valueOnlyToString();
340
+ rawstr << "FormalParmPHI ID: " << getId() << " SVFVar ID: " << res->getId() << "\n" << res->valueOnlyToString();
341
341
  else
342
- rawstr << "ActualRetPHI ID: " << getId() << " PAGNode ID: " << res->getId() << "\n" << res->valueOnlyToString();
342
+ rawstr << "ActualRetPHI ID: " << getId() << " SVFVar ID: " << res->getId() << "\n" << res->valueOnlyToString();
343
343
  return rawstr.str();
344
344
  }
345
345
 
@@ -355,7 +355,7 @@ const std::string NullPtrVFGNode::toString() const
355
355
  std::string str;
356
356
  std::stringstream rawstr(str);
357
357
  rawstr << "NullPtrVFGNode ID: " << getId();
358
- rawstr << " PAGNode ID: " << node->getId() << "\n";
358
+ rawstr << " SVFVar ID: " << node->getId() << "\n";
359
359
  return rawstr.str();
360
360
  }
361
361
 
@@ -404,12 +404,12 @@ const std::string RetDirSVFGEdge::toString() const
404
404
 
405
405
 
406
406
 
407
- FormalRetVFGNode::FormalRetVFGNode(NodeID id, const PAGNode* n, const FunObjVar* f) :
407
+ FormalRetVFGNode::FormalRetVFGNode(NodeID id, const SVFVar* n, const FunObjVar* f) :
408
408
  ArgumentVFGNode(id, n, FRet), fun(f)
409
409
  {
410
410
  }
411
411
 
412
- PHIVFGNode::PHIVFGNode(NodeID id, const PAGNode* r,VFGNodeK k): VFGNode(id, k), res(r)
412
+ PHIVFGNode::PHIVFGNode(NodeID id, const SVFVar* r,VFGNodeK k): VFGNode(id, k), res(r)
413
413
  {
414
414
 
415
415
  }
@@ -450,7 +450,7 @@ void VFG::addVFGNodes()
450
450
  // initialize dummy definition null pointers in order to uniform the construction
451
451
  // to be noted for black hole pointer it has already has address edge connected,
452
452
  // and its definition will be set when processing addr SVFIR edge.
453
- addNullPtrVFGNode(pag->getGNode(pag->getNullPtr()));
453
+ addNullPtrVFGNode(pag->getSVFVar(pag->getNullPtr()));
454
454
 
455
455
  // initialize address nodes
456
456
  SVFStmt::SVFStmtSetTy& addrs = getPAGEdgeSet(SVFStmt::Addr);
@@ -508,7 +508,7 @@ void VFG::addVFGNodes()
508
508
 
509
509
  for(SVFIR::SVFVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
510
510
  {
511
- const PAGNode* pagNode = *pit;
511
+ const SVFVar* pagNode = *pit;
512
512
  if (isInterestedPAGNode(pagNode))
513
513
  addActualParmVFGNode(pagNode,it->first);
514
514
  }
@@ -534,7 +534,7 @@ void VFG::addVFGNodes()
534
534
 
535
535
  for(SVFIR::SVFVarList::iterator pit = it->second.begin(), epit = it->second.end(); pit!=epit; ++pit)
536
536
  {
537
- const PAGNode* param = *pit;
537
+ const SVFVar* param = *pit;
538
538
  if (isInterestedPAGNode(param) == false || hasBlackHoleConstObjAddrAsDef(param))
539
539
  continue;
540
540
 
@@ -554,7 +554,7 @@ void VFG::addVFGNodes()
554
554
 
555
555
  if (func->isVarArg())
556
556
  {
557
- const PAGNode* varParam = pag->getGNode(pag->getVarargNode(func));
557
+ const SVFVar* varParam = pag->getSVFVar(pag->getVarargNode(func));
558
558
  if (isInterestedPAGNode(varParam) == false || hasBlackHoleConstObjAddrAsDef(varParam))
559
559
  continue;
560
560
 
@@ -578,7 +578,7 @@ void VFG::addVFGNodes()
578
578
  {
579
579
  const FunObjVar* func = it->first;
580
580
 
581
- const PAGNode* uniqueFunRetNode = it->second;
581
+ const SVFVar* uniqueFunRetNode = it->second;
582
582
 
583
583
  RetPESet retPEs;
584
584
  if (uniqueFunRetNode->hasOutgoingEdges(SVFStmt::Ret))
@@ -969,8 +969,8 @@ void VFG::connectCallerAndCallee(const CallICFGNode* callBlockNode, const FunObj
969
969
  SVFIR::SVFVarList::const_iterator funArgIt = funArgList.begin(), funArgEit = funArgList.end();
970
970
  for (; funArgIt != funArgEit && csArgIt != csArgEit; funArgIt++, csArgIt++)
971
971
  {
972
- const PAGNode *cs_arg = *csArgIt;
973
- const PAGNode *fun_arg = *funArgIt;
972
+ const SVFVar *cs_arg = *csArgIt;
973
+ const SVFVar *fun_arg = *funArgIt;
974
974
  if (isInterestedPAGNode(cs_arg) && isInterestedPAGNode(fun_arg))
975
975
  connectAParamAndFParam(cs_arg, fun_arg, callBlockNode, csId, edges);
976
976
  }
@@ -979,12 +979,12 @@ void VFG::connectCallerAndCallee(const CallICFGNode* callBlockNode, const FunObj
979
979
  if (callee->isVarArg())
980
980
  {
981
981
  NodeID varFunArg = pag->getVarargNode(callee);
982
- const PAGNode* varFunArgNode = pag->getGNode(varFunArg);
982
+ const SVFVar* varFunArgNode = pag->getSVFVar(varFunArg);
983
983
  if (isInterestedPAGNode(varFunArgNode))
984
984
  {
985
985
  for (; csArgIt != csArgEit; csArgIt++)
986
986
  {
987
- const PAGNode *cs_arg = *csArgIt;
987
+ const SVFVar *cs_arg = *csArgIt;
988
988
  if (isInterestedPAGNode(cs_arg))
989
989
  connectAParamAndFParam(cs_arg, varFunArgNode, callBlockNode, csId, edges);
990
990
  }
@@ -995,8 +995,8 @@ void VFG::connectCallerAndCallee(const CallICFGNode* callBlockNode, const FunObj
995
995
  // connect actual return and formal return
996
996
  if (pag->funHasRet(callee) && pag->callsiteHasRet(retBlockNode))
997
997
  {
998
- const PAGNode* cs_return = pag->getCallSiteRet(retBlockNode);
999
- const PAGNode* fun_return = pag->getFunRet(callee);
998
+ const SVFVar* cs_return = pag->getCallSiteRet(retBlockNode);
999
+ const SVFVar* fun_return = pag->getFunRet(callee);
1000
1000
  if (isInterestedPAGNode(cs_return) && isInterestedPAGNode(fun_return))
1001
1001
  connectFRetAndARet(fun_return, cs_return, csId, edges);
1002
1002
  }
@@ -1005,7 +1005,7 @@ void VFG::connectCallerAndCallee(const CallICFGNode* callBlockNode, const FunObj
1005
1005
  /*!
1006
1006
  * Given a VFG node, return its left hand side top level pointer
1007
1007
  */
1008
- const PAGNode* VFG::getLHSTopLevPtr(const VFGNode* node) const
1008
+ const SVFVar* VFG::getLHSTopLevPtr(const VFGNode* node) const
1009
1009
  {
1010
1010
 
1011
1011
  if(const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(node))
@@ -508,7 +508,7 @@ void MRGenerator::collectCallSitePts(const CallICFGNode* cs)
508
508
  */
509
509
  NodeBS& MRGenerator::CollectPtsChain(NodeID id)
510
510
  {
511
- NodeID baseId = pta->getPAG()->getBaseObjVar(id);
511
+ NodeID baseId = pta->getPAG()->getBaseObjVarID(id);
512
512
  NodeToPTSSMap::iterator it = cachedPtsChainMap.find(baseId);
513
513
  if(it!=cachedPtsChainMap.end())
514
514
  return it->second;
@@ -273,10 +273,10 @@ void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, co
273
273
  if(pushToCTPWorkList(newctp))
274
274
  {
275
275
  /// Add TCT nodes and edge
276
- if(addTCTEdge(this->getGNode(ctp.getTid()), spawneeNode))
276
+ if(addTCTEdge(this->getTCTNode(ctp.getTid()), spawneeNode))
277
277
  {
278
278
  DBOUT(DMTA,outs() << "Add TCT Edge from thread " << ctp.getTid() << " ";
279
- this->getGNode(ctp.getTid())->getCxtThread().dump();
279
+ this->getTCTNode(ctp.getTid())->getCxtThread().dump();
280
280
  outs() << " to thread " << spawneeNode->getId() << " ";
281
281
  spawneeNode->getCxtThread().dump();
282
282
  outs() << "\n" );
@@ -136,7 +136,7 @@ bool PointerAnalysis::isLocalVarInRecursiveFun(NodeID id) const
136
136
  assert(baseObjVar && "base object not found!!");
137
137
  if(SVFUtil::isa<StackObjVar>(baseObjVar))
138
138
  {
139
- if(const FunObjVar* svffun = pag->getGNode(id)->getFunction())
139
+ if(const FunObjVar* svffun = pag->getSVFVar(id)->getFunction())
140
140
  {
141
141
  return callGraphSCC->isInCycle(getCallGraph()->getCallGraphNode(svffun)->getId());
142
142
  }
@@ -234,7 +234,7 @@ void PointerAnalysis::dumpAllTypes()
234
234
  for (OrderedNodeSet::iterator nIter = this->getAllValidPtrs().begin();
235
235
  nIter != this->getAllValidPtrs().end(); ++nIter)
236
236
  {
237
- const PAGNode* node = getPAG()->getGNode(*nIter);
237
+ const SVFVar* node = getPAG()->getSVFVar(*nIter);
238
238
  if (SVFUtil::isa<DummyObjVar, DummyValVar>(node))
239
239
  continue;
240
240
 
@@ -253,7 +253,7 @@ void PointerAnalysis::dumpAllTypes()
253
253
  void PointerAnalysis::dumpPts(NodeID ptr, const PointsTo& pts)
254
254
  {
255
255
 
256
- const PAGNode* node = pag->getGNode(ptr);
256
+ const SVFVar* node = pag->getSVFVar(ptr);
257
257
  /// print the points-to set of node which has the maximum pts size.
258
258
  if (SVFUtil::isa<DummyObjVar> (node))
259
259
  {
@@ -283,12 +283,12 @@ void PointerAnalysis::dumpPts(NodeID ptr, const PointsTo& pts)
283
283
 
284
284
  for (PointsTo::iterator it = pts.begin(), eit = pts.end(); it != eit; ++it)
285
285
  {
286
- const PAGNode* node = pag->getGNode(*it);
286
+ const SVFVar* node = pag->getSVFVar(*it);
287
287
  if(SVFUtil::isa<ObjVar>(node) == false)
288
288
  continue;
289
289
  NodeID ptd = node->getId();
290
290
  outs() << "!!Target NodeID " << ptd << "\t [";
291
- const PAGNode* pagNode = pag->getGNode(ptd);
291
+ const SVFVar* pagNode = pag->getSVFVar(ptd);
292
292
  if (SVFUtil::isa<DummyValVar>(node))
293
293
  outs() << "DummyVal\n";
294
294
  else if (SVFUtil::isa<DummyObjVar>(node))
@@ -387,7 +387,7 @@ void PointerAnalysis::resolveIndCalls(const CallICFGNode* cs, const PointsTo& ta
387
387
  return;
388
388
  }
389
389
 
390
- if(ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(pag->getGNode(*ii)))
390
+ if(const ObjVar* objPN = pag->getObjVar(*ii))
391
391
  {
392
392
  const BaseObjVar* obj = pag->getBaseObject(objPN->getId());
393
393
 
@@ -436,7 +436,7 @@ void PointerAnalysis::getVFnsFromPts(const CallICFGNode* cs, const PointsTo &tar
436
436
  const VTableSet &chaVtbls = chgraph->getCSVtblsBasedonCHA(cs);
437
437
  for (PointsTo::iterator it = target.begin(), eit = target.end(); it != eit; ++it)
438
438
  {
439
- const PAGNode *ptdnode = pag->getGNode(*it);
439
+ const SVFVar* ptdnode = pag->getSVFVar(*it);
440
440
  const GlobalObjVar* pVar = nullptr;
441
441
  if (isa<ObjVar>(ptdnode) && isa<GlobalObjVar>(pag->getBaseObject(ptdnode->getId())))
442
442
  {
@@ -135,7 +135,7 @@ void BVDataPTAImpl::expandFIObjs(const PointsTo& pts, PointsTo& expandedPts)
135
135
  expandedPts = pts;;
136
136
  for(PointsTo::iterator pit = pts.begin(), epit = pts.end(); pit!=epit; ++pit)
137
137
  {
138
- if (pag->getBaseObjVar(*pit) == *pit || isFieldInsensitive(*pit))
138
+ if (pag->getBaseObjVarID(*pit) == *pit || isFieldInsensitive(*pit))
139
139
  {
140
140
  expandedPts |= pag->getAllFieldsObjVars(*pit);
141
141
  }
@@ -147,7 +147,7 @@ void BVDataPTAImpl::expandFIObjs(const NodeBS& pts, NodeBS& expandedPts)
147
147
  expandedPts = pts;
148
148
  for (const NodeID o : pts)
149
149
  {
150
- if (pag->getBaseObjVar(o) == o || isFieldInsensitive(o))
150
+ if (pag->getBaseObjVarID(o) == o || isFieldInsensitive(o))
151
151
  {
152
152
  expandedPts |= pag->getAllFieldsObjVars(o);
153
153
  }
@@ -176,7 +176,7 @@ void BVDataPTAImpl::writeObjVarToFile(const string& filename)
176
176
  {
177
177
  PAGNode* pagNode = it->second;
178
178
  if (!isa<ObjVar>(pagNode)) continue;
179
- NodeID n = pag->getBaseObjVar(it->first);
179
+ NodeID n = pag->getBaseObjVarID(it->first);
180
180
  if (NodeIDs.test(n)) continue;
181
181
  f << n << " ";
182
182
  f << isFieldInsensitive(n) << "\n";
@@ -224,10 +224,10 @@ void BVDataPTAImpl::writePtsResultToFile(std::fstream& f)
224
224
  void BVDataPTAImpl::writeGepObjVarMapToFile(std::fstream& f)
225
225
  {
226
226
  //write gepObjVarMap to file(in form of: baseID offset gepObjNodeId)
227
- SVFIR::NodeOffsetMap &gepObjVarMap = pag->getGepObjNodeMap();
228
- for(SVFIR::NodeOffsetMap::const_iterator it = gepObjVarMap.begin(), eit = gepObjVarMap.end(); it != eit; it++)
227
+ SVFIR::OffsetToGepVarMap &gepObjVarMap = pag->getGepObjNodeMap();
228
+ for(SVFIR::OffsetToGepVarMap::const_iterator it = gepObjVarMap.begin(), eit = gepObjVarMap.end(); it != eit; it++)
229
229
  {
230
- const SVFIR::NodeOffset offsetPair = it -> first;
230
+ const SVFIR::GepOffset offsetPair = it -> first;
231
231
  //write the base id to file
232
232
  f << offsetPair.first << " ";
233
233
  //write the offset to file
@@ -270,7 +270,7 @@ void BVDataPTAImpl::writeToFile(const string& filename)
270
270
  {
271
271
  PAGNode* pagNode = it->second;
272
272
  if (!isa<ObjVar>(pagNode)) continue;
273
- NodeID n = pag->getBaseObjVar(it->first);
273
+ NodeID n = pag->getBaseObjVarID(it->first);
274
274
  if (NodeIDs.test(n)) continue;
275
275
  f << n << " ";
276
276
  f << isFieldInsensitive(n) << "\n";
@@ -344,7 +344,7 @@ void BVDataPTAImpl::readGepObjVarMapFromFile(std::ifstream& F)
344
344
  {
345
345
  string line;
346
346
  //read GepObjVarMap from file
347
- SVFIR::NodeOffsetMap gepObjVarMap = pag->getGepObjNodeMap();
347
+ SVFIR::OffsetToGepVarMap gepObjVarMap = pag->getGepObjNodeMap();
348
348
  while (F.good())
349
349
  {
350
350
  getline(F, line);
@@ -355,20 +355,20 @@ void BVDataPTAImpl::readGepObjVarMapFromFile(std::ifstream& F)
355
355
  size_t offset;
356
356
  NodeID id;
357
357
  ss >> base >> offset >>id;
358
- SVFIR::NodeOffsetMap::const_iterator iter = gepObjVarMap.find(std::make_pair(base, offset));
358
+ SVFIR::OffsetToGepVarMap::const_iterator iter = gepObjVarMap.find(std::make_pair(base, offset));
359
359
  if (iter == gepObjVarMap.end())
360
360
  {
361
- SVFVar* node = pag->getGNode(base);
361
+ const SVFVar* node = pag->getSVFVar(base);
362
362
  const BaseObjVar* obj = nullptr;
363
- if (GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(node))
363
+ if (const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(node))
364
364
  {
365
365
  obj = gepObjVar->getBaseObj();
366
366
  }
367
- else if (BaseObjVar* baseNode = SVFUtil::dyn_cast<BaseObjVar>(node))
367
+ else if (const BaseObjVar* baseNode = SVFUtil::dyn_cast<BaseObjVar>(node))
368
368
  {
369
369
  obj = baseNode;
370
370
  }
371
- else if (DummyObjVar* baseNode = SVFUtil::dyn_cast<DummyObjVar>(node))
371
+ else if (const DummyObjVar* baseNode = SVFUtil::dyn_cast<DummyObjVar>(node))
372
372
  {
373
373
  obj = baseNode;
374
374
  }
@@ -446,7 +446,7 @@ void BVDataPTAImpl::dumpTopLevelPtsTo()
446
446
  for (OrderedNodeSet::iterator nIter = this->getAllValidPtrs().begin();
447
447
  nIter != this->getAllValidPtrs().end(); ++nIter)
448
448
  {
449
- const PAGNode* node = getPAG()->getGNode(*nIter);
449
+ const SVFVar* node = getPAG()->getSVFVar(*nIter);
450
450
  if (getPAG()->isValidTopLevelPtr(node))
451
451
  {
452
452
  const PointsTo& pts = this->getPts(node->getId());
@@ -536,7 +536,7 @@ void BVDataPTAImpl::onTheFlyThreadCallGraphSolve(const CallSiteToFunPtrMap& call
536
536
  const NodeBS targets = this->getPts(pVar->getId()).toNodeBS();
537
537
  for(NodeBS::iterator ii = targets.begin(), ie = targets.end(); ii != ie; ++ii)
538
538
  {
539
- if(ObjVar *objPN = SVFUtil::dyn_cast<ObjVar>(pag->getGNode(*ii)))
539
+ if(const ObjVar *objPN = pag->getObjVar(*ii))
540
540
  {
541
541
  const BaseObjVar* obj = pag->getBaseObject(objPN->getId());
542
542
  if(obj->isFunction())
@@ -558,7 +558,7 @@ void BVDataPTAImpl::onTheFlyThreadCallGraphSolve(const CallSiteToFunPtrMap& call
558
558
  void BVDataPTAImpl::normalizePointsTo()
559
559
  {
560
560
  SVFIR::MemObjToFieldsMap &memToFieldsMap = pag->getMemToFieldsMap();
561
- SVFIR::NodeOffsetMap &GepObjVarMap = pag->getGepObjNodeMap();
561
+ SVFIR::OffsetToGepVarMap &GepObjVarMap = pag->getGepObjNodeMap();
562
562
 
563
563
  // collect each gep node whose base node has been set as field-insensitive
564
564
  NodeBS dropNodes;
@@ -572,7 +572,7 @@ void BVDataPTAImpl::normalizePointsTo()
572
572
  {
573
573
  for (NodeID id : t.second)
574
574
  {
575
- if (SVFUtil::isa<GepObjVar>(pag->getGNode(id)))
575
+ if (SVFUtil::isa<GepObjVar>(pag->getSVFVar(id)))
576
576
  {
577
577
  dropNodes.set(id);
578
578
  }
@@ -592,7 +592,7 @@ void BVDataPTAImpl::normalizePointsTo()
592
592
  {
593
593
  if (!dropNodes.test(obj))
594
594
  continue;
595
- NodeID baseObj = pag->getBaseObjVar(obj);
595
+ NodeID baseObj = pag->getBaseObjVarID(obj);
596
596
  clearPts(n, obj);
597
597
  addPts(n, baseObj);
598
598
  }
@@ -602,7 +602,7 @@ void BVDataPTAImpl::normalizePointsTo()
602
602
  // and remove those nodes from pag
603
603
  for (NodeID n: dropNodes)
604
604
  {
605
- NodeID base = pag->getBaseObjVar(n);
605
+ NodeID base = pag->getBaseObjVarID(n);
606
606
  GepObjVar *gepNode = SVFUtil::dyn_cast<GepObjVar>(pag->getGNode(n));
607
607
  const APOffset apOffset = gepNode->getConstantFieldIdx();
608
608
  GepObjVarMap.erase(std::make_pair(base, apOffset));
@@ -79,7 +79,7 @@ void SaberSVFGBuilder::collectGlobals(BVDataPTAImpl* pta)
79
79
 
80
80
  if(GepObjVar* gepobj = SVFUtil::dyn_cast<GepObjVar>(pagNode))
81
81
  {
82
- if(SVFUtil::isa<DummyObjVar>(pag->getGNode(gepobj->getBaseNode())))
82
+ if(SVFUtil::isa<DummyObjVar>(pag->getSVFVar(gepobj->getBaseNode())))
83
83
  continue;
84
84
  }
85
85
  if ((isa<ObjVar>(pagNode) && isa<GlobalObjVar>(pag->getBaseObject(pagNode->getId()))) ||
@@ -121,7 +121,7 @@ PointsTo& SaberSVFGBuilder::CollectPtsChain(BVDataPTAImpl* pta, NodeID id, NodeT
121
121
  {
122
122
  SVFIR* pag = svfg->getPAG();
123
123
 
124
- NodeID baseId = pag->getBaseObjVar(id);
124
+ NodeID baseId = pag->getBaseObjVarID(id);
125
125
  NodeToPTSSMap::iterator it = cachedPtsMap.find(baseId);
126
126
  if(it!=cachedPtsMap.end())
127
127
  {
@@ -135,7 +135,7 @@ PointsTo& SaberSVFGBuilder::CollectPtsChain(BVDataPTAImpl* pta, NodeID id, NodeT
135
135
  {
136
136
  if(pta->isFIObjNode(baseId))
137
137
  {
138
- ValVar* valVar = SVFUtil::dyn_cast<ValVar>(pag->getGNode(baseId));
138
+ const ValVar* valVar = SVFUtil::dyn_cast<ValVar>(pag->getSVFVar(baseId));
139
139
  if(valVar && valVar->getICFGNode() && SVFUtil::isExtCall(valVar->getICFGNode()))
140
140
  {
141
141
  return pts;
@@ -485,12 +485,12 @@ NodeID SVFIR::addGepValNode(NodeID curInst,const ValVar* baseVar, const AccessPa
485
485
  */
486
486
  NodeID SVFIR::getGepObjVar(NodeID id, const APOffset& apOffset)
487
487
  {
488
- SVFVar* node = pag->getGNode(id);
489
- if (GepObjVar* gepNode = SVFUtil::dyn_cast<GepObjVar>(node))
488
+ const SVFVar* node = pag->getSVFVar(id);
489
+ if (const GepObjVar* gepNode = SVFUtil::dyn_cast<GepObjVar>(node))
490
490
  return getGepObjVar(gepNode->getBaseObj(), gepNode->getConstantFieldIdx() + apOffset);
491
- else if (BaseObjVar* baseNode = SVFUtil::dyn_cast<BaseObjVar>(node))
491
+ else if (const BaseObjVar* baseNode = SVFUtil::dyn_cast<BaseObjVar>(node))
492
492
  return getGepObjVar(baseNode, apOffset);
493
- else if (DummyObjVar* baseNode = SVFUtil::dyn_cast<DummyObjVar>(node))
493
+ else if (const DummyObjVar* baseNode = SVFUtil::dyn_cast<DummyObjVar>(node))
494
494
  return getGepObjVar(baseNode, apOffset);
495
495
  else
496
496
  {
@@ -518,7 +518,7 @@ NodeID SVFIR::getGepObjVar(const BaseObjVar* baseObj, const APOffset& apOffset)
518
518
  // Base and first field are the same memory location.
519
519
  if (Options::FirstFieldEqBase() && newLS == 0) return base;
520
520
 
521
- NodeOffsetMap::iterator iter = GepObjVarMap.find(std::make_pair(base, newLS));
521
+ OffsetToGepVarMap::iterator iter = GepObjVarMap.find(std::make_pair(base, newLS));
522
522
  if (iter == GepObjVarMap.end())
523
523
  {
524
524
  NodeID gepId = NodeIDAllocator::get()->allocateGepObjectId(base, apOffset, Options::MaxFieldLimit());
@@ -566,7 +566,7 @@ NodeBS& SVFIR::getAllFieldsObjVars(const BaseObjVar* obj)
566
566
  */
567
567
  NodeBS& SVFIR::getAllFieldsObjVars(NodeID id)
568
568
  {
569
- const SVFVar* node = pag->getGNode(id);
569
+ const SVFVar* node = pag->getSVFVar(id);
570
570
  assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
571
571
  return getAllFieldsObjVars(getBaseObject(id));
572
572
  }
@@ -578,7 +578,7 @@ NodeBS& SVFIR::getAllFieldsObjVars(NodeID id)
578
578
  */
579
579
  NodeBS SVFIR::getFieldsAfterCollapse(NodeID id)
580
580
  {
581
- const SVFVar* node = pag->getGNode(id);
581
+ const SVFVar* node = pag->getSVFVar(id);
582
582
  assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
583
583
  const BaseObjVar* obj = getBaseObject(id);
584
584
  if(obj->isFieldInsensitive())
@@ -732,7 +732,7 @@ void SVFIR::initialiseCandidatePointers()
732
732
  */
733
733
  bool SVFIR::isValidPointer(NodeID nodeId) const
734
734
  {
735
- SVFVar* node = pag->getGNode(nodeId);
735
+ const SVFVar* node = pag->getSVFVar(nodeId);
736
736
 
737
737
  if(node->isPointer())
738
738
  if (const ValVar* pVar = pag->getBaseValVar(nodeId))
@@ -230,7 +230,7 @@ void CDGBuilder::buildICFGNodeControlMap()
230
230
  SVFIR* pag = PAG::getPAG();
231
231
  _controlDG->addCDGEdgeFromSrcDst(
232
232
  controlNode, controllee,
233
- pag->getGNode(pag->getNullPtr()), pos);
233
+ pag->getSVFVar(pag->getNullPtr()), pos);
234
234
  }
235
235
 
236
236
  }
@@ -394,21 +394,21 @@ void AndersenBase::heapAllocatorViaIndCall(const CallICFGNode* cs, NodePairSet &
394
394
  void AndersenBase::normalizePointsTo()
395
395
  {
396
396
  SVFIR::MemObjToFieldsMap &memToFieldsMap = pag->getMemToFieldsMap();
397
- SVFIR::NodeOffsetMap &GepObjVarMap = pag->getGepObjNodeMap();
397
+ SVFIR::OffsetToGepVarMap &GepObjVarMap = pag->getGepObjNodeMap();
398
398
 
399
399
  // clear GepObjVarMap/memToFieldsMap/nodeToSubsMap/nodeToRepMap
400
400
  // for redundant gepnodes and remove those nodes from pag
401
401
  for (NodeID n: redundantGepNodes)
402
402
  {
403
- NodeID base = pag->getBaseObjVar(n);
404
- GepObjVar *gepNode = SVFUtil::dyn_cast<GepObjVar>(pag->getGNode(n));
403
+ NodeID base = pag->getBaseObjVarID(n);
404
+ const GepObjVar* gepNode = pag->getGepObjVar(n);
405
405
  assert(gepNode && "Not a gep node in redundantGepNodes set");
406
406
  const APOffset apOffset = gepNode->getConstantFieldIdx();
407
407
  GepObjVarMap.erase(std::make_pair(base, apOffset));
408
408
  memToFieldsMap[base].reset(n);
409
409
  cleanConsCG(n);
410
410
 
411
- pag->removeGNode(gepNode);
411
+ pag->removeGNode(const_cast<GepObjVar*>(gepNode));
412
412
  }
413
413
  }
414
414
 
@@ -556,7 +556,7 @@ bool Andersen::processLoad(NodeID node, const ConstraintEdge* load)
556
556
  /// make gcc in spec 2000 pass the flow-sensitive analysis.
557
557
  /// Try to handle black hole obj in an appropriate way.
558
558
  // if (pag->isBlkObjOrConstantObj(node))
559
- if (pag->isConstantObj(node) || pag->getGNode(load->getDstID())->isPointer() == false)
559
+ if (pag->isConstantObj(node) || pag->getSVFVar(load->getDstID())->isPointer() == false)
560
560
  return false;
561
561
 
562
562
  numOfProcessedLoad++;
@@ -576,7 +576,7 @@ bool Andersen::processStore(NodeID node, const ConstraintEdge* store)
576
576
  /// make gcc in spec 2000 pass the flow-sensitive analysis.
577
577
  /// Try to handle black hole obj in an appropriate way
578
578
  // if (pag->isBlkObjOrConstantObj(node))
579
- if (pag->isConstantObj(node) || pag->getGNode(store->getSrcID())->isPointer() == false)
579
+ if (pag->isConstantObj(node) || pag->getSVFVar(store->getSrcID())->isPointer() == false)
580
580
  return false;
581
581
 
582
582
  numOfProcessedStore++;
@@ -640,7 +640,7 @@ bool Andersen::processGepPts(const PointsTo& pts, const GepCGEdge* edge)
640
640
  if (!isFieldInsensitive(o))
641
641
  {
642
642
  setObjFieldInsensitive(o);
643
- consCG->addNodeToBeCollapsed(consCG->getBaseObjVar(o));
643
+ consCG->addNodeToBeCollapsed(consCG->getBaseObjVarID(o));
644
644
  }
645
645
 
646
646
  // Add the field-insensitive node into pts.
@@ -932,7 +932,7 @@ void Andersen::dumpTopLevelPtsTo()
932
932
  for (OrderedNodeSet::iterator nIter = this->getAllValidPtrs().begin();
933
933
  nIter != this->getAllValidPtrs().end(); ++nIter)
934
934
  {
935
- const PAGNode* node = getPAG()->getGNode(*nIter);
935
+ const SVFVar* node = getPAG()->getSVFVar(*nIter);
936
936
  if (getPAG()->isValidTopLevelPtr(node))
937
937
  {
938
938
  const PointsTo& pts = this->getPts(node->getId());
@@ -955,7 +955,7 @@ void Andersen::dumpTopLevelPtsTo()
955
955
  for (multiset<u32_t>::const_iterator it = line.begin(); it != line.end(); ++it)
956
956
  {
957
957
  if(Options::PrintFieldWithBasePrefix())
958
- if (auto gepNode = SVFUtil::dyn_cast<GepObjVar>(pag->getGNode(*it)))
958
+ if (auto gepNode = pag->getGepObjVar(*it))
959
959
  outs() << gepNode->getBaseNode() << "_" << gepNode->getConstantFieldIdx() << " ";
960
960
  else
961
961
  outs() << *it << " ";
@@ -73,10 +73,10 @@ void AndersenStat::collectCycleInfo(ConstraintGraph* consCG)
73
73
  for (NodeBS::iterator it = subNodes.begin(), eit = subNodes.end(); it != eit; ++it)
74
74
  {
75
75
  NodeID nodeId = *it;
76
- PAGNode* pagNode = pta->getPAG()->getGNode(nodeId);
76
+ const SVFVar* pagNode = pta->getPAG()->getSVFVar(nodeId);
77
77
  if (SVFUtil::isa<ObjVar>(pagNode) && pta->isFieldInsensitive(nodeId))
78
78
  {
79
- NodeID baseId = consCG->getBaseObjVar(nodeId);
79
+ NodeID baseId = consCG->getBaseObjVarID(nodeId);
80
80
  clone.reset(nodeId);
81
81
  clone.set(baseId);
82
82
  }
@@ -141,7 +141,7 @@ void AndersenStat::constraintGraphStat()
141
141
  if(nodeIt->second->getInEdges().empty() && nodeIt->second->getOutEdges().empty())
142
142
  continue;
143
143
  cgNodeNumber++;
144
- if(SVFUtil::isa<ObjVar>(pta->getPAG()->getGNode(nodeIt->first)))
144
+ if(SVFUtil::isa<ObjVar>(pta->getPAG()->getSVFVar(nodeIt->first)))
145
145
  objNodeNumber++;
146
146
 
147
147
  u32_t nCopyIn = nodeIt->second->getDirectInEdges().size();
@@ -289,7 +289,7 @@ void AndersenStat::performStat()
289
289
  totalPointers++;
290
290
  totalPtsSize+=size;
291
291
 
292
- if(pta->getPAG()->isValidTopLevelPtr(pta->getPAG()->getGNode(node)))
292
+ if(pta->getPAG()->isValidTopLevelPtr(pta->getPAG()->getSVFVar(node)))
293
293
  {
294
294
  totalTopLevPointers++;
295
295
  totalTopLevPtsSize+=size;