svf-tools 1.0.312 → 1.0.313

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 (120) hide show
  1. package/SVF-doxygen/html/html/AndersenSFR_8cpp_source.html +2 -2
  2. package/SVF-doxygen/html/html/CHG_8cpp_source.html +1 -1
  3. package/SVF-doxygen/html/html/ConsG_8h_source.html +2 -2
  4. package/SVF-doxygen/html/html/ContextDDA_8cpp_source.html +3 -3
  5. package/SVF-doxygen/html/html/DDAVFSolver_8h_source.html +6 -6
  6. package/SVF-doxygen/html/html/FlowDDA_8cpp_source.html +2 -2
  7. package/SVF-doxygen/html/html/FlowSensitiveStat_8cpp_source.html +3 -3
  8. package/SVF-doxygen/html/html/LocationSet_8h_source.html +1 -2
  9. package/SVF-doxygen/html/html/MemModel_8cpp_source.html +8 -52
  10. package/SVF-doxygen/html/html/MemModel_8h_source.html +44 -44
  11. package/SVF-doxygen/html/html/MemRegion_8cpp_source.html +6 -6
  12. package/SVF-doxygen/html/html/Options_8cpp_source.html +1 -2
  13. package/SVF-doxygen/html/html/Options_8h_source.html +2 -2
  14. package/SVF-doxygen/html/html/PAGBuilderFromFile_8cpp_source.html +1 -1
  15. package/SVF-doxygen/html/html/PAGBuilder_8cpp_source.html +1 -1
  16. package/SVF-doxygen/html/html/PAGNode_8h_source.html +4 -4
  17. package/SVF-doxygen/html/html/PAG_8cpp_source.html +6 -6
  18. package/SVF-doxygen/html/html/PAG_8h_source.html +4 -4
  19. package/SVF-doxygen/html/html/PTAStat_8cpp_source.html +15 -15
  20. package/SVF-doxygen/html/html/PointerAnalysisImpl_8cpp_source.html +2 -2
  21. package/SVF-doxygen/html/html/PointerAnalysis_8cpp_source.html +6 -6
  22. package/SVF-doxygen/html/html/PointerAnalysis_8h_source.html +5 -5
  23. package/SVF-doxygen/html/html/SVFModule_8cpp_source.html +2 -2
  24. package/SVF-doxygen/html/html/SaberSVFGBuilder_8cpp_source.html +1 -1
  25. package/SVF-doxygen/html/html/SymbolTableInfo_8cpp_source.html +12 -5
  26. package/SVF-doxygen/html/html/SymbolTableInfo_8h.html +0 -4
  27. package/SVF-doxygen/html/html/SymbolTableInfo_8h_source.html +35 -37
  28. package/SVF-doxygen/html/html/ThreadCallGraph_8cpp_source.html +3 -3
  29. package/SVF-doxygen/html/html/TypeBasedHeapCloning_8cpp_source.html +3 -3
  30. package/SVF-doxygen/html/html/TypeBasedHeapCloning_8h_source.html +1 -1
  31. package/SVF-doxygen/html/html/VersionedFlowSensitiveStat_8cpp_source.html +3 -3
  32. package/SVF-doxygen/html/html/annotated.html +134 -136
  33. package/SVF-doxygen/html/html/classSVF_1_1AndersenSFR.html +2 -2
  34. package/SVF-doxygen/html/html/classSVF_1_1BVDataPTAImpl.html +2 -2
  35. package/SVF-doxygen/html/html/classSVF_1_1CHGraph.html +1 -1
  36. package/SVF-doxygen/html/html/classSVF_1_1ContextDDA.html +3 -3
  37. package/SVF-doxygen/html/html/classSVF_1_1DDAVFSolver.html +1 -1
  38. package/SVF-doxygen/html/html/classSVF_1_1FlowDDA.html +2 -2
  39. package/SVF-doxygen/html/html/classSVF_1_1FlowSensitive.html +1 -1
  40. package/SVF-doxygen/html/html/classSVF_1_1FlowSensitiveStat.html +3 -3
  41. package/SVF-doxygen/html/html/classSVF_1_1GepObjPN.html +3 -3
  42. package/SVF-doxygen/html/html/classSVF_1_1LocationSet.html +1 -1
  43. package/SVF-doxygen/html/html/classSVF_1_1MRGenerator.html +7 -7
  44. package/SVF-doxygen/html/html/classSVF_1_1MemObj-members.html +7 -10
  45. package/SVF-doxygen/html/html/classSVF_1_1MemObj.html +92 -199
  46. package/SVF-doxygen/html/html/classSVF_1_1ObjPN.html +1 -1
  47. package/SVF-doxygen/html/html/classSVF_1_1ObjTypeInfo-members.html +8 -10
  48. package/SVF-doxygen/html/html/classSVF_1_1ObjTypeInfo.html +67 -167
  49. package/SVF-doxygen/html/html/classSVF_1_1Options-members.html +1 -1
  50. package/SVF-doxygen/html/html/classSVF_1_1Options.html +5 -5
  51. package/SVF-doxygen/html/html/classSVF_1_1PAG.html +12 -12
  52. package/SVF-doxygen/html/html/classSVF_1_1PAGBuilder.html +9 -9
  53. package/SVF-doxygen/html/html/classSVF_1_1PAGBuilderFromFile.html +1 -1
  54. package/SVF-doxygen/html/html/classSVF_1_1PTAStat.html +16 -16
  55. package/SVF-doxygen/html/html/classSVF_1_1PointerAnalysis.html +9 -9
  56. package/SVF-doxygen/html/html/classSVF_1_1SVFModule.html +2 -2
  57. package/SVF-doxygen/html/html/classSVF_1_1SaberSVFGBuilder.html +1 -1
  58. package/SVF-doxygen/html/html/classSVF_1_1SymbolTableInfo-members.html +78 -73
  59. package/SVF-doxygen/html/html/classSVF_1_1SymbolTableInfo.html +343 -119
  60. package/SVF-doxygen/html/html/classSVF_1_1ThreadCallGraph.html +3 -3
  61. package/SVF-doxygen/html/html/classSVF_1_1TypeBasedHeapCloning.html +4 -4
  62. package/SVF-doxygen/html/html/classSVF_1_1VersionedFlowSensitiveStat.html +3 -3
  63. package/SVF-doxygen/html/html/classes.html +90 -90
  64. package/SVF-doxygen/html/html/functions_0x7e.html +0 -6
  65. package/SVF-doxygen/html/html/functions_a.html +13 -10
  66. package/SVF-doxygen/html/html/functions_c.html +26 -24
  67. package/SVF-doxygen/html/html/functions_func.html +12 -9
  68. package/SVF-doxygen/html/html/functions_func_0x7e.html +0 -6
  69. package/SVF-doxygen/html/html/functions_func_c.html +13 -13
  70. package/SVF-doxygen/html/html/functions_func_g.html +11 -13
  71. package/SVF-doxygen/html/html/functions_func_i.html +8 -7
  72. package/SVF-doxygen/html/html/functions_func_l.html +2 -8
  73. package/SVF-doxygen/html/html/functions_func_m.html +1 -1
  74. package/SVF-doxygen/html/html/functions_func_v.html +0 -3
  75. package/SVF-doxygen/html/html/functions_g.html +6 -8
  76. package/SVF-doxygen/html/html/functions_i.html +10 -9
  77. package/SVF-doxygen/html/html/functions_l.html +1 -5
  78. package/SVF-doxygen/html/html/functions_m.html +1 -1
  79. package/SVF-doxygen/html/html/functions_o.html +3 -3
  80. package/SVF-doxygen/html/html/functions_p.html +3 -3
  81. package/SVF-doxygen/html/html/functions_s.html +6 -4
  82. package/SVF-doxygen/html/html/functions_t.html +7 -7
  83. package/SVF-doxygen/html/html/functions_u.html +3 -3
  84. package/SVF-doxygen/html/html/functions_v.html +5 -8
  85. package/SVF-doxygen/html/html/functions_vars_l.html +1 -1
  86. package/SVF-doxygen/html/html/hierarchy.html +2 -4
  87. package/SVF-doxygen/html/html/namespaceSVF.html +0 -4
  88. package/SVF-doxygen/html/html/search/all_1.js +3 -2
  89. package/SVF-doxygen/html/html/search/all_10.js +2 -2
  90. package/SVF-doxygen/html/html/search/all_13.js +6 -6
  91. package/SVF-doxygen/html/html/search/all_14.js +5 -5
  92. package/SVF-doxygen/html/html/search/all_15.js +1 -1
  93. package/SVF-doxygen/html/html/search/all_16.js +2 -3
  94. package/SVF-doxygen/html/html/search/all_1b.js +0 -2
  95. package/SVF-doxygen/html/html/search/all_3.js +4 -3
  96. package/SVF-doxygen/html/html/search/all_7.js +2 -2
  97. package/SVF-doxygen/html/html/search/all_9.js +2 -1
  98. package/SVF-doxygen/html/html/search/all_c.js +2 -3
  99. package/SVF-doxygen/html/html/search/all_d.js +2 -2
  100. package/SVF-doxygen/html/html/search/all_e.js +1 -1
  101. package/SVF-doxygen/html/html/search/all_f.js +1 -1
  102. package/SVF-doxygen/html/html/search/classes_9.js +1 -3
  103. package/SVF-doxygen/html/html/search/functions_0.js +3 -2
  104. package/SVF-doxygen/html/html/search/functions_13.js +0 -1
  105. package/SVF-doxygen/html/html/search/functions_16.js +0 -2
  106. package/SVF-doxygen/html/html/search/functions_2.js +4 -3
  107. package/SVF-doxygen/html/html/search/functions_6.js +2 -2
  108. package/SVF-doxygen/html/html/search/functions_8.js +2 -1
  109. package/SVF-doxygen/html/html/search/functions_a.js +1 -3
  110. package/SVF-doxygen/html/html/search/functions_b.js +1 -1
  111. package/SVF-doxygen/html/html/search/variables_14.js +2 -2
  112. package/SVF-doxygen/html/html/search/variables_c.js +1 -1
  113. package/SVF-doxygen/html/html/search/variables_d.js +1 -1
  114. package/SVF-doxygen/html/html/search/variables_e.js +1 -1
  115. package/include/MemoryModel/MemModel.h +5 -21
  116. package/include/SVF-FE/SymbolTableInfo.h +14 -56
  117. package/lib/MemoryModel/MemModel.cpp +10 -436
  118. package/lib/SVF-FE/SymbolTableInfo.cpp +136 -12
  119. package/lib/Util/Options.cpp +0 -8
  120. package/package.json +1 -1
@@ -42,135 +42,27 @@ using namespace SVFUtil;
42
42
 
43
43
  u32_t StInfo::maxFieldLimit = 0;
44
44
 
45
- /*!
46
- * Analyse types of all flattened fields of this object
47
- */
48
- void ObjTypeInfo::analyzeGlobalStackObjType(const Value* val)
49
- {
50
-
51
- const PointerType * refty = SVFUtil::dyn_cast<PointerType>(val->getType());
52
- assert(SVFUtil::isa<PointerType>(refty) && "this value should be a pointer type!");
53
- Type* elemTy = refty->getElementType();
54
- bool isPtrObj = false;
55
- // Find the inter nested array element
56
- while (const ArrayType *AT= SVFUtil::dyn_cast<ArrayType>(elemTy))
57
- {
58
- elemTy = AT->getElementType();
59
- if(elemTy->isPointerTy())
60
- isPtrObj = true;
61
- if(SVFUtil::isa<GlobalVariable>(val) && SVFUtil::cast<GlobalVariable>(val)->hasInitializer()
62
- && SVFUtil::isa<ConstantArray>(SVFUtil::cast<GlobalVariable>(val)->getInitializer()))
63
- {
64
- setFlag(CONST_ARRAY_OBJ);
65
- }
66
- else
67
- setFlag(VAR_ARRAY_OBJ);
68
- }
69
- if (const StructType *ST= SVFUtil::dyn_cast<StructType>(elemTy))
70
- {
71
- const std::vector<FieldInfo>& flattenFields = SymbolTableInfo::SymbolInfo()->getFlattenFieldInfoVec(ST);
72
- for(std::vector<FieldInfo>::const_iterator it = flattenFields.begin(), eit = flattenFields.end();
73
- it!=eit; ++it)
74
- {
75
- if((*it).getFlattenElemTy()->isPointerTy())
76
- isPtrObj = true;
77
- }
78
- if(SVFUtil::isa<GlobalVariable>(val) && SVFUtil::cast<GlobalVariable>(val)->hasInitializer()
79
- && SVFUtil::isa<ConstantStruct>(SVFUtil::cast<GlobalVariable>(val)->getInitializer()))
80
- setFlag(CONST_STRUCT_OBJ);
81
- else
82
- setFlag(VAR_STRUCT_OBJ);
83
- }
84
- else if (elemTy->isPointerTy())
85
- {
86
- isPtrObj = true;
87
- }
88
-
89
- if(isPtrObj)
90
- setFlag(HASPTR_OBJ);
91
- }
92
45
 
93
46
  /*!
94
47
  * Analyse types of heap and static objects
95
48
  */
96
- void ObjTypeInfo::analyzeHeapStaticObjType(const Value*)
49
+ void ObjTypeInfo::analyzeHeapObjType(const Type*)
97
50
  {
98
51
  // TODO: Heap and static objects are considered as pointers right now.
99
52
  // Refine this function to get more details about heap and static objects.
53
+ setFlag(HEAP_OBJ);
100
54
  setFlag(HASPTR_OBJ);
101
55
  }
102
56
 
103
57
  /*!
104
- * Return size of this Object
105
- */
106
- u32_t ObjTypeInfo::getObjSize(const Value* val)
107
- {
108
-
109
- Type* ety = SVFUtil::cast<PointerType>(val->getType())->getElementType();
110
- u32_t numOfFields = 1;
111
- if (SVFUtil::isa<StructType>(ety) || SVFUtil::isa<ArrayType>(ety))
112
- {
113
- numOfFields = SymbolTableInfo::SymbolInfo()->getFlattenFieldInfoVec(ety).size();
114
- }
115
- return numOfFields;
116
- }
117
-
118
- /*!
119
- * Initialize the type info of an object
58
+ * Analyse types of heap and static objects
120
59
  */
121
- void ObjTypeInfo::init(const Value* val)
60
+ void ObjTypeInfo::analyzeStaticObjType(const Type*)
122
61
  {
123
-
124
- Size_t objSize = 1;
125
- // Global variable
126
- if (SVFUtil::isa<Function>(val))
127
- {
128
- setFlag(FUNCTION_OBJ);
129
- analyzeGlobalStackObjType(val);
130
- objSize = getObjSize(val);
131
- }
132
- else if(SVFUtil::isa<AllocaInst>(val))
133
- {
134
- setFlag(STACK_OBJ);
135
- analyzeGlobalStackObjType(val);
136
- objSize = getObjSize(val);
137
- }
138
- else if(SVFUtil::isa<GlobalVariable>(val))
139
- {
140
- setFlag(GLOBVAR_OBJ);
141
- if(SymbolTableInfo::SymbolInfo()->isConstantObjSym(val))
142
- setFlag(CONST_OBJ);
143
- analyzeGlobalStackObjType(val);
144
- objSize = getObjSize(val);
145
- }
146
- else if (SVFUtil::isa<Instruction>(val) && isHeapAllocExtCall(SVFUtil::cast<Instruction>(val)))
147
- {
148
- setFlag(HEAP_OBJ);
149
- analyzeHeapStaticObjType(val);
150
- // Heap object, label its field as infinite here
151
- objSize = -1;
152
- }
153
- else if (SVFUtil::isa<Instruction>(val) && isStaticExtCall(SVFUtil::cast<Instruction>(val)))
154
- {
155
- setFlag(STATIC_OBJ);
156
- analyzeHeapStaticObjType(val);
157
- // static object allocated before main, label its field as infinite here
158
- objSize = -1;
159
- }
160
- else if(ArgInProgEntryFunction(val))
161
- {
162
- setFlag(STATIC_OBJ);
163
- analyzeHeapStaticObjType(val);
164
- // user input data, label its field as infinite here
165
- objSize = -1;
166
- }
167
- else
168
- assert("what other object do we have??");
169
-
170
- // Reset maxOffsetLimit if it is over the total fieldNum of this object
171
- if(objSize > 0 && maxOffsetLimit > objSize)
172
- maxOffsetLimit = objSize;
173
-
62
+ // TODO: Heap and static objects are considered as pointers right now.
63
+ // Refine this function to get more details about heap and static objects.
64
+ setFlag(STATIC_OBJ);
65
+ setFlag(HASPTR_OBJ);
174
66
  }
175
67
 
176
68
  /*!
@@ -237,32 +129,14 @@ void MemObj::setFieldSensitive()
237
129
  {
238
130
  typeInfo->setMaxFieldOffsetLimit(StInfo::getMaxFieldLimit());
239
131
  }
240
- /*
241
- * Initial the memory object here
242
- */
243
- void MemObj::init(const Type* type)
244
- {
245
- typeInfo = new ObjTypeInfo(StInfo::getMaxFieldLimit(),type);
246
- typeInfo->setFlag(ObjTypeInfo::HEAP_OBJ);
247
- typeInfo->setFlag(ObjTypeInfo::HASPTR_OBJ);
248
- }
249
132
 
250
- /*!
251
- * Constructor of a memory object
252
- */
253
- MemObj::MemObj(const Value *val, SymID id) :
254
- refVal(val), GSymID(id), typeInfo(nullptr)
255
- {
256
- init(val);
257
- }
258
133
 
259
134
  /*!
260
135
  * Constructor of a memory object
261
136
  */
262
- MemObj::MemObj(SymID id, const Type* type) :
263
- refVal(nullptr), GSymID(id), typeInfo(nullptr)
137
+ MemObj::MemObj(SymID id, ObjTypeInfo* ti, const Value *val) :
138
+ refVal(val), GSymID(id), typeInfo(ti)
264
139
  {
265
- init(type);
266
140
  }
267
141
 
268
142
  /*!
@@ -299,303 +173,3 @@ void MemObj::destroy()
299
173
  }
300
174
 
301
175
 
302
- /*!
303
- * Compute gep offset
304
- */
305
- bool LocSymTableInfo::computeGepOffset(const User *V, LocationSet& ls)
306
- {
307
-
308
- assert(V);
309
- int baseIndex = -1;
310
- int index = 0;
311
- for (bridge_gep_iterator gi = bridge_gep_begin(*V), ge = bridge_gep_end(*V);
312
- gi != ge; ++gi, ++index)
313
- {
314
- if(SVFUtil::isa<ConstantInt>(gi.getOperand()) == false)
315
- baseIndex = index;
316
- }
317
-
318
- index = 0;
319
- for (bridge_gep_iterator gi = bridge_gep_begin(*V), ge = bridge_gep_end(*V);
320
- gi != ge; ++gi, ++index)
321
- {
322
-
323
- if (index <= baseIndex)
324
- {
325
- /// variant offset
326
- // Handling pointer types
327
- if (const PointerType* pty = SVFUtil::dyn_cast<PointerType>(*gi))
328
- {
329
- const Type* et = pty->getElementType();
330
- Size_t sz = getTypeSizeInBytes(et);
331
-
332
- Size_t num = 1;
333
- if (const ArrayType* aty = SVFUtil::dyn_cast<ArrayType>(et))
334
- num = aty->getNumElements();
335
- else
336
- num = StInfo::getMaxFieldLimit();
337
-
338
- ls.addElemNumStridePair(std::make_pair(num, sz));
339
- }
340
- // Calculate the size of the array element
341
- else if(const ArrayType* at = SVFUtil::dyn_cast<ArrayType>(*gi))
342
- {
343
- const Type* et = at->getElementType();
344
- Size_t sz = getTypeSizeInBytes(et);
345
- Size_t num = at->getNumElements();
346
- ls.addElemNumStridePair(std::make_pair(num, sz));
347
- }
348
- else
349
- assert(false && "what other types?");
350
- }
351
- // constant offset
352
- else
353
- {
354
- assert(SVFUtil::isa<ConstantInt>(gi.getOperand()) && "expecting a constant");
355
-
356
- ConstantInt *op = SVFUtil::cast<ConstantInt>(gi.getOperand());
357
-
358
- //The actual index
359
- Size_t idx = op->getSExtValue();
360
-
361
- // Handling pointer types
362
- // These GEP instructions are simply making address computations from the base pointer address
363
- // e.g. idx1 = (char*) &MyVar + 4, at this case gep only one offset index (idx)
364
- if (const PointerType* pty = SVFUtil::dyn_cast<PointerType>(*gi))
365
- {
366
- const Type* et = pty->getElementType();
367
- Size_t sz = getTypeSizeInBytes(et);
368
- ls.setByteOffset(ls.getByteOffset() + idx * sz);
369
- }
370
- // Calculate the size of the array element
371
- else if(const ArrayType* at = SVFUtil::dyn_cast<ArrayType>(*gi))
372
- {
373
- const Type* et = at->getElementType();
374
- Size_t sz = getTypeSizeInBytes(et);
375
- ls.setByteOffset(ls.getByteOffset() + idx * sz);
376
- }
377
- // Handling struct here
378
- else if (const StructType *ST = SVFUtil::dyn_cast<StructType>(*gi))
379
- {
380
- assert(op && "non-const struct index in GEP");
381
- const vector<u32_t> &so = SymbolTableInfo::SymbolInfo()->getFattenFieldOffsetVec(ST);
382
- if ((unsigned)idx >= so.size())
383
- {
384
- outs() << "!! Struct index out of bounds" << idx << "\n";
385
- assert(0);
386
- }
387
- //add the translated offset
388
- ls.setByteOffset(ls.getByteOffset() + so[idx]);
389
- }
390
- else
391
- assert(false && "what other types?");
392
- }
393
- }
394
- return true;
395
- }
396
-
397
- /*!
398
- * Collect array information
399
- */
400
- void LocSymTableInfo::collectArrayInfo(const llvm::ArrayType*)
401
- {
402
- /*
403
- StInfo *stinfo = new StInfo();
404
- typeToFieldInfo[ty] = stinfo;
405
-
406
- /// If this is an array type, calculate the outmost array
407
- /// information and append them to the inner elements' type
408
- /// information later.
409
- u64_t out_num = ty->getNumElements();
410
- const Type* elemTy = ty->getElementType();
411
- u32_t out_stride = getTypeSizeInBytes(elemTy);
412
-
413
- /// Array itself only has one field which is the inner most element
414
- stinfo->addOffsetWithType(0, elemTy);
415
-
416
- while (const ArrayType* aty = dyn_cast<ArrayType>(elemTy)) {
417
- out_num *= aty->getNumElements();
418
- elemTy = aty->getElementType();
419
- out_stride = getTypeSizeInBytes(elemTy);
420
- }
421
-
422
- /// Array's flatten field infor is the same as its element's
423
- /// flatten infor with an additional slot for array's element
424
- /// number and stride pair.
425
- StInfo* elemStInfo = getStructInfo(elemTy);
426
- u32_t nfE = elemStInfo->getFlattenFieldInfoVec().size();
427
- for (u32_t j = 0; j < nfE; j++) {
428
- u32_t off = elemStInfo->getFlattenFieldInfoVec()[j].getFlattenOffset();
429
- const Type* fieldTy = elemStInfo->getFlattenFieldInfoVec()[j].getFlattenElemTy();
430
- FieldInfo::ElemNumStridePairVec pair = elemStInfo->getFlattenFieldInfoVec()[j].getElemNumStridePairVect();
431
- /// append the additional number
432
- pair.push_back(std::make_pair(out_num, out_stride));
433
- FieldInfo field(off, fieldTy, pair);
434
- stinfo->getFlattenFieldInfoVec().push_back(field);
435
- }
436
- */
437
- }
438
-
439
-
440
- /*
441
- * Recursively collect the memory layout information for a struct type
442
- */
443
- void LocSymTableInfo::collectStructInfo(const StructType*)
444
- {
445
- /*
446
- StInfo *stinfo = new StInfo();
447
- typeToFieldInfo[ty] = stinfo;
448
-
449
- const StructLayout *stTySL = getDataLayout(getModule().getMainLLVMModule())->getStructLayout( const_cast<StructType *>(ty) );
450
-
451
- u32_t field_idx = 0;
452
- for (StructType::element_iterator it = ty->element_begin(), ie =
453
- ty->element_end(); it != ie; ++it, ++field_idx) {
454
- const Type *et = *it;
455
-
456
- // The offset is where this element will be placed in the struct.
457
- // This offset is computed after alignment with the current struct
458
- u64_t eOffsetInBytes = stTySL->getElementOffset(field_idx);
459
-
460
- //The offset is where this element will be placed in the exp. struct.
461
- /// FIXME: As the layout size is uint_64, here we assume
462
- /// offset with uint_32 (Size_t) is large enough and will not cause overflow
463
- stinfo->addOffsetWithType(static_cast<u32_t>(eOffsetInBytes), et);
464
-
465
- StInfo* fieldStinfo = getStructInfo(et);
466
- u32_t nfE = fieldStinfo->getFlattenFieldInfoVec().size();
467
- //Copy ST's info, whose element 0 is the size of ST itself.
468
- for (u32_t j = 0; j < nfE; j++) {
469
- u32_t oft = eOffsetInBytes + fieldStinfo->getFlattenFieldInfoVec()[j].getFlattenOffset();
470
- const Type* elemTy = fieldStinfo->getFlattenFieldInfoVec()[j].getFlattenElemTy();
471
- FieldInfo::ElemNumStridePairVec pair = fieldStinfo->getFlattenFieldInfoVec()[j].getElemNumStridePairVect();
472
- pair.push_back(std::make_pair(1, 0));
473
- FieldInfo newField(oft, elemTy, pair);
474
- stinfo->getFlattenFieldInfoVec().push_back(newField);
475
- }
476
- }
477
-
478
- // verifyStructSize(stinfo,stTySL->getSizeInBytes());
479
-
480
- //Record the size of the complete struct and update max_struct.
481
- if (stTySL->getSizeInBytes() > maxStSize) {
482
- maxStruct = ty;
483
- maxStSize = stTySL->getSizeInBytes();
484
- }
485
- */
486
- }
487
-
488
-
489
- /*!
490
- * Given LocationSet from a Gep Instruction, return a new LocationSet which matches
491
- * the field information of this ObjTypeInfo by considering memory layout
492
- */
493
- LocationSet LocSymTableInfo::getModulusOffset(const MemObj* obj, const LocationSet& ls)
494
- {
495
- const Type* ety = obj->getType();
496
-
497
- if (SVFUtil::isa<StructType>(ety) || SVFUtil::isa<ArrayType>(ety))
498
- {
499
- /// Find an appropriate field for this LocationSet
500
- const std::vector<FieldInfo>& infovec = SymbolTableInfo::SymbolInfo()->getFlattenFieldInfoVec(ety);
501
- std::vector<FieldInfo>::const_iterator it = infovec.begin();
502
- std::vector<FieldInfo>::const_iterator eit = infovec.end();
503
- for (; it != eit; ++it)
504
- {
505
- const FieldInfo& fieldLS = *it;
506
- LocationSet rhsLS(fieldLS);
507
- LocationSet::LSRelation result = LocationSet::checkRelation(ls, rhsLS);
508
- if (result == LocationSet::Same ||
509
- result == LocationSet::Superset ||
510
- result == LocationSet::Subset)
511
- return ls;
512
- else if (result == LocationSet::Overlap)
513
- {
514
- // TODO:
515
- return ls;
516
- }
517
- else if (result == LocationSet::NonOverlap)
518
- {
519
- continue;
520
- }
521
-
522
- assert(false && "cannot find an appropriate field for specified LocationSet");
523
- return ls;
524
- }
525
- }
526
- else
527
- {
528
- if (obj->isStaticObj() || obj->isHeap())
529
- {
530
- // TODO: Objects which cannot find proper field for a certain offset including
531
- // arguments in main(), static objects allocated before main and heap
532
- // objects. Right now they're considered to have infinite fields. So we
533
- // just return the location set without modifying it.
534
- return ls;
535
- }
536
- else
537
- {
538
- // TODO: Using new memory model (locMM) may create objects with spurious offset
539
- // as we simply return new offset by mod operation without checking its
540
- // correctness in LocSymTableInfo::getModulusOffset(). So the following
541
- // assertion may fail. Try to refine the new memory model.
542
- assert(ls.isConstantOffset() && "expecting a constant location set");
543
- return ls;
544
- }
545
- }
546
-
547
- /// This location set represent one object
548
- if (ls.isConstantOffset())
549
- {
550
- /// if the offset is negative, it's possible that we're looking for an obj node out of range
551
- /// of current struct. Make the offset positive so we can still get a node within current
552
- /// struct to represent this obj.
553
- Size_t offset = ls.getOffset();
554
- if(offset < 0)
555
- {
556
- writeWrnMsg("try to create a gep node with negative offset.");
557
- offset = abs(offset);
558
- }
559
- u32_t maxOffset = obj->getMaxFieldOffsetLimit();
560
- if (maxOffset != 0)
561
- offset = offset % maxOffset;
562
- else
563
- offset = 0;
564
- }
565
- /// This location set represents multiple objects
566
- else
567
- {
568
-
569
- }
570
-
571
- return ls;
572
- }
573
-
574
- /*!
575
- * Verify struct size
576
- */
577
- void LocSymTableInfo::verifyStructSize(StInfo *stinfo, u32_t structSize)
578
- {
579
-
580
- u32_t lastOff = stinfo->getFlattenFieldInfoVec().back().getFlattenByteOffset();
581
- u32_t strideSize = 0;
582
- FieldInfo::ElemNumStridePairVec::const_iterator pit = stinfo->getFlattenFieldInfoVec().back().elemStridePairBegin();
583
- FieldInfo::ElemNumStridePairVec::const_iterator epit = stinfo->getFlattenFieldInfoVec().back().elemStridePairEnd();
584
- for(; pit!=epit; ++pit)
585
- strideSize += pit->first * pit->second;
586
-
587
- u32_t lastSize = getTypeSizeInBytes(stinfo->getFlattenFieldInfoVec().back().getFlattenElemTy());
588
- /// Please note this verify may not be complete as different machine has different alignment mechanism
589
- assert((structSize == lastOff + strideSize + lastSize) && "struct size not consistent");
590
-
591
- }
592
-
593
- /*!
594
- * Get the size of this object
595
- */
596
- u32_t LocObjTypeInfo::getObjSize(const Value* val)
597
- {
598
-
599
- Type* ety = SVFUtil::cast<PointerType>(val->getType())->getElementType();
600
- return LocSymTableInfo::SymbolInfo()->getTypeSizeInBytes(ety);
601
- }
@@ -47,10 +47,127 @@ using namespace SVFUtil;
47
47
  DataLayout* SymbolTableInfo::dl = nullptr;
48
48
  SymbolTableInfo* SymbolTableInfo::symInfo = nullptr;
49
49
 
50
+
51
+ /*!
52
+ * Analyse types of all flattened fields of this object
53
+ */
54
+ void SymbolTableInfo::analyzeGlobalStackObjType(ObjTypeInfo* typeinfo, const Value* val)
55
+ {
56
+
57
+ const PointerType * refty = SVFUtil::dyn_cast<PointerType>(val->getType());
58
+ assert(SVFUtil::isa<PointerType>(refty) && "this value should be a pointer type!");
59
+ Type* elemTy = refty->getElementType();
60
+ bool isPtrObj = false;
61
+ // Find the inter nested array element
62
+ while (const ArrayType *AT= SVFUtil::dyn_cast<ArrayType>(elemTy))
63
+ {
64
+ elemTy = AT->getElementType();
65
+ if(elemTy->isPointerTy())
66
+ isPtrObj = true;
67
+ if(SVFUtil::isa<GlobalVariable>(val) && SVFUtil::cast<GlobalVariable>(val)->hasInitializer()
68
+ && SVFUtil::isa<ConstantArray>(SVFUtil::cast<GlobalVariable>(val)->getInitializer()))
69
+ {
70
+ typeinfo->setFlag(ObjTypeInfo::CONST_ARRAY_OBJ);
71
+ }
72
+ else
73
+ typeinfo->setFlag(ObjTypeInfo::VAR_ARRAY_OBJ);
74
+ }
75
+ if (const StructType *ST= SVFUtil::dyn_cast<StructType>(elemTy))
76
+ {
77
+ const std::vector<FieldInfo>& flattenFields = SymbolTableInfo::SymbolInfo()->getFlattenFieldInfoVec(ST);
78
+ for(std::vector<FieldInfo>::const_iterator it = flattenFields.begin(), eit = flattenFields.end();
79
+ it!=eit; ++it)
80
+ {
81
+ if((*it).getFlattenElemTy()->isPointerTy())
82
+ isPtrObj = true;
83
+ }
84
+ if(SVFUtil::isa<GlobalVariable>(val) && SVFUtil::cast<GlobalVariable>(val)->hasInitializer()
85
+ && SVFUtil::isa<ConstantStruct>(SVFUtil::cast<GlobalVariable>(val)->getInitializer()))
86
+ typeinfo->setFlag(ObjTypeInfo::CONST_STRUCT_OBJ);
87
+ else
88
+ typeinfo->setFlag(ObjTypeInfo::VAR_STRUCT_OBJ);
89
+ }
90
+ else if (elemTy->isPointerTy())
91
+ {
92
+ isPtrObj = true;
93
+ }
94
+
95
+ if(isPtrObj)
96
+ typeinfo->setFlag(ObjTypeInfo::HASPTR_OBJ);
97
+ }
98
+
99
+ /*!
100
+ * Initialize the type info of an object
101
+ */
102
+ void SymbolTableInfo::initTypeInfo(ObjTypeInfo* typeinfo, const Value* val){
103
+
104
+ Size_t objSize = 1;
105
+ // Global variable
106
+ if (SVFUtil::isa<Function>(val))
107
+ {
108
+ typeinfo->setFlag(ObjTypeInfo::FUNCTION_OBJ);
109
+ analyzeGlobalStackObjType(typeinfo,val);
110
+ objSize = getObjSize(val);
111
+ }
112
+ else if(SVFUtil::isa<AllocaInst>(val))
113
+ {
114
+ typeinfo->setFlag(ObjTypeInfo::STACK_OBJ);
115
+ analyzeGlobalStackObjType(typeinfo,val);
116
+ objSize = getObjSize(val);
117
+ }
118
+ else if(SVFUtil::isa<GlobalVariable>(val))
119
+ {
120
+ typeinfo->setFlag(ObjTypeInfo::GLOBVAR_OBJ);
121
+ if(SymbolTableInfo::SymbolInfo()->isConstantObjSym(val))
122
+ typeinfo->setFlag(ObjTypeInfo::CONST_OBJ);
123
+ analyzeGlobalStackObjType(typeinfo,val);
124
+ objSize = getObjSize(val);
125
+ }
126
+ else if (SVFUtil::isa<Instruction>(val) && isHeapAllocExtCall(SVFUtil::cast<Instruction>(val)))
127
+ {
128
+ typeinfo->analyzeHeapObjType(val->getType());
129
+ // Heap object, label its field as infinite here
130
+ objSize = -1;
131
+ }
132
+ else if (SVFUtil::isa<Instruction>(val) && isStaticExtCall(SVFUtil::cast<Instruction>(val)))
133
+ {
134
+ typeinfo->analyzeStaticObjType(val->getType());
135
+ // static object allocated before main, label its field as infinite here
136
+ objSize = -1;
137
+ }
138
+ else if(ArgInProgEntryFunction(val))
139
+ {
140
+ typeinfo->analyzeStaticObjType(val->getType());
141
+ // user input data, label its field as infinite here
142
+ objSize = -1;
143
+ }
144
+ else
145
+ assert("what other object do we have??");
146
+
147
+ // Reset maxOffsetLimit if it is over the total fieldNum of this object
148
+ if(objSize > 0 && typeinfo->getMaxFieldOffsetLimit() > objSize)
149
+ typeinfo->setMaxFieldOffsetLimit(objSize);
150
+ }
151
+
152
+ /*!
153
+ * Return size of this Object
154
+ */
155
+ u32_t SymbolTableInfo::getObjSize(const Value* val)
156
+ {
157
+
158
+ Type* ety = SVFUtil::cast<PointerType>(val->getType())->getElementType();
159
+ u32_t numOfFields = 1;
160
+ if (SVFUtil::isa<StructType>(ety) || SVFUtil::isa<ArrayType>(ety))
161
+ {
162
+ numOfFields = SymbolTableInfo::SymbolInfo()->getFlattenFieldInfoVec(ety).size();
163
+ }
164
+ return numOfFields;
165
+ }
166
+
50
167
  /*
51
168
  * Initial the memory object here
52
169
  */
53
- void MemObj::init(const Value *val)
170
+ ObjTypeInfo* SymbolTableInfo::createObjTypeInfo(const Value *val)
54
171
  {
55
172
  const PointerType *refTy = nullptr;
56
173
 
@@ -67,11 +184,9 @@ void MemObj::init(const Value *val)
67
184
  if (refTy)
68
185
  {
69
186
  Type *objTy = refTy->getElementType();
70
- if(Options::LocMemModel)
71
- typeInfo = new LocObjTypeInfo(val, objTy, Options::MaxFieldLimit);
72
- else
73
- typeInfo = new ObjTypeInfo(val, objTy, Options::MaxFieldLimit);
74
- typeInfo->init(val);
187
+ ObjTypeInfo* typeInfo = new ObjTypeInfo(val, objTy, Options::MaxFieldLimit);
188
+ initTypeInfo(typeInfo,val);
189
+ return typeInfo;
75
190
  }
76
191
  else
77
192
  {
@@ -79,9 +194,20 @@ void MemObj::init(const Value *val)
79
194
  writeWrnMsg(val->getName().str());
80
195
  writeWrnMsg("(" + getSourceLoc(val) + ")");
81
196
  assert(false && "Memory object must be held by a pointer-typed ref value.");
197
+ abort();
82
198
  }
83
199
  }
84
200
 
201
+ /*
202
+ * Initial the memory object here (for a dummy object)
203
+ */
204
+ ObjTypeInfo* SymbolTableInfo::createObjTypeInfo(const Type* type)
205
+ {
206
+ ObjTypeInfo* typeInfo = new ObjTypeInfo(StInfo::getMaxFieldLimit(),type);
207
+ typeInfo->analyzeHeapObjType(type);
208
+ return typeInfo;
209
+ }
210
+
85
211
  /*!
86
212
  * Get the symbol table instance
87
213
  */
@@ -89,10 +215,7 @@ SymbolTableInfo* SymbolTableInfo::SymbolInfo()
89
215
  {
90
216
  if (symInfo == nullptr)
91
217
  {
92
- if(Options::LocMemModel)
93
- symInfo = new LocSymTableInfo();
94
- else
95
- symInfo = new SymbolTableInfo();
218
+ symInfo = new SymbolTableInfo();
96
219
  symInfo->setModelConstants(Options::ModelConsts);
97
220
  }
98
221
  return symInfo;
@@ -659,8 +782,8 @@ void SymbolTableInfo::collectObj(const Value *val)
659
782
  DBOUT(DMemModel,
660
783
  outs() << "create a new obj sym " << id << "\n");
661
784
 
662
- // create a memory object
663
- MemObj* mem = new MemObj(val, id);
785
+ // create a memory object
786
+ MemObj* mem = new MemObj(id, createObjTypeInfo(val), val);
664
787
  assert(objMap.find(id) == objMap.end());
665
788
  objMap[id] = mem;
666
789
  }
@@ -1092,3 +1215,4 @@ u32_t SymbolTableInfo::getTypeSizeInBytes(const StructType *sty, u32_t field_idx
1092
1215
 
1093
1216
 
1094
1217
 
1218
+
@@ -629,14 +629,6 @@ namespace SVF
629
629
  llvm::cl::desc("add svf.main()")
630
630
  );
631
631
 
632
-
633
- // SymbolTableInfo.cpp
634
- const llvm::cl::opt<bool> Options::LocMemModel(
635
- "loc-mm",
636
- llvm::cl::init(false),
637
- llvm::cl::desc("Bytes/bits modeling of memory locations")
638
- );
639
-
640
632
  const llvm::cl::opt<bool> Options::ModelConsts(
641
633
  "model-consts",
642
634
  llvm::cl::init(false),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.312",
3
+ "version": "1.0.313",
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": {