svf-lib 1.0.729 → 1.0.733

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 (61) hide show
  1. package/SVF-linux/Release-build/lib/libSvf.a +0 -0
  2. package/SVF-linux/include/DDA/DDAVFSolver.h +1 -1
  3. package/SVF-linux/include/Graphs/PAG.h +4 -4
  4. package/SVF-linux/include/Graphs/PAGNode.h +3 -3
  5. package/SVF-linux/include/MemoryModel/SVFIR.h +1 -1
  6. package/SVF-linux/include/MemoryModel/SVFSymbols.h +648 -0
  7. package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +26 -14
  8. package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +1 -1
  9. package/SVF-osx/Release-build/lib/CUDD/libCudd.a +0 -0
  10. package/SVF-osx/Release-build/lib/libSvf.a +0 -0
  11. package/SVF-osx/include/DDA/ContextDDA.h +1 -1
  12. package/SVF-osx/include/DDA/DDAClient.h +8 -8
  13. package/SVF-osx/include/DDA/DDAVFSolver.h +6 -6
  14. package/SVF-osx/include/DDA/FlowDDA.h +1 -1
  15. package/SVF-osx/include/Graphs/ConsG.h +6 -6
  16. package/SVF-osx/include/Graphs/ConsGEdge.h +2 -2
  17. package/SVF-osx/include/Graphs/ConsGNode.h +1 -1
  18. package/SVF-osx/include/Graphs/ExternalPAG.h +14 -14
  19. package/SVF-osx/include/Graphs/ICFGNode.h +14 -14
  20. package/SVF-osx/include/Graphs/IRGraph.h +245 -0
  21. package/SVF-osx/include/Graphs/OfflineConsG.h +1 -1
  22. package/SVF-osx/include/Graphs/PAG.h +4 -4
  23. package/SVF-osx/include/Graphs/PAGNode.h +4 -4
  24. package/SVF-osx/include/Graphs/SVFG.h +1 -1
  25. package/SVF-osx/include/Graphs/SVFGOPT.h +3 -3
  26. package/SVF-osx/include/Graphs/VFG.h +19 -19
  27. package/SVF-osx/include/Graphs/VFGNode.h +2 -3
  28. package/SVF-osx/include/MSSA/MemRegion.h +11 -11
  29. package/SVF-osx/include/MSSA/MemSSA.h +4 -4
  30. package/SVF-osx/include/MTA/FSMPTA.h +1 -1
  31. package/SVF-osx/include/MemoryModel/LocationSet.h +0 -1
  32. package/SVF-osx/include/MemoryModel/PAGBuilderFromFile.h +8 -8
  33. package/SVF-osx/include/MemoryModel/PTAStat.h +31 -31
  34. package/SVF-osx/include/MemoryModel/PointerAnalysis.h +9 -9
  35. package/SVF-osx/include/MemoryModel/PointerAnalysisImpl.h +3 -3
  36. package/SVF-osx/include/MemoryModel/SVFIR.h +738 -0
  37. package/SVF-osx/include/MemoryModel/SVFStatements.h +738 -0
  38. package/SVF-osx/include/MemoryModel/SVFSymbols.h +648 -0
  39. package/SVF-osx/include/MemoryModel/SVFVariables.h +842 -0
  40. package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +731 -0
  41. package/SVF-osx/include/SABER/SaberSVFGBuilder.h +0 -2
  42. package/SVF-osx/include/SABER/SrcSnkDDA.h +3 -3
  43. package/SVF-osx/include/SVF-FE/Graph2Json.h +1 -3
  44. package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +392 -0
  45. package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +89 -0
  46. package/SVF-osx/include/Util/BasicTypes.h +0 -10
  47. package/SVF-osx/include/Util/CFLSolver.h +1 -1
  48. package/SVF-osx/include/Util/ExtAPI.h +1 -1
  49. package/SVF-osx/include/Util/IRAnnotator.h +6 -6
  50. package/SVF-osx/include/Util/Options.h +1 -1
  51. package/SVF-osx/include/Util/SVFUtil.h +11 -0
  52. package/SVF-osx/include/Util/TypeBasedHeapCloning.h +11 -11
  53. package/SVF-osx/include/WPA/Andersen.h +11 -100
  54. package/SVF-osx/include/WPA/AndersenSFR.h +4 -4
  55. package/SVF-osx/include/WPA/FlowSensitive.h +2 -2
  56. package/SVF-osx/include/WPA/FlowSensitiveTBHC.h +1 -1
  57. package/SVF-osx/include/WPA/Steensgaard.h +2 -2
  58. package/SVF-osx/include/WPA/TypeAnalysis.h +1 -1
  59. package/SVF-osx/include/WPA/VersionedFlowSensitive.h +2 -2
  60. package/SVF-osx/include/WPA/WPAStat.h +1 -2
  61. package/package.json +1 -1
@@ -0,0 +1,731 @@
1
+ //===- SymbolTableInfo.h -- Symbol information from IR------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * SymbolTableInfo.h
25
+ *
26
+ * Created on: Nov 11, 2013
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef INCLUDE_SVF_FE_SYMBOLTABLEINFO_H_
31
+ #define INCLUDE_SVF_FE_SYMBOLTABLEINFO_H_
32
+
33
+
34
+ #include "Util/SVFUtil.h"
35
+ #include "MemoryModel/LocationSet.h"
36
+ #include "Util/SVFModule.h"
37
+ namespace SVF
38
+ {
39
+
40
+ class MemObj;
41
+ class ObjTypeInfo;
42
+ class StInfo;
43
+
44
+ /*!
45
+ * Symbol table of the memory model for analysis
46
+ */
47
+ class SymbolTableInfo
48
+ {
49
+ friend class SymbolTableBuilder;
50
+
51
+ public:
52
+
53
+ /// Symbol types
54
+ enum SYMTYPE
55
+ {
56
+ BlackHole,
57
+ ConstantObj,
58
+ BlkPtr,
59
+ NullPtr,
60
+ ValSymbol,
61
+ ObjSymbol,
62
+ RetSymbol,
63
+ VarargSymbol
64
+ };
65
+
66
+ /// various maps defined
67
+ //{@
68
+ /// llvm value to sym id map
69
+ /// local (%) and global (@) identifiers are pointer types which have a value node id.
70
+ typedef OrderedMap<const Value *, SymID> ValueToIDMapTy;
71
+ /// sym id to memory object map
72
+ typedef OrderedMap<SymID,MemObj*> IDToMemMapTy;
73
+ /// function to sym id map
74
+ typedef OrderedMap<const Function *, SymID> FunToIDMapTy;
75
+ /// struct type to struct info map
76
+ typedef OrderedMap<const Type*, StInfo*> TypeToFieldInfoMap;
77
+ typedef Set<CallSite> CallSiteSet;
78
+ typedef OrderedMap<const Instruction*,CallSiteID> CallSiteToIDMapTy;
79
+ typedef OrderedMap<CallSiteID,const Instruction*> IDToCallSiteMapTy;
80
+
81
+ //@}
82
+
83
+ private:
84
+ /// Data layout on a target machine
85
+ static DataLayout *dl;
86
+
87
+ ValueToIDMapTy valSymMap; ///< map a value to its sym id
88
+ ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
89
+ FunToIDMapTy returnSymMap; ///< return map
90
+ FunToIDMapTy varargSymMap; ///< vararg map
91
+ IDToMemMapTy objMap; ///< map a memory sym id to its obj
92
+
93
+ CallSiteSet callSiteSet;
94
+
95
+ // Singleton pattern here to enable instance of SymbolTableInfo can only be created once.
96
+ static SymbolTableInfo* symInfo;
97
+
98
+ /// Module
99
+ SVFModule* mod;
100
+
101
+ /// Max field limit
102
+ static u32_t maxFieldLimit;
103
+
104
+ /// Clean up memory
105
+ void destroy();
106
+
107
+ /// Whether to model constants
108
+ bool modelConstants;
109
+
110
+ /// total number of symbols
111
+ SymID totalSymNum;
112
+
113
+ protected:
114
+ /// Constructor
115
+ SymbolTableInfo(void) :
116
+ mod(nullptr), modelConstants(false), totalSymNum(0), maxStruct(nullptr), maxStSize(0)
117
+ {
118
+ }
119
+
120
+ public:
121
+
122
+ /// Singleton design here to make sure we only have one instance during any analysis
123
+ //@{
124
+ static SymbolTableInfo* SymbolInfo();
125
+
126
+ static void releaseSymbolInfo()
127
+ {
128
+ delete symInfo;
129
+ symInfo = nullptr;
130
+ }
131
+ virtual ~SymbolTableInfo()
132
+ {
133
+ destroy();
134
+ }
135
+ //@}
136
+
137
+ /// Set / Get modelConstants
138
+ //@{
139
+ void setModelConstants(bool _modelConstants)
140
+ {
141
+ modelConstants = _modelConstants;
142
+ }
143
+ bool getModelConstants() const
144
+ {
145
+ return modelConstants;
146
+ }
147
+ //@}
148
+
149
+ /// Get callsite set
150
+ //@{
151
+ inline const CallSiteSet& getCallSiteSet() const
152
+ {
153
+ return callSiteSet;
154
+ }
155
+ //@}
156
+
157
+ /// Module
158
+ inline SVFModule* getModule()
159
+ {
160
+ return mod;
161
+ }
162
+ /// Module
163
+ inline void setModule(SVFModule* m)
164
+ {
165
+ mod = m;
166
+ }
167
+
168
+ /// Get target machine data layout
169
+ inline static DataLayout* getDataLayout(Module* mod)
170
+ {
171
+ if(dl==nullptr)
172
+ return dl = new DataLayout(mod);
173
+ return dl;
174
+ }
175
+
176
+ /// Helper method to get the size of the type from target data layout
177
+ //@{
178
+ u32_t getTypeSizeInBytes(const Type* type);
179
+ u32_t getTypeSizeInBytes(const StructType *sty, u32_t field_index);
180
+ //@}
181
+
182
+ /// special value
183
+ // @{
184
+ static bool isNullPtrSym(const Value *val);
185
+
186
+ static bool isBlackholeSym(const Value *val);
187
+
188
+ bool isConstantObjSym(const Value *val);
189
+
190
+ static inline bool isBlkPtr(NodeID id)
191
+ {
192
+ return (id == BlkPtr);
193
+ }
194
+ static inline bool isNullPtr(NodeID id)
195
+ {
196
+ return (id == NullPtr);
197
+ }
198
+ static inline bool isBlkObj(NodeID id)
199
+ {
200
+ return (id == BlackHole);
201
+ }
202
+ static inline bool isConstantObj(NodeID id)
203
+ {
204
+ return (id == ConstantObj);
205
+ }
206
+ static inline bool isBlkObjOrConstantObj(NodeID id)
207
+ {
208
+ return (isBlkObj(id) || isConstantObj(id));
209
+ }
210
+
211
+ MemObj* createBlkObj(SymID symId);
212
+
213
+ MemObj* createConstantObj(SymID symId);
214
+
215
+ inline MemObj* getBlkObj() const
216
+ {
217
+ return getObj(blackholeSymID());
218
+ }
219
+ inline MemObj* getConstantObj() const
220
+ {
221
+ return getObj(constantSymID());
222
+ }
223
+
224
+ inline SymID blkPtrSymID() const
225
+ {
226
+ return BlkPtr;
227
+ }
228
+
229
+ inline SymID nullPtrSymID() const
230
+ {
231
+ return NullPtr;
232
+ }
233
+
234
+ inline SymID constantSymID() const
235
+ {
236
+ return ConstantObj;
237
+ }
238
+
239
+ inline SymID blackholeSymID() const
240
+ {
241
+ return BlackHole;
242
+ }
243
+
244
+ /// Can only be invoked by SVFIR::addDummyNode() when creaing SVFIR from file.
245
+ const MemObj* createDummyObj(SymID symId, const Type* type);
246
+ // @}
247
+
248
+ /// Get different kinds of syms
249
+ //@{
250
+ SymID getValSym(const Value *val)
251
+ {
252
+
253
+ if(isNullPtrSym(val))
254
+ return nullPtrSymID();
255
+ else if(isBlackholeSym(val))
256
+ return blkPtrSymID();
257
+ else
258
+ {
259
+ ValueToIDMapTy::const_iterator iter = valSymMap.find(val);
260
+ assert(iter!=valSymMap.end() &&"value sym not found");
261
+ return iter->second;
262
+ }
263
+ }
264
+
265
+ inline bool hasValSym(const Value* val)
266
+ {
267
+ if (isNullPtrSym(val) || isBlackholeSym(val))
268
+ return true;
269
+ else
270
+ return (valSymMap.find(val) != valSymMap.end());
271
+ }
272
+
273
+ inline SymID getObjSym(const Value *val) const
274
+ {
275
+ ValueToIDMapTy::const_iterator iter = objSymMap.find(SVFUtil::getGlobalRep(val));
276
+ assert(iter!=objSymMap.end() && "obj sym not found");
277
+ return iter->second;
278
+ }
279
+
280
+ inline MemObj* getObj(SymID id) const
281
+ {
282
+ IDToMemMapTy::const_iterator iter = objMap.find(id);
283
+ assert(iter!=objMap.end() && "obj not found");
284
+ return iter->second;
285
+ }
286
+
287
+ inline SymID getRetSym(const Function *val) const
288
+ {
289
+ FunToIDMapTy::const_iterator iter = returnSymMap.find(val);
290
+ assert(iter!=returnSymMap.end() && "ret sym not found");
291
+ return iter->second;
292
+ }
293
+
294
+ inline SymID getVarargSym(const Function *val) const
295
+ {
296
+ FunToIDMapTy::const_iterator iter = varargSymMap.find(val);
297
+ assert(iter!=varargSymMap.end() && "vararg sym not found");
298
+ return iter->second;
299
+ }
300
+ //@}
301
+
302
+
303
+ /// Statistics
304
+ //@{
305
+ inline Size_t getTotalSymNum() const
306
+ {
307
+ return totalSymNum;
308
+ }
309
+ inline u32_t getMaxStructSize() const
310
+ {
311
+ return maxStSize;
312
+ }
313
+ //@}
314
+
315
+ /// Get different kinds of syms maps
316
+ //@{
317
+ inline ValueToIDMapTy& valSyms()
318
+ {
319
+ return valSymMap;
320
+ }
321
+
322
+ inline ValueToIDMapTy& objSyms()
323
+ {
324
+ return objSymMap;
325
+ }
326
+
327
+ inline IDToMemMapTy& idToObjMap()
328
+ {
329
+ return objMap;
330
+ }
331
+
332
+ inline FunToIDMapTy& retSyms()
333
+ {
334
+ return returnSymMap;
335
+ }
336
+
337
+ inline FunToIDMapTy& varargSyms()
338
+ {
339
+ return varargSymMap;
340
+ }
341
+
342
+ //@}
343
+
344
+ /// Get struct info
345
+ //@{
346
+ ///Get an iterator for StructInfo, designed as internal methods
347
+ TypeToFieldInfoMap::iterator getStructInfoIter(const Type *T)
348
+ {
349
+ assert(T);
350
+ TypeToFieldInfoMap::iterator it = typeToFieldInfo.find(T);
351
+ if (it != typeToFieldInfo.end())
352
+ return it;
353
+ else
354
+ {
355
+ collectTypeInfo(T);
356
+ return typeToFieldInfo.find(T);
357
+ }
358
+ }
359
+
360
+ ///Get a reference to StructInfo.
361
+ inline StInfo* getStructInfo(const Type *T)
362
+ {
363
+ return getStructInfoIter(T)->second;
364
+ }
365
+
366
+ ///Get a reference to the components of struct_info.
367
+ const std::vector<u32_t>& getFattenFieldIdxVec(const Type *T);
368
+ const std::vector<u32_t>& getFattenFieldOffsetVec(const Type *T);
369
+ const std::vector<FieldInfo>& getFlattenFieldInfoVec(const Type *T);
370
+ const Type* getOrigSubTypeWithFldInx(const Type* baseType, u32_t field_idx);
371
+ const Type* getOrigSubTypeWithByteOffset(const Type* baseType, u32_t byteOffset);
372
+ //@}
373
+
374
+ /// Compute gep offset
375
+ virtual bool computeGepOffset(const User *V, LocationSet& ls);
376
+ /// Get the base type and max offset
377
+ const Type *getBaseTypeAndFlattenedFields(const Value *V, std::vector<LocationSet> &fields);
378
+ /// Replace fields with flatten fields of T if the number of its fields is larger than msz.
379
+ u32_t getFields(std::vector<LocationSet>& fields, const Type* T, u32_t msz);
380
+ /// Collect type info
381
+ void collectTypeInfo(const Type* T);
382
+ /// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
383
+ virtual LocationSet getModulusOffset(const MemObj* obj, const LocationSet& ls);
384
+
385
+ /// Debug method
386
+ void printFlattenFields(const Type* type);
387
+
388
+ static std::string toString(SYMTYPE symtype);
389
+
390
+ /// Another debug method
391
+ virtual void dump();
392
+
393
+ protected:
394
+ /// Collect the struct info
395
+ virtual void collectStructInfo(const StructType *T);
396
+ /// Collect the array info
397
+ virtual void collectArrayInfo(const ArrayType* T);
398
+ /// Collect simple type (non-aggregate) info
399
+ virtual void collectSimpleTypeInfo(const Type* T);
400
+
401
+ /// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
402
+ ObjTypeInfo* createObjTypeInfo(const Type *type = nullptr);
403
+
404
+ /// Every type T is mapped to StInfo
405
+ /// which contains size (fsize) , offset(foffset)
406
+ /// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
407
+ /// fsize[0] is always the size of the expanded struct.
408
+ TypeToFieldInfoMap typeToFieldInfo;
409
+
410
+ ///The struct type with the most fields
411
+ const Type* maxStruct;
412
+
413
+ ///The number of fields in max_struct
414
+ u32_t maxStSize;
415
+ };
416
+
417
+
418
+ /*!
419
+ * Memory object symbols or MemObj (address-taken variables in LLVM-based languages)
420
+ */
421
+ class MemObj
422
+ {
423
+
424
+ private:
425
+ /// Type information of this object
426
+ ObjTypeInfo* typeInfo;
427
+ /// The unique value of this symbol/variable
428
+ const Value *refVal;
429
+ /// The unique id to represent this symbol
430
+ SymID symId;
431
+ public:
432
+
433
+ /// Constructor
434
+ MemObj(SymID id, ObjTypeInfo* ti, const Value *val = nullptr);
435
+
436
+ /// Destructor
437
+ ~MemObj()
438
+ {
439
+ destroy();
440
+ }
441
+
442
+ virtual const std::string toString() const;
443
+
444
+ /// Get the reference value to this object
445
+ inline const Value* getValue() const
446
+ {
447
+ return refVal;
448
+ }
449
+
450
+ /// Get the memory object id
451
+ inline SymID getId() const
452
+ {
453
+ return symId;
454
+ }
455
+
456
+ /// Get obj type
457
+ const Type* getType() const;
458
+
459
+ /// Get max field offset limit
460
+ Size_t getMaxFieldOffsetLimit() const;
461
+
462
+ /// Return true if its field limit is 0
463
+ bool isFieldInsensitive() const;
464
+
465
+ /// Set the memory object to be field insensitive
466
+ void setFieldInsensitive();
467
+
468
+ /// Set the memory object to be field sensitive (up to max field limit)
469
+ void setFieldSensitive();
470
+
471
+ /// Whether it is a black hole object
472
+ bool isBlackHoleObj() const;
473
+
474
+ /// object attributes methods
475
+ //@{
476
+ bool isFunction() const;
477
+ bool isGlobalObj() const;
478
+ bool isStaticObj() const;
479
+ bool isStack() const;
480
+ bool isHeap() const;
481
+ bool isStruct() const;
482
+ bool isArray() const;
483
+ bool isVarStruct() const;
484
+ bool isVarArray() const;
485
+ bool isConstStruct() const;
486
+ bool isConstArray() const;
487
+ bool isConstant() const;
488
+ bool hasPtrObj() const;
489
+ bool isNonPtrFieldObj(const LocationSet& ls) const;
490
+ //@}
491
+
492
+ /// Operator overloading
493
+ inline bool operator==(const MemObj &mem) const
494
+ {
495
+ return getValue() == mem.getValue();
496
+ }
497
+
498
+ /// Clean up memory
499
+ void destroy();
500
+ };
501
+
502
+
503
+
504
+
505
+ /*!
506
+ * Struct information
507
+ */
508
+ class StInfo
509
+ {
510
+
511
+ private:
512
+ /// flattened field indices of a struct
513
+ std::vector<u32_t> fldIdxVec;
514
+ /// flattened field offsets of of a struct
515
+ std::vector<u32_t> foffset;
516
+ /// Types of all fields of a struct
517
+ Map<u32_t, const llvm::Type*> fldIdx2TypeMap;
518
+ /// Types of all fields of a struct
519
+ Map<u32_t, const llvm::Type*> offset2TypeMap;
520
+ /// All field infos after flattening a struct
521
+ std::vector<FieldInfo> finfo;
522
+
523
+ /// Max field limit
524
+ static u32_t maxFieldLimit;
525
+
526
+ public:
527
+ /// Constructor
528
+ StInfo()
529
+ {
530
+ }
531
+ /// Destructor
532
+ ~StInfo()
533
+ {
534
+ }
535
+
536
+ static inline void setMaxFieldLimit(u32_t limit)
537
+ {
538
+ maxFieldLimit = limit;
539
+ }
540
+
541
+ static inline u32_t getMaxFieldLimit()
542
+ {
543
+ return maxFieldLimit;
544
+ }
545
+
546
+ /// Get method for fields of a struct
547
+ //{@
548
+ inline const llvm::Type* getFieldTypeWithFldIdx(u32_t fldIdx)
549
+ {
550
+ return fldIdx2TypeMap[fldIdx];
551
+ }
552
+ inline const llvm::Type* getFieldTypeWithByteOffset(u32_t offset)
553
+ {
554
+ return offset2TypeMap[offset];
555
+ }
556
+ inline std::vector<u32_t>& getFieldIdxVec()
557
+ {
558
+ return fldIdxVec;
559
+ }
560
+ inline std::vector<u32_t>& getFieldOffsetVec()
561
+ {
562
+ return foffset;
563
+ }
564
+ inline std::vector<FieldInfo>& getFlattenFieldInfoVec()
565
+ {
566
+ return finfo;
567
+ }
568
+ //@}
569
+
570
+ /// Add field (index and offset) with its corresponding type
571
+ inline void addFldWithType(u32_t fldIdx, u32_t offset, const llvm::Type* type)
572
+ {
573
+ fldIdxVec.push_back(fldIdx);
574
+ foffset.push_back(offset);
575
+ fldIdx2TypeMap[fldIdx] = type;
576
+ offset2TypeMap[offset] = type;
577
+ }
578
+ };
579
+
580
+ /*!
581
+ * Type Info of an abstract memory object
582
+ */
583
+ class ObjTypeInfo
584
+ {
585
+
586
+ public:
587
+ typedef enum
588
+ {
589
+ FUNCTION_OBJ = 0x1, // object is a function
590
+ GLOBVAR_OBJ = 0x2, // object is a global variable
591
+ STATIC_OBJ = 0x4, // object is a static variable allocated before main
592
+ STACK_OBJ = 0x8, // object is a stack variable
593
+ HEAP_OBJ = 0x10, // object is a heap variable
594
+ VAR_STRUCT_OBJ = 0x20, // object contains struct
595
+ VAR_ARRAY_OBJ = 0x40, // object contains array
596
+ CONST_STRUCT_OBJ = 0x80, // constant struct
597
+ CONST_ARRAY_OBJ = 0x100, // constant array
598
+ CONST_OBJ = 0x200, // constant object str e.g.
599
+ HASPTR_OBJ = 0x400 // non pointer object including compound type have field that is a pointer type
600
+ } MEMTYPE;
601
+
602
+ private:
603
+ /// LLVM type
604
+ const Type* type;
605
+ /// Type flags
606
+ Size_t flags;
607
+ /// Max offset for flexible field sensitive analysis
608
+ /// maximum number of field object can be created
609
+ /// minimum number is 0 (field insensitive analysis)
610
+ u32_t maxOffsetLimit;
611
+ public:
612
+
613
+ /// Constructors
614
+ ObjTypeInfo(const Value*, const Type* t, u32_t max) :
615
+ type(t), flags(0), maxOffsetLimit(max)
616
+ {
617
+ }
618
+ /// Constructor
619
+ ObjTypeInfo(u32_t max, const Type* t) : type(t), flags(0), maxOffsetLimit(max)
620
+ {
621
+
622
+ }
623
+ /// Destructor
624
+ virtual ~ObjTypeInfo()
625
+ {
626
+
627
+ }
628
+
629
+ /// Analyse types of heap and static objects
630
+ void analyzeHeapObjType(const Type* type);
631
+
632
+ /// Analyse types of heap and static objects
633
+ void analyzeStaticObjType(const Type* type);
634
+
635
+ /// Get LLVM type
636
+ inline const Type* getType() const
637
+ {
638
+ return type;
639
+ }
640
+
641
+ /// Get max field offset limit
642
+ inline u32_t getMaxFieldOffsetLimit()
643
+ {
644
+ return maxOffsetLimit;
645
+ }
646
+
647
+ /// Get max field offset limit
648
+ inline void setMaxFieldOffsetLimit(u32_t limit)
649
+ {
650
+ maxOffsetLimit = limit;
651
+ }
652
+
653
+ /// Flag for this object type
654
+ //@{
655
+ inline void setFlag(MEMTYPE mask)
656
+ {
657
+ flags |= mask;
658
+ }
659
+ inline bool hasFlag(MEMTYPE mask)
660
+ {
661
+ return (flags & mask) == mask;
662
+ }
663
+ //@}
664
+
665
+ /// Object attributes
666
+ //@{
667
+ inline bool isFunction()
668
+ {
669
+ return hasFlag(FUNCTION_OBJ);
670
+ }
671
+ inline bool isGlobalObj()
672
+ {
673
+ return hasFlag(GLOBVAR_OBJ);
674
+ }
675
+ inline bool isStaticObj()
676
+ {
677
+ return hasFlag(STATIC_OBJ);
678
+ }
679
+ inline bool isStack()
680
+ {
681
+ return hasFlag(STACK_OBJ);
682
+ }
683
+ inline bool isHeap()
684
+ {
685
+ return hasFlag(HEAP_OBJ);
686
+ }
687
+ //@}
688
+
689
+ /// Object attributes (noted that an object can be a nested compound types)
690
+ /// e.g. both isStruct and isArray can return true
691
+ //@{
692
+ inline bool isVarStruct()
693
+ {
694
+ return hasFlag(VAR_STRUCT_OBJ);
695
+ }
696
+ inline bool isConstStruct()
697
+ {
698
+ return hasFlag(CONST_STRUCT_OBJ);
699
+ }
700
+ inline bool isStruct()
701
+ {
702
+ return hasFlag(VAR_STRUCT_OBJ) || hasFlag(CONST_STRUCT_OBJ);
703
+ }
704
+ inline bool isVarArray()
705
+ {
706
+ return hasFlag(VAR_ARRAY_OBJ);
707
+ }
708
+ inline bool isConstArray()
709
+ {
710
+ return hasFlag(CONST_ARRAY_OBJ);
711
+ }
712
+ inline bool isArray()
713
+ {
714
+ return hasFlag(VAR_ARRAY_OBJ) || hasFlag(CONST_ARRAY_OBJ);
715
+ }
716
+ inline bool isConstant()
717
+ {
718
+ return hasFlag(CONST_OBJ);
719
+ }
720
+ inline bool hasPtrObj()
721
+ {
722
+ return hasFlag(HASPTR_OBJ);
723
+ }
724
+ virtual bool isNonPtrFieldObj(const LocationSet& ls);
725
+ //@}
726
+ };
727
+
728
+
729
+ } // End namespace SVF
730
+
731
+ #endif /* INCLUDE_SVF_FE_SYMBOLTABLEINFO_H_ */