svf-lib 1.0.2182 → 1.0.2184

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/SVF-linux/Release-build/bin/ae +0 -0
  2. package/SVF-linux/Release-build/bin/cfl +0 -0
  3. package/SVF-linux/Release-build/bin/dvf +0 -0
  4. package/SVF-linux/Release-build/bin/llvm2svf +0 -0
  5. package/SVF-linux/Release-build/bin/mta +0 -0
  6. package/SVF-linux/Release-build/bin/saber +0 -0
  7. package/SVF-linux/Release-build/bin/svf-ex +0 -0
  8. package/SVF-linux/Release-build/bin/wpa +0 -0
  9. package/SVF-linux/Release-build/include/DDA/DDAVFSolver.h +5 -7
  10. package/SVF-linux/Release-build/include/Graphs/ConsG.h +2 -2
  11. package/SVF-linux/Release-build/include/Graphs/IRGraph.h +5 -18
  12. package/SVF-linux/Release-build/include/MemoryModel/PointerAnalysis.h +7 -7
  13. package/SVF-linux/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +2 -2
  14. package/SVF-linux/Release-build/include/SVFIR/SVFFileSystem.h +0 -12
  15. package/SVF-linux/Release-build/include/SVFIR/SVFIR.h +84 -106
  16. package/SVF-linux/Release-build/include/SVFIR/SVFVariables.h +239 -84
  17. package/SVF-linux/Release-build/include/SVFIR/SymbolTableInfo.h +18 -136
  18. package/SVF-linux/Release-build/lib/libSvfCore.a +0 -0
  19. package/SVF-linux/Release-build/lib/libSvfLLVM.a +0 -0
  20. package/SVF-osx/Release-build/bin/ae +0 -0
  21. package/SVF-osx/Release-build/bin/cfl +0 -0
  22. package/SVF-osx/Release-build/bin/dvf +0 -0
  23. package/SVF-osx/Release-build/bin/llvm2svf +0 -0
  24. package/SVF-osx/Release-build/bin/mta +0 -0
  25. package/SVF-osx/Release-build/bin/saber +0 -0
  26. package/SVF-osx/Release-build/bin/svf-ex +0 -0
  27. package/SVF-osx/Release-build/bin/wpa +0 -0
  28. package/SVF-osx/Release-build/include/DDA/DDAVFSolver.h +5 -7
  29. package/SVF-osx/Release-build/include/Graphs/ConsG.h +2 -2
  30. package/SVF-osx/Release-build/include/Graphs/IRGraph.h +5 -18
  31. package/SVF-osx/Release-build/include/MemoryModel/PointerAnalysis.h +7 -7
  32. package/SVF-osx/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +2 -2
  33. package/SVF-osx/Release-build/include/SVFIR/SVFFileSystem.h +0 -12
  34. package/SVF-osx/Release-build/include/SVFIR/SVFIR.h +84 -106
  35. package/SVF-osx/Release-build/include/SVFIR/SVFVariables.h +239 -84
  36. package/SVF-osx/Release-build/include/SVFIR/SymbolTableInfo.h +18 -136
  37. package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
  38. package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
  39. package/package.json +1 -1
@@ -37,9 +37,9 @@
37
37
  namespace SVF
38
38
  {
39
39
 
40
- class MemObj;
41
40
  class ObjTypeInfo;
42
41
  class StInfo;
42
+ class BaseObjVar;
43
43
 
44
44
  /*!
45
45
  * Symbol table of the memory model for analysis
@@ -70,8 +70,9 @@ public:
70
70
  /// llvm value to sym id map
71
71
  /// local (%) and global (@) identifiers are pointer types which have a value node id.
72
72
  typedef OrderedMap<const SVFValue*, SymID> ValueToIDMapTy;
73
- /// sym id to memory object map
74
- typedef OrderedMap<SymID, MemObj*> IDToMemMapTy;
73
+ /// sym id to obj type info map
74
+ typedef OrderedMap<SymID, ObjTypeInfo*> IDToTypeInfoMapTy;
75
+
75
76
  /// function to sym id map
76
77
  typedef OrderedMap<const SVFFunction*, SymID> FunToIDMapTy;
77
78
  /// struct type to struct info map
@@ -83,7 +84,7 @@ private:
83
84
  ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
84
85
  FunToIDMapTy returnSymMap; ///< return map
85
86
  FunToIDMapTy varargSymMap; ///< vararg map
86
- IDToMemMapTy objMap; ///< map a memory sym id to its obj
87
+ IDToTypeInfoMapTy objTypeInfoMap; ///< map a memory sym id to its obj
87
88
 
88
89
  // Singleton pattern here to enable instance of SymbolTableInfo can only be created once.
89
90
  static SymbolTableInfo* symInfo;
@@ -171,15 +172,6 @@ public:
171
172
  return (isBlkObj(id) || isConstantObj(id));
172
173
  }
173
174
 
174
- inline MemObj* getBlkObj() const
175
- {
176
- return getObj(blackholeSymID());
177
- }
178
- inline MemObj* getConstantObj() const
179
- {
180
- return getObj(constantSymID());
181
- }
182
-
183
175
  inline SymID blkPtrSymID() const
184
176
  {
185
177
  return BlkPtr;
@@ -200,10 +192,6 @@ public:
200
192
  return BlackHole;
201
193
  }
202
194
 
203
- /// Can only be invoked by SVFIR::addDummyNode() when creating SVFIR from file.
204
- const MemObj* createDummyObj(SymID symId, const SVFType* type);
205
- // @}
206
-
207
195
  /// Get different kinds of syms
208
196
  //@{
209
197
  SymID getValSym(const SVFValue* val);
@@ -220,10 +208,10 @@ public:
220
208
  return iter->second;
221
209
  }
222
210
 
223
- inline MemObj* getObj(SymID id) const
211
+ inline ObjTypeInfo* getObjTypeInfo(SymID id) const
224
212
  {
225
- IDToMemMapTy::const_iterator iter = objMap.find(id);
226
- assert(iter!=objMap.end() && "obj not found");
213
+ IDToTypeInfoMapTy::const_iterator iter = objTypeInfoMap.find(id);
214
+ assert(iter!=objTypeInfoMap.end() && "obj type info not found");
227
215
  return iter->second;
228
216
  }
229
217
 
@@ -267,14 +255,14 @@ public:
267
255
  return objSymMap;
268
256
  }
269
257
 
270
- inline IDToMemMapTy& idToObjMap()
258
+ inline IDToTypeInfoMapTy& idToObjTypeInfoMap()
271
259
  {
272
- return objMap;
260
+ return objTypeInfoMap;
273
261
  }
274
262
 
275
- inline const IDToMemMapTy& idToObjMap() const
263
+ inline const IDToTypeInfoMapTy& idToObjTypeInfoMap() const
276
264
  {
277
- return objMap;
265
+ return objTypeInfoMap;
278
266
  }
279
267
 
280
268
  inline FunToIDMapTy& retSyms()
@@ -311,6 +299,11 @@ public:
311
299
  return svfTypes.find(T) != svfTypes.end();
312
300
  }
313
301
 
302
+ /// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
303
+ ObjTypeInfo* createObjTypeInfo(const SVFType* type);
304
+
305
+ const ObjTypeInfo* createDummyObjTypeInfo(SymID symId, const SVFType* type);
306
+
314
307
  ///Get a reference to the components of struct_info.
315
308
  /// Number of flattened elements of an array or struct
316
309
  u32_t getNumOfFlattenElements(const SVFType* T);
@@ -333,8 +326,7 @@ public:
333
326
  virtual void dump();
334
327
 
335
328
  /// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
336
- virtual APOffset getModulusOffset(const MemObj* obj,
337
- const APOffset& apOffset);
329
+ virtual APOffset getModulusOffset(const BaseObjVar* baseObj, const APOffset& apOffset);
338
330
 
339
331
  ///The struct type with the most fields
340
332
  const SVFType* maxStruct;
@@ -359,9 +351,6 @@ protected:
359
351
  /// Return the flattened field type for struct type only
360
352
  const std::vector<const SVFType*>& getFlattenFieldTypes(const SVFStructType *T);
361
353
 
362
- /// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
363
- ObjTypeInfo* createObjTypeInfo(const SVFType* type);
364
-
365
354
  /// (owned) All SVF Types
366
355
  /// Every type T is mapped to StInfo
367
356
  /// which contains size (fsize) , offset(foffset)
@@ -375,113 +364,6 @@ protected:
375
364
 
376
365
  class SVFBaseNode;
377
366
 
378
- /*!
379
- * Memory object symbols or MemObj (address-taken variables in LLVM-based languages)
380
- */
381
- class MemObj
382
- {
383
- friend class SVFIRWriter;
384
- friend class SVFIRReader;
385
- friend class SVFIRBuilder;
386
-
387
- private:
388
- /// Type information of this object
389
- ObjTypeInfo* typeInfo;
390
- /// The unique value of this symbol/variable
391
- const SVFValue* refVal;
392
- /// The unique id to represent this symbol
393
- SymID symId;
394
-
395
- const SVFBaseNode* gNode;
396
-
397
- public:
398
- /// Constructor
399
- MemObj(SymID id, ObjTypeInfo* ti, const SVFValue* val = nullptr, const SVFBaseNode* node = nullptr);
400
-
401
- /// Destructor
402
- virtual ~MemObj()
403
- {
404
- destroy();
405
- }
406
-
407
- virtual const std::string toString() const;
408
-
409
- /// Get the reference value to this object
410
- inline const SVFValue* getValue() const
411
- {
412
- return refVal;
413
- }
414
-
415
- /// Get the reference value to this object
416
- inline const SVFBaseNode* getGNode() const
417
- {
418
- return gNode;
419
- }
420
-
421
- /// Get the memory object id
422
- inline SymID getId() const
423
- {
424
- return symId;
425
- }
426
-
427
- /// Get obj type
428
- const SVFType* getType() const;
429
-
430
- /// Get the number of elements of this object
431
- u32_t getNumOfElements() const;
432
-
433
- /// Set the number of elements of this object
434
- void setNumOfElements(u32_t num);
435
-
436
- /// Get max field offset limit
437
- u32_t getMaxFieldOffsetLimit() const;
438
-
439
- /// Return true if its field limit is 0
440
- bool isFieldInsensitive() const;
441
-
442
- /// Set the memory object to be field insensitive
443
- void setFieldInsensitive();
444
-
445
- /// Set the memory object to be field sensitive (up to max field limit)
446
- void setFieldSensitive();
447
-
448
- /// Whether it is a black hole object
449
- bool isBlackHoleObj() const;
450
-
451
- /// Get the byte size of this object
452
- u32_t getByteSizeOfObj() const;
453
-
454
- /// Check if byte size is a const value
455
- bool isConstantByteSize() const;
456
-
457
-
458
- /// object attributes methods
459
- //@{
460
- bool isFunction() const;
461
- bool isGlobalObj() const;
462
- bool isStaticObj() const;
463
- bool isStack() const;
464
- bool isHeap() const;
465
- bool isStruct() const;
466
- bool isArray() const;
467
- bool isVarStruct() const;
468
- bool isVarArray() const;
469
- bool isConstantStruct() const;
470
- bool isConstantArray() const;
471
- bool isConstDataOrConstGlobal() const;
472
- bool isConstDataOrAggData() const;
473
- //@}
474
-
475
- /// Operator overloading
476
- inline bool operator==(const MemObj& mem) const
477
- {
478
- return getValue() == mem.getValue();
479
- }
480
-
481
- /// Clean up memory
482
- void destroy();
483
- };
484
-
485
367
  /*!
486
368
  * Type Info of an abstract memory object
487
369
  */
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -473,8 +473,6 @@ protected:
473
473
  NodeID id = getPtrNodeID(var);
474
474
  const BaseObjVar* baseObj = _pag->getBaseObject(id);
475
475
  assert(baseObj && "base object is null??");
476
- const MemObj* obj = _pag->getObject(id);
477
- assert(obj && "object not found!!");
478
476
  if(SVFUtil::isa<StackObjVar>(baseObj))
479
477
  {
480
478
  if(const SVFFunction* svffun = _pag->getGNode(id)->getFunction())
@@ -645,14 +643,14 @@ protected:
645
643
 
646
644
  inline bool isArrayCondMemObj(const CVar& var) const
647
645
  {
648
- const MemObj* mem = _pag->getObject(getPtrNodeID(var));
649
- assert(mem && "memory object is null??");
650
- return mem->isArray();
646
+ const BaseObjVar* obj = _pag->getBaseObject(getPtrNodeID(var));
647
+ assert(obj && "base object is null??");
648
+ return obj->isArray();
651
649
  }
652
650
  inline bool isFieldInsenCondMemObj(const CVar& var) const
653
651
  {
654
- const MemObj* mem = _pag->getBaseObj(getPtrNodeID(var));
655
- return mem->isFieldInsensitive();
652
+ const BaseObjVar* baseObj = _pag->getBaseObject(getPtrNodeID(var));
653
+ return baseObj->isFieldInsensitive();
656
654
  }
657
655
  //@}
658
656
  private:
@@ -323,8 +323,8 @@ public:
323
323
  }
324
324
  inline bool isSingleFieldObj(NodeID id) const
325
325
  {
326
- const MemObj* mem = pag->getBaseObj(id);
327
- return (mem->getMaxFieldOffsetLimit() == 1);
326
+ const BaseObjVar* baseObj = pag->getBaseObject(id);
327
+ return (baseObj->getMaxFieldOffsetLimit() == 1);
328
328
  }
329
329
  /// Get a field of a memory object
330
330
  inline NodeID getGepObjVar(NodeID id, const APOffset& apOffset)
@@ -65,10 +65,11 @@ protected:
65
65
  SymbolTableInfo* symInfo;
66
66
 
67
67
  /// Add a node into the graph
68
- inline NodeID addNode(SVFVar* node, NodeID i)
68
+ inline NodeID addNode(SVFVar* node)
69
69
  {
70
- addGNode(i,node);
71
- return i;
70
+ assert(node && "cannot add a null node");
71
+ addGNode(node->getId(),node);
72
+ return node->getId();
72
73
  }
73
74
  /// Add an edge into the graph
74
75
  bool addEdge(SVFVar* src, SVFVar* dst, SVFStmt* edge);
@@ -94,12 +95,6 @@ protected:
94
95
  inserted.first->second.emplace(edge);
95
96
  }
96
97
  }
97
- /// get MemObj according to LLVM value
98
- inline const MemObj* getMemObj(const SVFValue* val) const
99
- {
100
- return symInfo->getObj(symInfo->getObjSym(val));
101
- }
102
-
103
98
  public:
104
99
  IRGraph(bool buildFromFile)
105
100
  : fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0)
@@ -174,14 +169,6 @@ public:
174
169
  {
175
170
  return symInfo->nullPtrSymID();
176
171
  }
177
- inline const MemObj* getBlackHoleObj() const
178
- {
179
- return symInfo->getBlkObj();
180
- }
181
- inline const MemObj* getConstantObj() const
182
- {
183
- return symInfo->getConstantObj();
184
- }
185
172
 
186
173
  inline u32_t getValueNodeNum() const
187
174
  {
@@ -189,7 +176,7 @@ public:
189
176
  }
190
177
  inline u32_t getObjectNodeNum() const
191
178
  {
192
- return symInfo->idToObjMap().size();
179
+ return symInfo->idToObjTypeInfoMap().size();
193
180
  }
194
181
  inline u32_t getNodeNumAfterPAGBuild() const
195
182
  {
@@ -309,9 +309,9 @@ public:
309
309
 
310
310
  inline bool isArrayMemObj(NodeID id) const
311
311
  {
312
- const MemObj* mem = pag->getObject(id);
313
- assert(mem && "memory object is null??");
314
- return mem->isArray();
312
+ const BaseObjVar* obj = pag->getBaseObject(id);
313
+ assert(obj && "base object is null??");
314
+ return obj->isArray();
315
315
  }
316
316
  //@}
317
317
 
@@ -339,13 +339,13 @@ public:
339
339
  }
340
340
  inline void setObjFieldInsensitive(NodeID id)
341
341
  {
342
- MemObj* mem = const_cast<MemObj*>(pag->getBaseObj(id));
343
- mem->setFieldInsensitive();
342
+ BaseObjVar* baseObj = const_cast<BaseObjVar*>(pag->getBaseObject(id));
343
+ baseObj->setFieldInsensitive();
344
344
  }
345
345
  inline bool isFieldInsensitive(NodeID id) const
346
346
  {
347
- const MemObj* mem = pag->getBaseObj(id);
348
- return mem->isFieldInsensitive();
347
+ const BaseObjVar* baseObj = pag->getBaseObject(id);
348
+ return baseObj->isFieldInsensitive();
349
349
  }
350
350
  ///@}
351
351
 
@@ -118,9 +118,9 @@ protected:
118
118
  ///Get a reference to StructInfo.
119
119
  StInfo* getOrAddSVFTypeInfo(const Type* T);
120
120
 
121
- MemObj* createBlkObj(SymID symId);
121
+ ObjTypeInfo* createBlkObjTypeInfo(SymID symId);
122
122
 
123
- MemObj* createConstantObj(SymID symId);
123
+ ObjTypeInfo* createConstantObjTypeInfo(SymID symId);
124
124
  };
125
125
 
126
126
  } // End namespace SVF
@@ -129,8 +129,6 @@ class SVFMetadataAsValue;
129
129
 
130
130
  class SVFLoopAndDomInfo; // Part of SVFFunction
131
131
 
132
- // Classes created upon buildSymbolTableInfo
133
- class MemObj;
134
132
 
135
133
  // Classes created upon ICFG construction
136
134
  class ICFGNode;
@@ -422,7 +420,6 @@ private:
422
420
 
423
421
  cJSON* toJson(const AccessPath& ap);
424
422
  cJSON* toJson(const SVFLoop* loop);
425
- cJSON* toJson(const MemObj* memObj);
426
423
  cJSON* toJson(const ObjTypeInfo* objTypeInfo); // Only owned by MemObj
427
424
  cJSON* toJson(const SVFLoopAndDomInfo* ldInfo); // Only owned by SVFFunction
428
425
  cJSON* toJson(const StInfo* stInfo);
@@ -528,7 +525,6 @@ private:
528
525
 
529
526
  // Other classes
530
527
  cJSON* contentToJson(const SVFLoop* loop);
531
- cJSON* contentToJson(const MemObj* memObj); // Owned by SymbolTable->objMap
532
528
  cJSON* contentToJson(const StInfo* stInfo);
533
529
  ///@}
534
530
 
@@ -899,13 +895,8 @@ class SymbolTableInfoReader
899
895
 
900
896
  private:
901
897
  const cJSON* symTabFieldJson = nullptr;
902
- ReaderIDToObjMap<MemObj> memObjMap;
903
898
 
904
899
  public:
905
- inline MemObj* getMemObjPtr(unsigned id) const
906
- {
907
- return memObjMap.getPtr(id);
908
- }
909
900
 
910
901
  template <typename MemObjCreator>
911
902
  void createObjs(const cJSON* symTabJson, MemObjCreator memObjCreator)
@@ -915,7 +906,6 @@ public:
915
906
 
916
907
  const cJSON* const allMemObj = symTabJson->child;
917
908
  CHECK_JSON_KEY(allMemObj);
918
- memObjMap.createObjs(allMemObj, memObjCreator);
919
909
 
920
910
  symTabFieldJson = allMemObj->next;
921
911
  }
@@ -1104,7 +1094,6 @@ private:
1104
1094
 
1105
1095
  void readJson(const cJSON* obj, AccessPath& ap);
1106
1096
  void readJson(const cJSON* obj, SVFLoop*& loop);
1107
- void readJson(const cJSON* obj, MemObj*& memObj);
1108
1097
  void readJson(const cJSON* obj,
1109
1098
  ObjTypeInfo*& objTypeInfo); // Only owned by MemObj
1110
1099
  void readJson(const cJSON* obj,
@@ -1257,7 +1246,6 @@ private:
1257
1246
  void fill(const cJSON*& fieldJson, TDForkPE* stmt);
1258
1247
  void fill(const cJSON*& fieldJson, TDJoinPE* stmt);
1259
1248
 
1260
- void fill(const cJSON*& fieldJson, MemObj* memObj);
1261
1249
  void fill(const cJSON*& fieldJson, StInfo* stInfo);
1262
1250
  // ICFG
1263
1251
  void virtFill(const cJSON*& fieldJson, ICFGNode* node);