svf-lib 1.0.2197 → 1.0.2199

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 (37) 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/Graphs/IRGraph.h +238 -29
  10. package/SVF-linux/Release-build/include/MemoryModel/AccessPath.h +0 -1
  11. package/SVF-linux/Release-build/include/SVF-LLVM/LLVMModule.h +1 -1
  12. package/SVF-linux/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +3 -3
  13. package/SVF-linux/Release-build/include/SVFIR/ObjTypeInfo.h +225 -0
  14. package/SVF-linux/Release-build/include/SVFIR/SVFIR.h +9 -19
  15. package/SVF-linux/Release-build/include/SVFIR/SVFVariables.h +4 -9
  16. package/SVF-linux/Release-build/lib/libSvfCore.a +0 -0
  17. package/SVF-linux/Release-build/lib/libSvfLLVM.a +0 -0
  18. package/SVF-osx/Release-build/bin/ae +0 -0
  19. package/SVF-osx/Release-build/bin/cfl +0 -0
  20. package/SVF-osx/Release-build/bin/dvf +0 -0
  21. package/SVF-osx/Release-build/bin/llvm2svf +0 -0
  22. package/SVF-osx/Release-build/bin/mta +0 -0
  23. package/SVF-osx/Release-build/bin/saber +0 -0
  24. package/SVF-osx/Release-build/bin/svf-ex +0 -0
  25. package/SVF-osx/Release-build/bin/wpa +0 -0
  26. package/SVF-osx/Release-build/include/Graphs/IRGraph.h +6 -34
  27. package/SVF-osx/Release-build/include/SVF-LLVM/LLVMModule.h +43 -1
  28. package/SVF-osx/Release-build/include/SVF-LLVM/SVFIRBuilder.h +2 -2
  29. package/SVF-osx/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +6 -2
  30. package/SVF-osx/Release-build/include/SVFIR/SVFIR.h +9 -1
  31. package/SVF-osx/Release-build/include/SVFIR/SVFVariables.h +1 -1
  32. package/SVF-osx/Release-build/include/Util/GeneralType.h +0 -1
  33. package/SVF-osx/Release-build/include/Util/SVFUtil.h +0 -1
  34. package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
  35. package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
  36. package/package.json +1 -1
  37. package/SVF-linux/Release-build/include/SVFIR/SymbolTableInfo.h +0 -545
@@ -1,545 +0,0 @@
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 Affero 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 Affero General Public License for more details.
17
-
18
- // You should have received a copy of the GNU Affero 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_SVFIR_SYMBOLTABLEINFO_H_
31
- #define INCLUDE_SVFIR_SYMBOLTABLEINFO_H_
32
-
33
-
34
- #include "Util/SVFUtil.h"
35
- #include "MemoryModel/AccessPath.h"
36
- #include "SVFIR/SVFModule.h"
37
- namespace SVF
38
- {
39
-
40
- class ObjTypeInfo;
41
- class StInfo;
42
- class BaseObjVar;
43
-
44
- /*!
45
- * Symbol table of the memory model for analysis
46
- */
47
- class SymbolTableInfo
48
- {
49
- friend class SymbolTableBuilder;
50
- friend class SVFIRWriter;
51
- friend class SVFIRReader;
52
-
53
- public:
54
-
55
- /// Symbol types
56
- enum SYMTYPE
57
- {
58
- NullPtr,
59
- BlkPtr,
60
- BlackHole,
61
- ConstantObj,
62
- ValSymbol,
63
- ObjSymbol,
64
- RetSymbol,
65
- VarargSymbol
66
- };
67
-
68
- /// various maps defined
69
- //{@
70
- /// llvm value to sym id map
71
- /// local (%) and global (@) identifiers are pointer types which have a value node id.
72
- typedef OrderedMap<const SVFValue*, SymID> ValueToIDMapTy;
73
- /// sym id to obj type info map
74
- typedef OrderedMap<SymID, ObjTypeInfo*> IDToTypeInfoMapTy;
75
-
76
- /// function to sym id map
77
- typedef OrderedMap<const SVFFunction*, SymID> FunToIDMapTy;
78
- /// struct type to struct info map
79
- typedef Set<const SVFType*> SVFTypeSet;
80
- //@}
81
-
82
- private:
83
- ValueToIDMapTy valSymMap; ///< map a value to its sym id
84
- ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
85
- FunToIDMapTy returnSymMap; ///< return map
86
- FunToIDMapTy varargSymMap; ///< vararg map
87
- IDToTypeInfoMapTy objTypeInfoMap; ///< map a memory sym id to its obj
88
-
89
- // Singleton pattern here to enable instance of SymbolTableInfo can only be created once.
90
- static SymbolTableInfo* symInfo;
91
-
92
- /// Module
93
- SVFModule* mod;
94
-
95
- /// Clean up memory
96
- void destroy();
97
-
98
- /// Whether to model constants
99
- bool modelConstants;
100
-
101
- /// total number of symbols
102
- SymID totalSymNum;
103
-
104
- protected:
105
- /// Constructor
106
- SymbolTableInfo(void)
107
- : mod(nullptr), modelConstants(false), totalSymNum(0),
108
- maxStruct(nullptr), maxStSize(0)
109
- {
110
- }
111
-
112
- public:
113
-
114
- /// Singleton design here to make sure we only have one instance during any analysis
115
- //@{
116
- static SymbolTableInfo* SymbolInfo();
117
-
118
- static void releaseSymbolInfo()
119
- {
120
- delete symInfo;
121
- symInfo = nullptr;
122
- }
123
- virtual ~SymbolTableInfo()
124
- {
125
- destroy();
126
- }
127
- //@}
128
-
129
- /// Set / Get modelConstants
130
- //@{
131
- void setModelConstants(bool _modelConstants)
132
- {
133
- modelConstants = _modelConstants;
134
- }
135
- bool getModelConstants() const
136
- {
137
- return modelConstants;
138
- }
139
- //@}
140
-
141
- /// Module
142
- inline SVFModule* getModule()
143
- {
144
- return mod;
145
- }
146
- /// Module
147
- inline void setModule(SVFModule* m)
148
- {
149
- mod = m;
150
- }
151
-
152
- /// special value
153
- // @{
154
- static inline bool isBlkPtr(NodeID id)
155
- {
156
- return (id == BlkPtr);
157
- }
158
- static inline bool isNullPtr(NodeID id)
159
- {
160
- return (id == NullPtr);
161
- }
162
- static inline bool isBlkObj(NodeID id)
163
- {
164
- return (id == BlackHole);
165
- }
166
- static inline bool isConstantObj(NodeID id)
167
- {
168
- return (id == ConstantObj);
169
- }
170
- static inline bool isBlkObjOrConstantObj(NodeID id)
171
- {
172
- return (isBlkObj(id) || isConstantObj(id));
173
- }
174
-
175
- inline SymID blkPtrSymID() const
176
- {
177
- return BlkPtr;
178
- }
179
-
180
- inline SymID nullPtrSymID() const
181
- {
182
- return NullPtr;
183
- }
184
-
185
- inline SymID constantSymID() const
186
- {
187
- return ConstantObj;
188
- }
189
-
190
- inline SymID blackholeSymID() const
191
- {
192
- return BlackHole;
193
- }
194
-
195
- /// Get different kinds of syms
196
- //@{
197
- SymID getValSym(const SVFValue* val);
198
-
199
- bool hasValSym(const SVFValue* val);
200
-
201
- inline SymID getObjSym(const SVFValue* val) const
202
- {
203
- const SVFValue* svfVal = val;
204
- if(const SVFGlobalValue* g = SVFUtil::dyn_cast<SVFGlobalValue>(val))
205
- svfVal = g->getDefGlobalForMultipleModule();
206
- ValueToIDMapTy::const_iterator iter = objSymMap.find(svfVal);
207
- assert(iter!=objSymMap.end() && "obj sym not found");
208
- return iter->second;
209
- }
210
-
211
- inline ObjTypeInfo* getObjTypeInfo(SymID id) const
212
- {
213
- IDToTypeInfoMapTy::const_iterator iter = objTypeInfoMap.find(id);
214
- assert(iter!=objTypeInfoMap.end() && "obj type info not found");
215
- return iter->second;
216
- }
217
-
218
- inline SymID getRetSym(const SVFFunction* val) const
219
- {
220
- FunToIDMapTy::const_iterator iter = returnSymMap.find(val);
221
- assert(iter!=returnSymMap.end() && "ret sym not found");
222
- return iter->second;
223
- }
224
-
225
- inline SymID getVarargSym(const SVFFunction* val) const
226
- {
227
- FunToIDMapTy::const_iterator iter = varargSymMap.find(val);
228
- assert(iter!=varargSymMap.end() && "vararg sym not found");
229
- return iter->second;
230
- }
231
- //@}
232
-
233
-
234
- /// Statistics
235
- //@{
236
- inline u32_t getTotalSymNum() const
237
- {
238
- return totalSymNum;
239
- }
240
- inline u32_t getMaxStructSize() const
241
- {
242
- return maxStSize;
243
- }
244
- //@}
245
-
246
- /// Get different kinds of syms maps
247
- //@{
248
- inline ValueToIDMapTy& valSyms()
249
- {
250
- return valSymMap;
251
- }
252
-
253
- inline ValueToIDMapTy& objSyms()
254
- {
255
- return objSymMap;
256
- }
257
-
258
- inline IDToTypeInfoMapTy& idToObjTypeInfoMap()
259
- {
260
- return objTypeInfoMap;
261
- }
262
-
263
- inline const IDToTypeInfoMapTy& idToObjTypeInfoMap() const
264
- {
265
- return objTypeInfoMap;
266
- }
267
-
268
- inline FunToIDMapTy& retSyms()
269
- {
270
- return returnSymMap;
271
- }
272
-
273
- inline FunToIDMapTy& varargSyms()
274
- {
275
- return varargSymMap;
276
- }
277
-
278
- //@}
279
-
280
- /// Constant reader that won't change the state of the symbol table
281
- //@{
282
- inline const SVFTypeSet& getSVFTypes() const
283
- {
284
- return svfTypes;
285
- }
286
-
287
- inline const Set<const StInfo*>& getStInfos() const
288
- {
289
- return stInfos;
290
- }
291
- //@}
292
-
293
- /// Get struct info
294
- //@{
295
- ///Get a reference to StructInfo.
296
- const StInfo* getTypeInfo(const SVFType* T) const;
297
- inline bool hasSVFTypeInfo(const SVFType* T)
298
- {
299
- return svfTypes.find(T) != svfTypes.end();
300
- }
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
-
307
- ///Get a reference to the components of struct_info.
308
- /// Number of flattened elements of an array or struct
309
- u32_t getNumOfFlattenElements(const SVFType* T);
310
- /// Flattened element idx of an array or struct by considering stride
311
- u32_t getFlattenedElemIdx(const SVFType* T, u32_t origId);
312
- /// Return the type of a flattened element given a flattened index
313
- const SVFType* getFlatternedElemType(const SVFType* baseType, u32_t flatten_idx);
314
- /// struct A { int id; int salary; }; struct B { char name[20]; struct A a;} B b;
315
- /// OriginalElemType of b with field_idx 1 : Struct A
316
- /// FlatternedElemType of b with field_idx 1 : int
317
- const SVFType* getOriginalElemType(const SVFType* baseType, u32_t origId) const;
318
- //@}
319
-
320
- /// Debug method
321
- void printFlattenFields(const SVFType* type);
322
-
323
- static std::string toString(SYMTYPE symtype);
324
-
325
- /// Another debug method
326
- virtual void dump();
327
-
328
- /// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
329
- virtual APOffset getModulusOffset(const BaseObjVar* baseObj, const APOffset& apOffset);
330
-
331
- ///The struct type with the most fields
332
- const SVFType* maxStruct;
333
-
334
- ///The number of fields in max_struct
335
- u32_t maxStSize;
336
-
337
- inline void addTypeInfo(const SVFType* ty)
338
- {
339
- bool inserted = svfTypes.insert(ty).second;
340
- if(!inserted)
341
- assert(false && "this type info has been added before");
342
- }
343
-
344
- inline void addStInfo(StInfo* stInfo)
345
- {
346
- stInfos.insert(stInfo);
347
- }
348
-
349
- protected:
350
-
351
- /// Return the flattened field type for struct type only
352
- const std::vector<const SVFType*>& getFlattenFieldTypes(const SVFStructType *T);
353
-
354
- /// (owned) All SVF Types
355
- /// Every type T is mapped to StInfo
356
- /// which contains size (fsize) , offset(foffset)
357
- /// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
358
- /// fsize[0] is always the size of the expanded struct.
359
- SVFTypeSet svfTypes;
360
-
361
- /// @brief (owned) All StInfo
362
- Set<const StInfo*> stInfos;
363
- };
364
-
365
- class SVFBaseNode;
366
-
367
- /*!
368
- * Type Info of an abstract memory object
369
- */
370
- class ObjTypeInfo
371
- {
372
- friend class SVFIRWriter;
373
- friend class SVFIRReader;
374
- friend class SymbolTableBuilder;
375
-
376
- public:
377
- typedef enum
378
- {
379
- FUNCTION_OBJ = 0x1, // object is a function
380
- GLOBVAR_OBJ = 0x2, // object is a global variable
381
- STATIC_OBJ = 0x4, // object is a static variable allocated before main
382
- STACK_OBJ = 0x8, // object is a stack variable
383
- HEAP_OBJ = 0x10, // object is a heap variable
384
- VAR_STRUCT_OBJ = 0x20, // object contains struct
385
- VAR_ARRAY_OBJ = 0x40, // object contains array
386
- CONST_STRUCT_OBJ = 0x80, // constant struct
387
- CONST_ARRAY_OBJ = 0x100, // constant array
388
- CONST_GLOBAL_OBJ = 0x200, // global constant object
389
- CONST_DATA = 0x400, // constant object str e.g. 5, 10, 1.0
390
- } MEMTYPE;
391
-
392
- private:
393
- /// SVF type
394
- const SVFType* type;
395
- /// Type flags
396
- u32_t flags;
397
- /// Max offset for flexible field sensitive analysis
398
- /// maximum number of field object can be created
399
- /// minimum number is 0 (field insensitive analysis)
400
- u32_t maxOffsetLimit;
401
- /// Size of the object or number of elements
402
- u32_t elemNum;
403
-
404
- /// Byte size of object
405
- u32_t byteSize;
406
-
407
- void resetTypeForHeapStaticObj(const SVFType* type);
408
- public:
409
-
410
- /// Constructors
411
- ObjTypeInfo(const SVFType* t, u32_t max);
412
-
413
- /// Destructor
414
- virtual ~ObjTypeInfo()
415
- {
416
- }
417
-
418
- /// Get LLVM type
419
- inline const SVFType* getType() const
420
- {
421
- return type;
422
- }
423
-
424
- /// Get max field offset limit
425
- inline u32_t getMaxFieldOffsetLimit()
426
- {
427
- return maxOffsetLimit;
428
- }
429
-
430
- /// Get max field offset limit
431
- inline void setMaxFieldOffsetLimit(u32_t limit)
432
- {
433
- maxOffsetLimit = limit;
434
- }
435
-
436
- /// Set the number of elements of this object
437
- inline void setNumOfElements(u32_t num)
438
- {
439
- elemNum = num;
440
- setMaxFieldOffsetLimit(num);
441
- }
442
-
443
- /// Get the number of elements of this object
444
- inline u32_t getNumOfElements() const
445
- {
446
- return elemNum;
447
- }
448
-
449
- /// Get the byte size of this object
450
- inline u32_t getByteSizeOfObj() const
451
- {
452
- assert(isConstantByteSize() && "This Obj's byte size is not constant.");
453
- return byteSize;
454
- }
455
-
456
- /// Set the byte size of this object
457
- inline void setByteSizeOfObj(u32_t size)
458
- {
459
- byteSize = size;
460
- }
461
-
462
- /// Check if byte size is a const value
463
- inline bool isConstantByteSize() const
464
- {
465
- return byteSize != 0;
466
- }
467
-
468
- /// Flag for this object type
469
- //@{
470
- inline void setFlag(MEMTYPE mask)
471
- {
472
- flags |= mask;
473
- }
474
- inline bool hasFlag(MEMTYPE mask)
475
- {
476
- return (flags & mask) == mask;
477
- }
478
- //@}
479
-
480
- /// Object attributes
481
- //@{
482
- inline bool isFunction()
483
- {
484
- return hasFlag(FUNCTION_OBJ);
485
- }
486
- inline bool isGlobalObj()
487
- {
488
- return hasFlag(GLOBVAR_OBJ);
489
- }
490
- inline bool isStaticObj()
491
- {
492
- return hasFlag(STATIC_OBJ);
493
- }
494
- inline bool isStack()
495
- {
496
- return hasFlag(STACK_OBJ);
497
- }
498
- inline bool isHeap()
499
- {
500
- return hasFlag(HEAP_OBJ);
501
- }
502
- //@}
503
-
504
- /// Object attributes (noted that an object can be a nested compound types)
505
- /// e.g. both isStruct and isArray can return true
506
- //@{
507
- inline bool isVarStruct()
508
- {
509
- return hasFlag(VAR_STRUCT_OBJ);
510
- }
511
- inline bool isConstantStruct()
512
- {
513
- return hasFlag(CONST_STRUCT_OBJ);
514
- }
515
- inline bool isStruct()
516
- {
517
- return hasFlag(VAR_STRUCT_OBJ) || hasFlag(CONST_STRUCT_OBJ);
518
- }
519
- inline bool isVarArray()
520
- {
521
- return hasFlag(VAR_ARRAY_OBJ);
522
- }
523
- inline bool isConstantArray()
524
- {
525
- return hasFlag(CONST_ARRAY_OBJ);
526
- }
527
- inline bool isArray()
528
- {
529
- return hasFlag(VAR_ARRAY_OBJ) || hasFlag(CONST_ARRAY_OBJ);
530
- }
531
- inline bool isConstDataOrConstGlobal()
532
- {
533
- return hasFlag(CONST_GLOBAL_OBJ) || hasFlag(CONST_DATA);
534
- }
535
- inline bool isConstDataOrAggData()
536
- {
537
- return hasFlag(CONST_DATA);
538
- }
539
- //@}
540
- };
541
-
542
-
543
- } // End namespace SVF
544
-
545
- #endif /* INCLUDE_SVFIR_SYMBOLTABLEINFO_H_ */