svf-tools 1.0.693 → 1.0.695

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.
@@ -48,6 +48,7 @@ class SymbolTableInfo
48
48
  {
49
49
  friend class SymbolTableBuilder;
50
50
  friend class SVFIRWriter;
51
+ friend class SVFIRReader;
51
52
 
52
53
  public:
53
54
 
@@ -288,6 +289,19 @@ public:
288
289
 
289
290
  //@}
290
291
 
292
+ /// Constant reader that won't change the state of the symbol table
293
+ //@{
294
+ inline const SVFTypeSet& getSVFTypes() const
295
+ {
296
+ return svfTypes;
297
+ }
298
+
299
+ inline const Set<const StInfo*>& getStInfos() const
300
+ {
301
+ return stInfos;
302
+ }
303
+ //@}
304
+
291
305
  /// Get struct info
292
306
  //@{
293
307
  ///Get a reference to StructInfo.
@@ -329,8 +343,13 @@ public:
329
343
 
330
344
  inline void addTypeInfo(const SVFType* ty)
331
345
  {
332
- assert(!hasSVFTypeInfo(ty) && "this type info has been added before");
333
- svfTypes.insert(ty);
346
+ bool inserted = svfTypes.insert(ty).second;
347
+ assert(inserted && "this type info has been added before");
348
+ }
349
+
350
+ inline void addStInfo(StInfo* stInfo)
351
+ {
352
+ stInfos.insert(stInfo);
334
353
  }
335
354
 
336
355
  protected:
@@ -341,11 +360,15 @@ protected:
341
360
  /// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
342
361
  ObjTypeInfo* createObjTypeInfo(const SVFType* type);
343
362
 
363
+ /// (owned) All SVF Types
344
364
  /// Every type T is mapped to StInfo
345
365
  /// which contains size (fsize) , offset(foffset)
346
366
  /// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
347
367
  /// fsize[0] is always the size of the expanded struct.
348
368
  SVFTypeSet svfTypes;
369
+
370
+ /// @brief (owned) All StInfo
371
+ Set<const StInfo*> stInfos;
349
372
  };
350
373
 
351
374
 
@@ -355,6 +378,7 @@ protected:
355
378
  class MemObj
356
379
  {
357
380
  friend class SVFIRWriter;
381
+ friend class SVFIRReader;
358
382
 
359
383
  private:
360
384
  /// Type information of this object
@@ -447,6 +471,7 @@ public:
447
471
  class ObjTypeInfo
448
472
  {
449
473
  friend class SVFIRWriter;
474
+ friend class SVFIRReader;
450
475
  friend class SymbolTableBuilder;
451
476
 
452
477
  public:
@@ -135,6 +135,7 @@ public:
135
135
  static const Option<bool> ShowSVFIRValue;
136
136
  static const Option<bool> DumpICFG;
137
137
  static const Option<std::string> DumpJson;
138
+ static const Option<bool> ReadJson;
138
139
  static const Option<bool> CallGraphDotGraph;
139
140
  static const Option<bool> PAGPrint;
140
141
  static const Option<u32_t> IndirectCallLimit;
@@ -654,6 +654,55 @@ move(T &&t) noexcept
654
654
  return std::move(t);
655
655
  }
656
656
 
657
+ /// void_t is not avaiable until C++17. We define it here for C++11/14.
658
+ template <typename... Ts> struct make_void
659
+ {
660
+ typedef void type;
661
+ };
662
+ template <typename... Ts> using void_t = typename make_void<Ts...>::type;
663
+
664
+ /// @brief Type trait that checks if a type is iterable
665
+ /// (can be applied on a range-based for loop)
666
+ ///@{
667
+ template <typename T, typename = void> struct is_iterable : std::false_type {};
668
+ template <typename T>
669
+ struct is_iterable<T, void_t<decltype(std::begin(std::declval<T&>()) !=
670
+ std::end(std::declval<T&>()))>>
671
+ : std::true_type {};
672
+ template <typename T> constexpr bool is_iterable_v = is_iterable<T>::value;
673
+ ///@}
674
+
675
+ /// @brief Type trait to check if a type is a map or unordered_map.
676
+ ///@{
677
+ template <typename T> struct is_map : std::false_type {};
678
+ template <typename... Ts> struct is_map<std::map<Ts...>> : std::true_type {};
679
+ template <typename... Ts>
680
+ struct is_map<std::unordered_map<Ts...>> : std::true_type {};
681
+ template <typename... Ts> constexpr bool is_map_v = is_map<Ts...>::value;
682
+ ///@}
683
+
684
+ /// @brief Type trait to check if a type is a set or unordered_set.
685
+ ///@{
686
+ template <typename T> struct is_set : std::false_type {};
687
+ template <typename... Ts> struct is_set<std::set<Ts...>> : std::true_type {};
688
+ template <typename... Ts>
689
+ struct is_set<std::unordered_set<Ts...>> : std::true_type {};
690
+ template <typename... Ts> constexpr bool is_set_v = is_set<Ts...>::value;
691
+ ///@}
692
+
693
+ /// @brief Type trait to check if a type is vector or list.
694
+ template <typename T> struct is_sequence_container : std::false_type {};
695
+ template <typename... Ts>
696
+ struct is_sequence_container<std::vector<Ts...>> : std::true_type {};
697
+ template <typename... Ts>
698
+ struct is_sequence_container<std::deque<Ts...>> : std::true_type {};
699
+ template <typename... Ts>
700
+ struct is_sequence_container<std::list<Ts...>> : std::true_type {};
701
+ template <typename... Ts>
702
+ constexpr bool is_sequence_container_v = is_sequence_container<Ts...>::value;
703
+ ///@}
704
+
705
+
657
706
  } // End namespace SVFUtil
658
707
 
659
708
  } // End namespace SVF
@@ -217,6 +217,7 @@ inline unsigned countPopulation(T Value)
217
217
  template <unsigned ElementSize = 128> struct SparseBitVectorElement
218
218
  {
219
219
  friend class SVFIRWriter;
220
+ friend class SVFIRReader;
220
221
 
221
222
  public:
222
223
  using BitWord = unsigned long;
@@ -458,6 +459,7 @@ template <unsigned ElementSize = 128>
458
459
  class SparseBitVector
459
460
  {
460
461
  friend class SVFIRWriter;
462
+ friend class SVFIRReader;
461
463
 
462
464
  using ElementList = std::list<SparseBitVectorElement<ElementSize>>;
463
465
  using ElementListIter = typename ElementList::iterator;