svf-lib 1.0.1574 → 1.0.1576

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.
@@ -52,7 +52,7 @@ public:
52
52
  typedef FIFOWorkList<NodeID> WorkList;
53
53
 
54
54
  protected:
55
- SVFIR*pag;
55
+ SVFIR* pag;
56
56
  NodeToRepMap nodeToRepMap;
57
57
  NodeToSubsMap nodeToSubsMap;
58
58
  WorkList nodesToBeCollapsed;
@@ -180,7 +180,7 @@ public:
180
180
  /// Add Copy edge
181
181
  CopyCGEdge* addCopyCGEdge(NodeID src, NodeID dst);
182
182
  /// Add Gep edge
183
- NormalGepCGEdge* addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath& ls);
183
+ NormalGepCGEdge* addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath& ap);
184
184
  VariantGepCGEdge* addVariantGepCGEdge(NodeID src, NodeID dst);
185
185
  /// Add Load edge
186
186
  LoadCGEdge* addLoadCGEdge(NodeID src, NodeID dst);
@@ -325,9 +325,9 @@ public:
325
325
  return (mem->getMaxFieldOffsetLimit() == 1);
326
326
  }
327
327
  /// Get a field of a memory object
328
- inline NodeID getGepObjVar(NodeID id, const APOffset& ls)
328
+ inline NodeID getGepObjVar(NodeID id, const APOffset& apOffset)
329
329
  {
330
- NodeID gep = pag->getGepObjVar(id,ls);
330
+ NodeID gep = pag->getGepObjVar(id, apOffset);
331
331
  /// Create a node when it is (1) not exist on graph and (2) not merged
332
332
  if(sccRepNode(gep)==gep && hasConstraintNode(gep)==false)
333
333
  addConstraintNode(new ConstraintNode(gep),gep);
@@ -269,7 +269,7 @@ private:
269
269
  NormalGepCGEdge(const NormalGepCGEdge &); ///< place holder
270
270
  void operator=(const NormalGepCGEdge &); ///< place holder
271
271
 
272
- AccessPath ls; ///< location set of the gep edge
272
+ AccessPath ap; ///< Access path of the gep edge
273
273
 
274
274
  public:
275
275
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -293,20 +293,22 @@ public:
293
293
  //@}
294
294
 
295
295
  /// Constructor
296
- NormalGepCGEdge(ConstraintNode* s, ConstraintNode* d, const AccessPath& l, EdgeID id)
297
- : GepCGEdge(s,d,NormalGep,id), ls(l)
298
- {}
296
+ NormalGepCGEdge(ConstraintNode* s, ConstraintNode* d, const AccessPath& ap,
297
+ EdgeID id)
298
+ : GepCGEdge(s, d, NormalGep, id), ap(ap)
299
+ {
300
+ }
299
301
 
300
302
  /// Get location set of the gep edge
301
303
  inline const AccessPath& getAccessPath() const
302
304
  {
303
- return ls;
305
+ return ap;
304
306
  }
305
307
 
306
308
  /// Get location set of the gep edge
307
309
  inline APOffset getConstantFieldIdx() const
308
310
  {
309
- return ls.getConstantFieldIdx();
311
+ return ap.getConstantFieldIdx();
310
312
  }
311
313
 
312
314
  };
@@ -68,9 +68,9 @@ public:
68
68
  AccessPath(APOffset o = 0) : fldIdx(o) {}
69
69
 
70
70
  /// Copy Constructor
71
- AccessPath(const AccessPath& ls)
72
- : fldIdx(ls.fldIdx),
73
- offsetVarAndGepTypePairs(ls.getOffsetVarAndGepTypePairVec())
71
+ AccessPath(const AccessPath& ap)
72
+ : fldIdx(ap.fldIdx),
73
+ offsetVarAndGepTypePairs(ap.getOffsetVarAndGepTypePairVec())
74
74
  {
75
75
  }
76
76
 
@@ -146,11 +146,12 @@ private:
146
146
 
147
147
  template <> struct std::hash<SVF::AccessPath>
148
148
  {
149
- size_t operator()(const SVF::AccessPath &ls) const
149
+ size_t operator()(const SVF::AccessPath &ap) const
150
150
  {
151
151
  SVF::Hash<std::pair<SVF::NodeID, SVF::NodeID>> h;
152
152
  std::hash<SVF::AccessPath::OffsetVarAndGepTypePairs> v;
153
- return h(std::make_pair(ls.getConstantFieldIdx(), v(ls.getOffsetVarAndGepTypePairVec())));
153
+ return h(std::make_pair(ap.getConstantFieldIdx(),
154
+ v(ap.getOffsetVarAndGepTypePairVec())));
154
155
  }
155
156
  };
156
157
 
@@ -338,9 +338,9 @@ public:
338
338
  {
339
339
  return pag->getFIObjVar(id);
340
340
  }
341
- inline NodeID getGepObjVar(NodeID id, const APOffset& ls)
341
+ inline NodeID getGepObjVar(NodeID id, const APOffset& ap)
342
342
  {
343
- return pag->getGepObjVar(id,ls);
343
+ return pag->getGepObjVar(id, ap);
344
344
  }
345
345
  virtual inline const NodeBS& getAllFieldsObjVars(NodeID id)
346
346
  {
@@ -422,7 +422,7 @@ private:
422
422
  cJSON* toJson(const CHEdge* edge); // CHGraph Edge
423
423
 
424
424
  cJSON* toJson(const CallSite& cs);
425
- cJSON* toJson(const AccessPath& ls);
425
+ cJSON* toJson(const AccessPath& ap);
426
426
  cJSON* toJson(const SVFLoop* loop);
427
427
  cJSON* toJson(const MemObj* memObj);
428
428
  cJSON* toJson(const ObjTypeInfo* objTypeInfo); // Only owned by MemObj
@@ -1104,7 +1104,7 @@ private:
1104
1104
  void readJson(const cJSON* obj, CHEdge*& edge); // CHGraph Edge
1105
1105
  void readJson(const cJSON* obj, CallSite& cs); // CHGraph's csToClassMap
1106
1106
 
1107
- void readJson(const cJSON* obj, AccessPath& ls);
1107
+ void readJson(const cJSON* obj, AccessPath& ap);
1108
1108
  void readJson(const cJSON* obj, SVFLoop*& loop);
1109
1109
  void readJson(const cJSON* obj, MemObj*& memObj);
1110
1110
  void readJson(const cJSON* obj,
@@ -328,7 +328,8 @@ public:
328
328
  //@}
329
329
 
330
330
  /// Due to constaint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar.
331
- NodeID getGepValVar(const SVFValue* curInst, NodeID base, const AccessPath& ls) const;
331
+ NodeID getGepValVar(const SVFValue* curInst, NodeID base,
332
+ const AccessPath& ap) const;
332
333
 
333
334
  /// Add/get indirect callsites
334
335
  //@{
@@ -392,9 +393,9 @@ public:
392
393
  //@}
393
394
 
394
395
  /// Get a field SVFIR Object node according to base mem obj and offset
395
- NodeID getGepObjVar(const MemObj* obj, const APOffset& ls);
396
+ NodeID getGepObjVar(const MemObj* obj, const APOffset& ap);
396
397
  /// Get a field obj SVFIR node according to a mem obj and a given offset
397
- NodeID getGepObjVar(NodeID id, const APOffset& ls) ;
398
+ NodeID getGepObjVar(NodeID id, const APOffset& ap) ;
398
399
  /// Get a field-insensitive obj SVFIR node according to a mem obj
399
400
  //@{
400
401
  inline NodeID getFIObjVar(const MemObj* obj) const
@@ -557,9 +558,9 @@ private:
557
558
  }
558
559
 
559
560
  /// Add a temp field value node, this method can only invoked by getGepValVar
560
- NodeID addGepValNode(const SVFValue* curInst,const SVFValue* val, const AccessPath& ls, NodeID i, const SVFType* type);
561
+ NodeID addGepValNode(const SVFValue* curInst,const SVFValue* val, const AccessPath& ap, NodeID i, const SVFType* type);
561
562
  /// Add a field obj node, this method can only invoked by getGepObjVar
562
- NodeID addGepObjNode(const MemObj* obj, const APOffset& ls);
563
+ NodeID addGepObjNode(const MemObj* obj, const APOffset& apOffset);
563
564
  /// Add a field-insensitive node, this method can only invoked by getFIGepObjNode
564
565
  NodeID addFIObjNode(const MemObj* obj);
565
566
  //@}
@@ -665,12 +666,12 @@ private:
665
666
  RetPE* addRetPE(NodeID src, NodeID dst, const CallICFGNode* cs,
666
667
  const FunExitICFGNode* exit);
667
668
  /// Add Gep edge
668
- GepStmt* addGepStmt(NodeID src, NodeID dst, const AccessPath& ls,
669
+ GepStmt* addGepStmt(NodeID src, NodeID dst, const AccessPath& ap,
669
670
  bool constGep);
670
671
  /// Add Offset(Gep) edge
671
- GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const AccessPath& ls);
672
+ GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const AccessPath& ap);
672
673
  /// Add Variant(Gep) edge
673
- GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const AccessPath& ls);
674
+ GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const AccessPath& ap);
674
675
  /// Add Thread fork edge for parameter passing
675
676
  TDForkPE* addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode* cs,
676
677
  const FunEntryICFGNode* entry);
@@ -465,7 +465,7 @@ private:
465
465
  GepStmt(const GepStmt &); ///< place holder
466
466
  void operator=(const GepStmt &); ///< place holder
467
467
 
468
- AccessPath ls; ///< location set of the gep edge
468
+ AccessPath ap; ///< Access path of the GEP edge
469
469
  bool variantField; ///< Gep statement with a variant field index (pointer arithmetic) for struct field access (e.g., p = &(q + f), where f is a variable)
470
470
  public:
471
471
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -486,7 +486,7 @@ public:
486
486
 
487
487
  inline const AccessPath& getAccessPath() const
488
488
  {
489
- return ls;
489
+ return ap;
490
490
  }
491
491
  inline const AccessPath::OffsetVarAndGepTypePairs getOffsetVarAndGepTypePairVec() const
492
492
  {
@@ -515,8 +515,8 @@ public:
515
515
  }
516
516
 
517
517
  /// constructor
518
- GepStmt(SVFVar* s, SVFVar* d, const AccessPath& l, bool varfld = false)
519
- : AssignStmt(s, d, SVFStmt::Gep), ls(l), variantField(varfld)
518
+ GepStmt(SVFVar* s, SVFVar* d, const AccessPath& ap, bool varfld = false)
519
+ : AssignStmt(s, d, SVFStmt::Gep), ap(ap), variantField(varfld)
520
520
  {
521
521
  }
522
522
 
@@ -383,7 +383,7 @@ class GepValVar: public ValVar
383
383
  friend class SVFIRReader;
384
384
 
385
385
  private:
386
- AccessPath ls; // AccessPath
386
+ AccessPath ap; // AccessPath
387
387
  const SVFType* gepValType;
388
388
 
389
389
  /// Constructor to create empty GeValVar (for SVFIRReader/deserialization)
@@ -411,16 +411,16 @@ public:
411
411
  //@}
412
412
 
413
413
  /// Constructor
414
- GepValVar(const SVFValue* val, NodeID i, const AccessPath& l,
414
+ GepValVar(const SVFValue* val, NodeID i, const AccessPath& ap,
415
415
  const SVFType* ty)
416
- : ValVar(val, i, GepValNode), ls(l), gepValType(ty)
416
+ : ValVar(val, i, GepValNode), ap(ap), gepValType(ty)
417
417
  {
418
418
  }
419
419
 
420
420
  /// offset of the base value variable
421
421
  inline APOffset getConstantFieldIdx() const
422
422
  {
423
- return ls.getConstantFieldIdx();
423
+ return ap.getConstantFieldIdx();
424
424
  }
425
425
 
426
426
  /// Return name of a LLVM value
@@ -451,7 +451,7 @@ class GepObjVar: public ObjVar
451
451
  friend class SVFIRReader;
452
452
 
453
453
  private:
454
- APOffset ls = 0;
454
+ APOffset apOffset = 0;
455
455
  NodeID base = 0;
456
456
 
457
457
  /// Constructor to create empty GepObjVar (for SVFIRReader/deserialization)
@@ -480,9 +480,9 @@ public:
480
480
  //@}
481
481
 
482
482
  /// Constructor
483
- GepObjVar(const MemObj* mem, NodeID i, const APOffset& l,
483
+ GepObjVar(const MemObj* mem, NodeID i, const APOffset& apOffset,
484
484
  PNODEK ty = GepObjNode)
485
- : ObjVar(mem->getValue(), i, mem, ty), ls(l)
485
+ : ObjVar(mem->getValue(), i, mem, ty), apOffset(apOffset)
486
486
  {
487
487
  base = mem->getId();
488
488
  }
@@ -490,7 +490,7 @@ public:
490
490
  /// offset of the mem object
491
491
  inline APOffset getConstantFieldIdx() const
492
492
  {
493
- return ls;
493
+ return apOffset;
494
494
  }
495
495
 
496
496
  /// Set the base object from which this GEP node came from.
@@ -508,15 +508,15 @@ public:
508
508
  /// Return the type of this gep object
509
509
  inline virtual const SVFType* getType() const
510
510
  {
511
- return SymbolTableInfo::SymbolInfo()->getFlatternedElemType(mem->getType(), ls);
511
+ return SymbolTableInfo::SymbolInfo()->getFlatternedElemType(mem->getType(), apOffset);
512
512
  }
513
513
 
514
514
  /// Return name of a LLVM value
515
515
  inline const std::string getValueName() const
516
516
  {
517
517
  if (value)
518
- return value->getName() + "_" + std::to_string(ls);
519
- return "offset_" + std::to_string(ls);
518
+ return value->getName() + "_" + std::to_string(apOffset);
519
+ return "offset_" + std::to_string(apOffset);
520
520
  }
521
521
 
522
522
  virtual const std::string toString() const;
@@ -333,7 +333,8 @@ public:
333
333
  virtual void dump();
334
334
 
335
335
  /// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
336
- virtual APOffset getModulusOffset(const MemObj* obj, const APOffset& ls);
336
+ virtual APOffset getModulusOffset(const MemObj* obj,
337
+ const APOffset& apOffset);
337
338
 
338
339
  ///The struct type with the most fields
339
340
  const SVFType* maxStruct;
@@ -453,7 +454,7 @@ public:
453
454
  bool isConstDataOrConstGlobal() const;
454
455
  bool isConstDataOrAggData() const;
455
456
  bool hasPtrObj() const;
456
- bool isNonPtrFieldObj(const APOffset& ls) const;
457
+ bool isNonPtrFieldObj(const APOffset& apOffset) const;
457
458
  //@}
458
459
 
459
460
  /// Operator overloading
@@ -621,7 +622,7 @@ public:
621
622
  {
622
623
  return hasFlag(HASPTR_OBJ);
623
624
  }
624
- virtual bool isNonPtrFieldObj(const APOffset& ls);
625
+ virtual bool isNonPtrFieldObj(const APOffset& apOffset);
625
626
  //@}
626
627
  };
627
628
 
@@ -261,7 +261,7 @@ public:
261
261
 
262
262
  friend bool eq(const Z3Expr &lhs, const Z3Expr &rhs)
263
263
  {
264
- return eq(lhs.getExpr(), rhs.getExpr());
264
+ return eq(lhs.getExpr().simplify(), rhs.getExpr().simplify());
265
265
  }
266
266
 
267
267
  z3::sort get_sort() const
@@ -293,7 +293,7 @@ public:
293
293
  /// compute NEG
294
294
  static inline Z3Expr NEG(const Z3Expr &z3Expr)
295
295
  {
296
- return !z3Expr;
296
+ return (!z3Expr).simplify();
297
297
  }
298
298
 
299
299
  /// compute AND, used for branch condition
@@ -216,10 +216,10 @@ protected:
216
216
  void processCE(const Value* val);
217
217
 
218
218
  /// Infer field index from byteoffset.
219
- u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, AccessPath& ls, APOffset idx);
219
+ u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, AccessPath& ap, APOffset idx);
220
220
 
221
221
  /// Compute offset of a gep instruction or gep constant expression
222
- bool computeGepOffset(const User *V, AccessPath& ls);
222
+ bool computeGepOffset(const User *V, AccessPath& ap);
223
223
 
224
224
  /// Get the base value of (i8* src and i8* dst) for external argument (e.g. memcpy(i8* dst, i8* src, int size))
225
225
  const Value* getBaseValueForExtArg(const Value* V);
@@ -287,7 +287,7 @@ protected:
287
287
  return nullPtr;
288
288
  }
289
289
 
290
- NodeID getGepValVar(const SVFValue* val, const AccessPath& ls, const SVFType* baseType);
290
+ NodeID getGepValVar(const SVFValue* val, const AccessPath& ap, const SVFType* baseType);
291
291
 
292
292
  void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
293
293
 
@@ -364,53 +364,53 @@ protected:
364
364
  inline void addStoreEdge(NodeID src, NodeID dst)
365
365
  {
366
366
  IntraICFGNode* node;
367
- if(const SVFInstruction* inst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
367
+ if (const SVFInstruction* inst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
368
368
  node = pag->getICFG()->getIntraICFGNode(inst);
369
369
  else
370
370
  node = nullptr;
371
- if(StoreStmt *edge = pag->addStoreStmt(src, dst, node))
371
+ if (StoreStmt* edge = pag->addStoreStmt(src, dst, node))
372
372
  setCurrentBBAndValueForPAGEdge(edge);
373
373
  }
374
374
  /// Add Call edge
375
375
  inline void addCallEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
376
376
  {
377
- if(CallPE *edge = pag->addCallPE(src, dst, cs, entry))
377
+ if (CallPE* edge = pag->addCallPE(src, dst, cs, entry))
378
378
  setCurrentBBAndValueForPAGEdge(edge);
379
379
  }
380
380
  /// Add Return edge
381
381
  inline void addRetEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
382
382
  {
383
- if(RetPE *edge = pag->addRetPE(src, dst, cs, exit))
383
+ if (RetPE* edge = pag->addRetPE(src, dst, cs, exit))
384
384
  setCurrentBBAndValueForPAGEdge(edge);
385
385
  }
386
386
  /// Add Gep edge
387
- inline void addGepEdge(NodeID src, NodeID dst, const AccessPath& ls, bool constGep)
387
+ inline void addGepEdge(NodeID src, NodeID dst, const AccessPath& ap, bool constGep)
388
388
  {
389
- if(GepStmt *edge = pag->addGepStmt(src, dst, ls, constGep))
389
+ if (GepStmt* edge = pag->addGepStmt(src, dst, ap, constGep))
390
390
  setCurrentBBAndValueForPAGEdge(edge);
391
391
  }
392
392
  /// Add Offset(Gep) edge
393
- inline void addNormalGepEdge(NodeID src, NodeID dst, const AccessPath& ls)
393
+ inline void addNormalGepEdge(NodeID src, NodeID dst, const AccessPath& ap)
394
394
  {
395
- if(GepStmt *edge = pag->addNormalGepStmt(src, dst, ls))
395
+ if (GepStmt* edge = pag->addNormalGepStmt(src, dst, ap))
396
396
  setCurrentBBAndValueForPAGEdge(edge);
397
397
  }
398
398
  /// Add Variant(Gep) edge
399
- inline void addVariantGepEdge(NodeID src, NodeID dst, const AccessPath& ls)
399
+ inline void addVariantGepEdge(NodeID src, NodeID dst, const AccessPath& ap)
400
400
  {
401
- if(GepStmt *edge = pag->addVariantGepStmt(src, dst, ls))
401
+ if (GepStmt* edge = pag->addVariantGepStmt(src, dst, ap))
402
402
  setCurrentBBAndValueForPAGEdge(edge);
403
403
  }
404
404
  /// Add Thread fork edge for parameter passing
405
405
  inline void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
406
406
  {
407
- if(TDForkPE *edge = pag->addThreadForkPE(src, dst, cs, entry))
407
+ if (TDForkPE* edge = pag->addThreadForkPE(src, dst, cs, entry))
408
408
  setCurrentBBAndValueForPAGEdge(edge);
409
409
  }
410
410
  /// Add Thread join edge for parameter passing
411
411
  inline void addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
412
412
  {
413
- if(TDJoinPE *edge = pag->addThreadJoinPE(src, dst, cs, exit))
413
+ if (TDJoinPE* edge = pag->addThreadJoinPE(src, dst, cs, exit))
414
414
  setCurrentBBAndValueForPAGEdge(edge);
415
415
  }
416
416
  //@}
@@ -261,7 +261,7 @@ public:
261
261
 
262
262
  friend bool eq(const Z3Expr &lhs, const Z3Expr &rhs)
263
263
  {
264
- return eq(lhs.getExpr(), rhs.getExpr());
264
+ return eq(lhs.getExpr().simplify(), rhs.getExpr().simplify());
265
265
  }
266
266
 
267
267
  z3::sort get_sort() const
@@ -293,7 +293,7 @@ public:
293
293
  /// compute NEG
294
294
  static inline Z3Expr NEG(const Z3Expr &z3Expr)
295
295
  {
296
- return !z3Expr;
296
+ return (!z3Expr).simplify();
297
297
  }
298
298
 
299
299
  /// compute AND, used for branch condition
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1574",
3
+ "version": "1.0.1576",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {