svf-tools 1.0.702 → 1.0.704

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.702",
3
+ "version": "1.0.704",
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": {
@@ -1,4 +1,4 @@
1
- //===- SVFIRRW.h -- SVF IR Reader and Writer ------------------------------===//
1
+ //===- SVFFileSystem.h -- SVF IR Reader and Writer ------------------------===//
2
2
  //
3
3
  // SVF - Static Value-Flow Analysis Framework
4
4
  // SVF: Static Value-Flow Analysis
@@ -21,8 +21,8 @@
21
21
  //
22
22
  //===----------------------------------------------------------------------===//
23
23
 
24
- #ifndef INCLUDE_SVFIRRW_H_
25
- #define INCLUDE_SVFIRRW_H_
24
+ #ifndef INCLUDE_SVFFILESYSTEM_H_
25
+ #define INCLUDE_SVFFILESYSTEM_H_
26
26
 
27
27
  #include "Graphs/GenericGraph.h"
28
28
  #include "Util/SVFUtil.h"
@@ -99,6 +99,7 @@ namespace SVF
99
99
  {
100
100
  /// @brief Forward declarations.
101
101
  ///@{
102
+ class NodeIDAllocator;
102
103
  // Classes created upon SVFMoudle construction
103
104
  class SVFType;
104
105
  class SVFPointerType;
@@ -404,6 +405,7 @@ private:
404
405
 
405
406
  const char* numToStr(size_t n);
406
407
 
408
+ cJSON* toJson(const NodeIDAllocator* nodeIDAllocator);
407
409
  cJSON* toJson(const SymbolTableInfo* symTable);
408
410
  cJSON* toJson(const SVFModule* module);
409
411
  cJSON* toJson(const SVFType* type);
@@ -582,6 +584,14 @@ private:
582
584
  return root;
583
585
  }
584
586
 
587
+ /** The following 2 functions are intended to convert SparseBitVectors
588
+ * to JSON. But they're buggy. Commentting them out would enable the
589
+ * toJson(T) where is_iterable_v<T> is true. But that implementation is less
590
+ * space-efficient if the bitvector contains many elements.
591
+ * It is observed that upon construction, SVF IR bitvectors contain at most
592
+ * 1 element. In that case, we can just use the toJson(T) for iterable T
593
+ * without much space overhead.
594
+
585
595
  template <unsigned ElementSize>
586
596
  cJSON* toJson(const SparseBitVectorElement<ElementSize>& element)
587
597
  {
@@ -598,6 +608,7 @@ private:
598
608
  {
599
609
  return toJson(bv.Elements);
600
610
  }
611
+ */
601
612
 
602
613
  template <typename T, typename U> cJSON* toJson(const std::pair<T, U>& pair)
603
614
  {
@@ -652,7 +663,7 @@ template <typename T, typename = void> struct KindBaseHelper
652
663
  using type = B; \
653
664
  static inline s64_t getKind(T* p) \
654
665
  { \
655
- return p->KindGetter(); \
666
+ return {p->KindGetter()}; \
656
667
  } \
657
668
  }
658
669
  KIND_BASE(SVFType, getKind);
@@ -797,6 +808,14 @@ public:
797
808
  {
798
809
  return ptrPool.size();
799
810
  }
811
+
812
+ template <typename Set> void saveToSet(Set& set) const
813
+ {
814
+ for (T* obj : ptrPool)
815
+ {
816
+ set.insert(obj);
817
+ }
818
+ }
800
819
  };
801
820
 
802
821
  template <typename NodeTy, typename EdgeTy> class GenericGraphReader
@@ -949,6 +968,9 @@ public:
949
968
 
950
969
  class SVFModuleReader
951
970
  {
971
+ friend class SVFIRReader;
972
+
973
+ private:
952
974
  const cJSON* svfModuleFieldJson = nullptr;
953
975
  ReaderPtrPool<SVFType> svfTypePool;
954
976
  ReaderPtrPool<StInfo> stInfoPool;
@@ -1063,11 +1085,12 @@ private:
1063
1085
  SVFIR* read(const cJSON* root);
1064
1086
  const cJSON* createObjs(const cJSON* root);
1065
1087
 
1066
- void readJson(SymbolTableInfo*& symTabInfo);
1067
- void readJson(IRGraph*& graph); // IRGraph Graph
1068
- void readJson(ICFG*& icfg); // ICFG Graph
1069
- void readJson(CHGraph*& graph); // CHGraph Graph
1070
- void readJson(SVFModule*& module);
1088
+ void readJson(const cJSON* obj, NodeIDAllocator* idAllocator);
1089
+ void readJson(SymbolTableInfo* symTabInfo);
1090
+ void readJson(IRGraph* graph); // IRGraph Graph
1091
+ void readJson(ICFG* icfg); // ICFG Graph
1092
+ void readJson(CHGraph* graph); // CHGraph Graph
1093
+ void readJson(SVFModule* module);
1071
1094
 
1072
1095
  void readJson(const cJSON* obj, SVFType*& type);
1073
1096
  void readJson(const cJSON* obj, StInfo*& stInfo);
@@ -1077,7 +1100,6 @@ private:
1077
1100
  void readJson(const cJSON* obj, SVFStmt*& stmt); // IRGraph Edge
1078
1101
  void readJson(const cJSON* obj, ICFGNode*& node); // ICFG Node
1079
1102
  void readJson(const cJSON* obj, ICFGEdge*& edge); // ICFG Edge
1080
- // void readJson(const cJSON* obj, CHGraph*& graph); // CHGraph Graph
1081
1103
  void readJson(const cJSON* obj, CHNode*& node); // CHGraph Node
1082
1104
  void readJson(const cJSON* obj, CHEdge*& edge); // CHGraph Edge
1083
1105
  void readJson(const cJSON* obj, CallSite& cs); // CHGraph's csToClassMap
@@ -1093,15 +1115,24 @@ private:
1093
1115
  template <unsigned ElementSize>
1094
1116
  inline void readJson(const cJSON* obj, SparseBitVector<ElementSize>& bv)
1095
1117
  {
1096
- readJson(obj, bv.Elements);
1118
+ ABORT_IFNOT(jsonIsArray(obj), "SparseBitVector should be an array");
1119
+ jsonForEach(nObj, obj)
1120
+ {
1121
+ unsigned n;
1122
+ readJson(nObj, n);
1123
+ bv.set(n);
1124
+ }
1097
1125
  }
1098
1126
 
1127
+ /* See comment of toJson(SparseBitVectorElement) for reason of commenting
1128
+ it out.
1099
1129
  template <unsigned ElementSize>
1100
1130
  inline void readJson(const cJSON* obj,
1101
1131
  SparseBitVectorElement<ElementSize>& element)
1102
1132
  {
1103
1133
  readJson(obj, element.Bits);
1104
1134
  }
1135
+ */
1105
1136
 
1106
1137
  /// @brief Read a pointer of some child class of
1107
1138
  /// SVFType/SVFValue/SVFVar/SVFStmt/ICFGNode/ICFGEdge/CHNode/CHEdge
@@ -1299,4 +1330,4 @@ private:
1299
1330
 
1300
1331
  } // namespace SVF
1301
1332
 
1302
- #endif // !INCLUDE_SVFIRRW_H_
1333
+ #endif // !INCLUDE_SVFFILESYSTEM_H_
@@ -69,6 +69,8 @@ public:
69
69
  typedef Map<NodeOffset,NodeID> NodeOffsetMap;
70
70
  typedef Map<NodeLocationSet,NodeID> NodeLocationSetMap;
71
71
  typedef Map<const SVFValue*, NodeLocationSetMap> GepValueVarMap;
72
+ typedef std::pair<const SVFType*, std::vector<LocationSet>> SVFTypeLocSetsPair;
73
+ typedef Map<NodeID, SVFTypeLocSetsPair> TypeLocSetsMap;
72
74
  typedef Map<NodePair,NodeID> NodePairSetMap;
73
75
 
74
76
  private:
@@ -77,6 +79,7 @@ private:
77
79
  ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap; ///< Map an ICFGNode to its SVFStmts
78
80
  ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap; ///< Map an ICFGNode to its PointerAnalysis related SVFStmts
79
81
  GepValueVarMap GepValObjMap; ///< Map a pair<base,off> to a gep value node id
82
+ TypeLocSetsMap typeLocSetsMap; ///< Map an arg to its base SVFType* and all its field location sets
80
83
  NodeLocationSetMap GepObjVarMap; ///< Map a pair<base,off> to a gep obj node id
81
84
  MemObjToFieldsMap memToFieldsMap; ///< Map a mem object id to all its fields
82
85
  SVFStmtSet globSVFStmtSet; ///< Global PAGEdges without control flow information
@@ -218,6 +221,16 @@ public:
218
221
  if (edge->isPTAEdge())
219
222
  icfgNode2PTASVFStmtsMap[inst].push_back(edge);
220
223
  }
224
+ /// Add a base SVFType* and all its field location sets to an arg NodeId
225
+ inline void addToTypeLocSetsMap(NodeID argId, SVFTypeLocSetsPair& locSets)
226
+ {
227
+ typeLocSetsMap[argId]=locSets;
228
+ }
229
+ /// Given an arg NodeId, get its base SVFType* and all its field location sets
230
+ inline SVFTypeLocSetsPair& getTypeLocSetsMap(NodeID argId)
231
+ {
232
+ return typeLocSetsMap[argId];
233
+ }
221
234
  /// Get global PAGEdges (not in a procedure)
222
235
  inline SVFStmtSet& getGlobalSVFStmtSet()
223
236
  {
@@ -40,8 +40,6 @@ namespace SVF
40
40
 
41
41
  class SVFModule
42
42
  {
43
- friend class SVFModuleWrite;
44
- friend class SVFModuleRead;
45
43
  friend class SVFIRWriter;
46
44
  friend class SVFIRReader;
47
45
 
@@ -79,8 +77,6 @@ public:
79
77
 
80
78
  ~SVFModule();
81
79
 
82
- void writeToJson(const std::string& filePath);
83
-
84
80
  static inline void setPagFromTXT(const std::string& txt)
85
81
  {
86
82
  pagReadFromTxt = txt;
@@ -130,8 +130,6 @@ typedef Set<VersionedVar> VersionedVarSet;
130
130
  */
131
131
  class StInfo
132
132
  {
133
- friend class SVFModuleWrite;
134
- friend class SVFModuleRead;
135
133
  friend class SVFIRWriter;
136
134
  friend class SVFIRReader;
137
135
 
@@ -242,8 +240,6 @@ public:
242
240
 
243
241
  class SVFType
244
242
  {
245
- friend class SVFModuleWrite;
246
- friend class SVFModuleRead;
247
243
  friend class SVFIRWriter;
248
244
  friend class SVFIRReader;
249
245
 
@@ -329,8 +325,6 @@ public:
329
325
 
330
326
  class SVFPointerType : public SVFType
331
327
  {
332
- friend class SVFModuleWrite;
333
- friend class SVFModuleRead;
334
328
  friend class SVFIRWriter;
335
329
  friend class SVFIRReader;
336
330
 
@@ -364,8 +358,6 @@ public:
364
358
 
365
359
  class SVFFunctionType : public SVFType
366
360
  {
367
- friend class SVFModuleWrite;
368
- friend class SVFModuleRead;
369
361
  friend class SVFIRWriter;
370
362
  friend class SVFIRReader;
371
363
 
@@ -49,8 +49,6 @@ class SVFType;
49
49
 
50
50
  class SVFLoopAndDomInfo
51
51
  {
52
- friend class SVFModuleWrite;
53
- friend class SVFModuleRead;
54
52
  friend class SVFIRWriter;
55
53
  friend class SVFIRReader;
56
54
  public:
@@ -151,8 +149,6 @@ public:
151
149
 
152
150
  class SVFValue
153
151
  {
154
- friend class SVFModuleWrite;
155
- friend class SVFModuleRead;
156
152
  friend class SVFIRWriter;
157
153
  friend class SVFIRReader;
158
154
  friend class LLVMModuleSet;
@@ -268,8 +264,6 @@ public:
268
264
  class SVFFunction : public SVFValue
269
265
  {
270
266
  friend class LLVMModuleSet;
271
- friend class SVFModuleWrite;
272
- friend class SVFModuleRead;
273
267
  friend class SVFIRWriter;
274
268
  friend class SVFIRReader;
275
269
 
@@ -486,8 +480,6 @@ public:
486
480
  class SVFBasicBlock : public SVFValue
487
481
  {
488
482
  friend class LLVMModuleSet;
489
- friend class SVFModuleWrite;
490
- friend class SVFModuleRead;
491
483
  friend class SVFIRWriter;
492
484
  friend class SVFIRReader;
493
485
 
@@ -588,8 +580,6 @@ public:
588
580
 
589
581
  class SVFInstruction : public SVFValue
590
582
  {
591
- friend class SVFModuleWrite;
592
- friend class SVFModuleRead;
593
583
  friend class SVFIRWriter;
594
584
  friend class SVFIRReader;
595
585
  public:
@@ -657,8 +647,6 @@ public:
657
647
 
658
648
  class SVFCallInst : public SVFInstruction
659
649
  {
660
- friend class SVFModuleWrite;
661
- friend class SVFModuleRead;
662
650
  friend class SVFIRWriter;
663
651
  friend class SVFIRReader;
664
652
  friend class LLVMModuleSet;
@@ -733,8 +721,6 @@ public:
733
721
 
734
722
  class SVFVirtualCallInst : public SVFCallInst
735
723
  {
736
- friend class SVFModuleWrite;
737
- friend class SVFModuleRead;
738
724
  friend class SVFIRWriter;
739
725
  friend class SVFIRReader;
740
726
  friend class LLVMModuleSet;
@@ -793,8 +779,6 @@ public:
793
779
 
794
780
  class SVFConstant : public SVFValue
795
781
  {
796
- friend class SVFModuleWrite;
797
- friend class SVFModuleRead;
798
782
  friend class SVFIRWriter;
799
783
  friend class SVFIRReader;
800
784
  public:
@@ -817,8 +801,6 @@ public:
817
801
 
818
802
  class SVFGlobalValue : public SVFConstant
819
803
  {
820
- friend class SVFModuleWrite;
821
- friend class SVFModuleRead;
822
804
  friend class SVFIRWriter;
823
805
  friend class SVFIRReader;
824
806
  friend class LLVMModuleSet;
@@ -857,8 +839,6 @@ public:
857
839
 
858
840
  class SVFArgument : public SVFValue
859
841
  {
860
- friend class SVFModuleWrite;
861
- friend class SVFModuleRead;
862
842
  friend class SVFIRWriter;
863
843
  friend class SVFIRReader;
864
844
  private:
@@ -898,8 +878,6 @@ public:
898
878
 
899
879
  class SVFConstantData : public SVFConstant
900
880
  {
901
- friend class SVFModuleWrite;
902
- friend class SVFModuleRead;
903
881
  friend class SVFIRWriter;
904
882
  friend class SVFIRReader;
905
883
  public:
@@ -929,8 +907,6 @@ public:
929
907
 
930
908
  class SVFConstantInt : public SVFConstantData
931
909
  {
932
- friend class SVFModuleWrite;
933
- friend class SVFModuleRead;
934
910
  friend class SVFIRWriter;
935
911
  friend class SVFIRReader;
936
912
  private:
@@ -965,8 +941,6 @@ public:
965
941
 
966
942
  class SVFConstantFP : public SVFConstantData
967
943
  {
968
- friend class SVFModuleWrite;
969
- friend class SVFModuleRead;
970
944
  friend class SVFIRWriter;
971
945
  friend class SVFIRReader;
972
946
  private:
@@ -994,8 +968,6 @@ public:
994
968
 
995
969
  class SVFConstantNullPtr : public SVFConstantData
996
970
  {
997
- friend class SVFModuleWrite;
998
- friend class SVFModuleRead;
999
971
  friend class SVFIRWriter;
1000
972
  friend class SVFIRReader;
1001
973
 
@@ -1017,8 +989,6 @@ public:
1017
989
 
1018
990
  class SVFBlackHoleValue : public SVFConstantData
1019
991
  {
1020
- friend class SVFModuleWrite;
1021
- friend class SVFModuleRead;
1022
992
  friend class SVFIRWriter;
1023
993
  friend class SVFIRReader;
1024
994
 
@@ -1040,8 +1010,6 @@ public:
1040
1010
 
1041
1011
  class SVFOtherValue : public SVFValue
1042
1012
  {
1043
- friend class SVFModuleWrite;
1044
- friend class SVFModuleRead;
1045
1013
  friend class SVFIRWriter;
1046
1014
  friend class SVFIRReader;
1047
1015
  public:
@@ -1061,8 +1029,6 @@ public:
1061
1029
  */
1062
1030
  class SVFMetadataAsValue : public SVFOtherValue
1063
1031
  {
1064
- friend class SVFModuleWrite;
1065
- friend class SVFModuleRead;
1066
1032
  friend class SVFIRWriter;
1067
1033
  friend class SVFIRReader;
1068
1034
  public:
@@ -306,6 +306,9 @@ public:
306
306
  // Assuming hasStatic(F), does (F) have a second static Y where X -> Y?
307
307
  bool has_static2(const SVFFunction *F);
308
308
 
309
+ // Does (F) have a memset_like or memcpy_like operation?
310
+ bool is_memset_or_memcpy(const SVFFunction *F);
311
+
309
312
  // Does (F) allocate a new object and return it?
310
313
  bool is_alloc(const SVFFunction *F);
311
314
 
@@ -5096,13 +5096,6 @@
5096
5096
  "dst": "Ret"
5097
5097
  }
5098
5098
  },
5099
- "dlsym": {
5100
- "return": "void *",
5101
- "arguments": "(void *, const char *)",
5102
- "type": "EFT_L_A1__FunPtr",
5103
- "overwrite_app_function": 0,
5104
- "funptr_ops": ["Arg1"]
5105
- },
5106
5099
  "bcopy": {
5107
5100
  "return": "void",
5108
5101
  "arguments": "(const void *, void *, size_t)",
@@ -19,6 +19,9 @@ class BVDataPTAImpl;
19
19
  /// all symbols have been allocated through endSymbolAllocation.
20
20
  class NodeIDAllocator
21
21
  {
22
+ friend class SVFIRWriter;
23
+ friend class SVFIRReader;
24
+
22
25
  public:
23
26
  /// Allocation strategy to use.
24
27
  enum Strategy
@@ -299,6 +299,12 @@ inline bool isExtCall(const SVFFunction* fun)
299
299
  return fun && ExtAPI::getExtAPI()->is_ext(fun);
300
300
  }
301
301
 
302
+ // Return true if extern function contains memset_like or memcpy_like operations
303
+ inline bool isMemSetOrCpyExtFun(const SVFFunction* fun)
304
+ {
305
+ return fun && ExtAPI::getExtAPI()->is_memset_or_memcpy(fun);
306
+ }
307
+
302
308
  /// Return true if the call is a heap allocator/reallocator
303
309
  //@{
304
310
  /// note that these two functions are not suppose to be used externally
@@ -1,4 +1,4 @@
1
- #include "SVFIR/SVFIRRW.h"
1
+ #include "SVFIR/SVFFileSystem.h"
2
2
  #include "Graphs/CHG.h"
3
3
  #include "SVFIR/SVFIR.h"
4
4
  #include "Util/CommandLine.h"
@@ -1022,6 +1022,8 @@ SVFIRWriter::autoCStr SVFIRWriter::generateJsonString()
1022
1022
  SVFIRWriter::autoJSON SVFIRWriter::generateJson()
1023
1023
  {
1024
1024
  const IRGraph* const irGraph = svfIR;
1025
+ NodeIDAllocator* nodeIDAllocator = NodeIDAllocator::allocator;
1026
+ assert(nodeIDAllocator && "NodeIDAllocator is not initialized?");
1025
1027
 
1026
1028
  cJSON* root = jsonCreateObject();
1027
1029
  #define F(field) JSON_WRITE_FIELD(root, svfIR, field)
@@ -1033,6 +1035,7 @@ SVFIRWriter::autoJSON SVFIRWriter::generateJson()
1033
1035
  F(icfgNode2SVFStmtsMap);
1034
1036
  F(icfgNode2PTASVFStmtsMap);
1035
1037
  F(GepValObjMap);
1038
+ F(typeLocSetsMap);
1036
1039
  F(GepObjVarMap);
1037
1040
  F(memToFieldsMap);
1038
1041
  F(globSVFStmtSet);
@@ -1045,6 +1048,7 @@ SVFIRWriter::autoJSON SVFIRWriter::generateJson()
1045
1048
  F(funPtrToCallSitesMap);
1046
1049
  F(candidatePointers);
1047
1050
  F(callSiteSet);
1051
+ jsonAddJsonableToObject(root, FIELD_NAME_ITEM(nodeIDAllocator));
1048
1052
  #undef F
1049
1053
 
1050
1054
  return {root, cJSON_Delete};
@@ -1237,6 +1241,19 @@ cJSON* SVFIRWriter::toJson(const LocationSet& ls)
1237
1241
  return root;
1238
1242
  }
1239
1243
 
1244
+ cJSON* SVFIRWriter::toJson(const NodeIDAllocator* nodeIDAllocator)
1245
+ {
1246
+ ENSURE_NOT_VISITED(nodeIDAllocator);
1247
+
1248
+ cJSON* root = jsonCreateObject();
1249
+ JSON_WRITE_FIELD(root, nodeIDAllocator, strategy);
1250
+ JSON_WRITE_FIELD(root, nodeIDAllocator, numObjects);
1251
+ JSON_WRITE_FIELD(root, nodeIDAllocator, numValues);
1252
+ JSON_WRITE_FIELD(root, nodeIDAllocator, numSymbols);
1253
+ JSON_WRITE_FIELD(root, nodeIDAllocator, numNodes);
1254
+ return root;
1255
+ }
1256
+
1240
1257
  cJSON* SVFIRWriter::toJson(const SymbolTableInfo* symTable)
1241
1258
  {
1242
1259
  ENSURE_NOT_VISITED(symTable);
@@ -1323,14 +1340,15 @@ SVFIR* SVFIRReader::read(const cJSON* root)
1323
1340
  auto svfModule = new SVFModule();
1324
1341
  auto icfg = new ICFG();
1325
1342
  auto chgraph = new CHGraph(svfModule);
1326
- auto symboTableInfo = SymbolTableInfo::SymbolInfo();
1343
+ auto symInfo = SymbolTableInfo::SymbolInfo();
1344
+ symInfo->mod = svfModule;
1327
1345
 
1328
1346
  svfIR->svfModule = svfModule;
1329
1347
  svfIR->icfg = icfg;
1330
1348
  svfIR->chgraph = chgraph;
1331
1349
 
1332
1350
  #define F(field) JSON_READ_FIELD_FWD(svfirField, svfIR, field)
1333
- readJson(symboTableInfo);
1351
+ readJson(symInfo);
1334
1352
  readJson(irGraph);
1335
1353
  readJson(icfg);
1336
1354
  readJson(chgraph);
@@ -1339,6 +1357,7 @@ SVFIR* SVFIRReader::read(const cJSON* root)
1339
1357
  F(icfgNode2SVFStmtsMap);
1340
1358
  F(icfgNode2PTASVFStmtsMap);
1341
1359
  F(GepValObjMap);
1360
+ F(typeLocSetsMap);
1342
1361
  F(GepObjVarMap);
1343
1362
  F(memToFieldsMap);
1344
1363
  F(globSVFStmtSet);
@@ -1352,6 +1371,9 @@ SVFIR* SVFIRReader::read(const cJSON* root)
1352
1371
  F(candidatePointers);
1353
1372
  F(callSiteSet);
1354
1373
  #undef F
1374
+ assert(!NodeIDAllocator::allocator && "NodeIDAllocator should be NULL");
1375
+ auto nodeIDAllocator = NodeIDAllocator::get();
1376
+ JSON_READ_OBJ_FWD(svfirField, nodeIDAllocator);
1355
1377
 
1356
1378
  return svfIR;
1357
1379
  }
@@ -1636,7 +1658,26 @@ SVFStmt* SVFIRReader::createPAGEdge(GEdgeKind kind)
1636
1658
  }
1637
1659
  }
1638
1660
 
1639
- void SVFIRReader::readJson(SymbolTableInfo*& symTabInfo)
1661
+ void SVFIRReader::readJson(const cJSON* obj, NodeIDAllocator* idAllocator)
1662
+ {
1663
+ assert(idAllocator && "idAllocator should be nonempty");
1664
+
1665
+ ABORT_IFNOT(jsonIsObject(obj), "Expect object for " << JSON_KEY(obj));
1666
+ obj = obj->child;
1667
+
1668
+ JSON_DEF_READ_FWD(obj, int, strategy);
1669
+ static_assert(sizeof(idAllocator->strategy) == sizeof(strategy),
1670
+ "idAllocator->strategy should be represented by int");
1671
+ idAllocator->strategy = static_cast<NodeIDAllocator::Strategy>(strategy);
1672
+ JSON_READ_FIELD_FWD(obj, idAllocator, numObjects);
1673
+ JSON_READ_FIELD_FWD(obj, idAllocator, numValues);
1674
+ JSON_READ_FIELD_FWD(obj, idAllocator, numSymbols);
1675
+ JSON_READ_FIELD_FWD(obj, idAllocator, numNodes);
1676
+
1677
+ ABORT_IFNOT(!obj, "Extra field " << JSON_KEY(obj) << " in NodeIDAllocator");
1678
+ }
1679
+
1680
+ void SVFIRReader::readJson(SymbolTableInfo* symTabInfo)
1640
1681
  {
1641
1682
  const cJSON* obj = symTableReader.getFieldJson();
1642
1683
  #define F(field) JSON_READ_FIELD_FWD(obj, symTabInfo, field)
@@ -1654,7 +1695,7 @@ void SVFIRReader::readJson(SymbolTableInfo*& symTabInfo)
1654
1695
  ABORT_IFNOT(!obj, "Extra field " << JSON_KEY(obj) << " in SymbolTableInfo");
1655
1696
  }
1656
1697
 
1657
- void SVFIRReader::readJson(IRGraph*& graph)
1698
+ void SVFIRReader::readJson(IRGraph* graph)
1658
1699
  {
1659
1700
  assert(SymbolTableInfo::symInfo && "SymbolTableInfo should be nonempty");
1660
1701
  assert(graph->symInfo == SymbolTableInfo::SymbolInfo() && "symInfo differ");
@@ -1679,7 +1720,7 @@ void SVFIRReader::readJson(IRGraph*& graph)
1679
1720
  ABORT_IFNOT(nullit->second.empty(), "valueToEdgeMap[NULL] should be empty");
1680
1721
  }
1681
1722
 
1682
- void SVFIRReader::readJson(ICFG*& icfg)
1723
+ void SVFIRReader::readJson(ICFG* icfg)
1683
1724
  {
1684
1725
  icfgReader.saveToGenericGraph(icfg);
1685
1726
  const cJSON* obj = icfgReader.getFieldJson();
@@ -1695,7 +1736,7 @@ void SVFIRReader::readJson(ICFG*& icfg)
1695
1736
  #undef F
1696
1737
  }
1697
1738
 
1698
- void SVFIRReader::readJson(CHGraph*& graph)
1739
+ void SVFIRReader::readJson(CHGraph* graph)
1699
1740
  {
1700
1741
  chGraphReader.saveToGenericGraph(graph);
1701
1742
  const cJSON* obj = chGraphReader.getFieldJson();
@@ -1714,9 +1755,14 @@ void SVFIRReader::readJson(CHGraph*& graph)
1714
1755
  #undef F
1715
1756
  }
1716
1757
 
1717
- void SVFIRReader::readJson(SVFModule*& module)
1758
+ void SVFIRReader::readJson(SVFModule* module)
1718
1759
  {
1719
1760
  const cJSON* obj = svfModuleReader.getFieldJson();
1761
+ auto symInfo = SymbolTableInfo::symInfo;
1762
+ assert(symInfo && "SymbolTableInfo should be non-NULL");
1763
+ svfModuleReader.svfTypePool.saveToSet(symInfo->svfTypes);
1764
+ svfModuleReader.stInfoPool.saveToSet(symInfo->stInfos);
1765
+
1720
1766
  #define F(field) JSON_READ_FIELD_FWD(obj, module, field)
1721
1767
  F(pagReadFromTxt);
1722
1768
  F(moduleIdentifier);
@@ -22,7 +22,6 @@
22
22
 
23
23
 
24
24
  #include "SVFIR/SVFModule.h"
25
- #include "SVFIR/SVFModuleRW.h"
26
25
  #include "SVFIR/SymbolTableInfo.h"
27
26
  #include "Util/SVFUtil.h"
28
27
  #include "Util/SVFStat.h"
@@ -54,9 +53,3 @@ const SVFFunction* SVFModule::getSVFFunction(const std::string& name)
54
53
  }
55
54
  return nullptr;
56
55
  }
57
-
58
- void SVFModule::writeToJson(const std::string& filePath)
59
- {
60
- if (!filePath.empty())
61
- SVFModuleWrite(this, filePath);
62
- }
@@ -443,6 +443,13 @@ bool ExtAPI::has_static2(const SVFFunction* F)
443
443
  return t == EFT_STAT2;
444
444
  }
445
445
 
446
+ bool ExtAPI::is_memset_or_memcpy(const SVFFunction* F)
447
+ {
448
+ ExtAPI::extType t = get_type(F);
449
+ return t == EFT_L_A0__A0R_A1 || t == EFT_L_A0__A0R_A1R || t == EFT_A1R_A0R || t == EFT_A3R_A1R_NS
450
+ || t == EFT_STD_RB_TREE_INSERT_AND_REBALANCE || t == EFT_L_A0__A1_A0;
451
+ }
452
+
446
453
  bool ExtAPI::is_alloc(const SVFFunction* F)
447
454
  {
448
455
  ExtAPI::extType t = get_type(F);
@@ -235,9 +235,10 @@ protected:
235
235
 
236
236
  /// Handle external call
237
237
  //@{
238
- virtual void parseOperations(std::vector<ExtAPI::Operation> &operations, CallBase* cs);
239
- virtual void handleExtCall(CallBase* cs, const Function *F);
240
- void addComplexConsForExt(const Value* D, const Value* S, const Value* sz);
238
+ virtual void parseOperations(std::vector<ExtAPI::Operation> &operations, const SVFCallInst* svfcall);
239
+ virtual void preProcessExtCall(CallBase* cs);
240
+ virtual void handleExtCall(SVFInstruction* svfinst, const SVFFunction* svfcallee);
241
+ void addComplexConsForExt(const SVFValue* D, const SVFValue* S, const SVFValue* sz);
241
242
  //@}
242
243
 
243
244
  /// Set current basic block in order to keep track of control flow information
@@ -281,7 +282,7 @@ protected:
281
282
  return nullPtr;
282
283
  }
283
284
 
284
- NodeID getGepValVar(const Value* val, const LocationSet& ls, const SVFType* baseType);
285
+ NodeID getGepValVar(const SVFValue* val, const LocationSet& ls, const SVFType* baseType);
285
286
 
286
287
  void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
287
288
 
@@ -31,7 +31,6 @@
31
31
  #include <algorithm>
32
32
  #include "Util/Options.h"
33
33
  #include "SVFIR/SVFModule.h"
34
- #include "SVFIR/SVFModuleRW.h"
35
34
  #include "Util/SVFUtil.h"
36
35
  #include "SVF-LLVM/BasicTypes.h"
37
36
  #include "SVF-LLVM/LLVMUtil.h"