svf-lib 1.0.2452 → 1.0.2453

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 (29) hide show
  1. package/SVF-linux-x86_64/bin/ae +0 -0
  2. package/SVF-linux-x86_64/bin/cfl +0 -0
  3. package/SVF-linux-x86_64/bin/dvf +0 -0
  4. package/SVF-linux-x86_64/bin/mta +0 -0
  5. package/SVF-linux-x86_64/bin/saber +0 -0
  6. package/SVF-linux-x86_64/bin/svf-ex +0 -0
  7. package/SVF-linux-x86_64/bin/wpa +0 -0
  8. package/SVF-linux-x86_64/include/Graphs/BasicBlockG.h +18 -4
  9. package/SVF-linux-x86_64/include/Graphs/CHG.h +12 -0
  10. package/SVF-linux-x86_64/include/Graphs/CallGraph.h +14 -2
  11. package/SVF-linux-x86_64/include/Graphs/ICFG.h +24 -8
  12. package/SVF-linux-x86_64/include/Graphs/ICFGEdge.h +1 -0
  13. package/SVF-linux-x86_64/include/Graphs/ICFGNode.h +39 -6
  14. package/SVF-linux-x86_64/include/Graphs/IRGraph.h +12 -0
  15. package/SVF-linux-x86_64/include/MemoryModel/AccessPath.h +7 -1
  16. package/SVF-linux-x86_64/include/SVF-LLVM/ICFGBuilder.h +1 -1
  17. package/SVF-linux-x86_64/include/SVF-LLVM/SVFIRBuilder.h +1 -0
  18. package/SVF-linux-x86_64/include/SVFIR/ObjTypeInfo.h +5 -0
  19. package/SVF-linux-x86_64/include/SVFIR/SVFIR.h +61 -39
  20. package/SVF-linux-x86_64/include/SVFIR/SVFStatements.h +125 -10
  21. package/SVF-linux-x86_64/include/SVFIR/SVFType.h +97 -1
  22. package/SVF-linux-x86_64/include/SVFIR/SVFValue.h +1 -0
  23. package/SVF-linux-x86_64/include/SVFIR/SVFVariables.h +164 -4
  24. package/SVF-linux-x86_64/include/Util/ExtAPI.h +1 -0
  25. package/SVF-linux-x86_64/include/Util/NodeIDAllocator.h +11 -0
  26. package/SVF-linux-x86_64/include/Util/SVFLoopAndDomInfo.h +37 -0
  27. package/SVF-linux-x86_64/lib/libSvfCore.so.3.2 +0 -0
  28. package/SVF-linux-x86_64/lib/libSvfLLVM.so.3.2 +0 -0
  29. package/package.json +1 -1
@@ -51,6 +51,7 @@ class SVFBasicBlock;
51
51
  typedef GenericEdge<SVFVar> GenericPAGEdgeTy;
52
52
  class SVFStmt : public GenericPAGEdgeTy
53
53
  {
54
+ friend class GraphDBClient;
54
55
 
55
56
  public:
56
57
  /// Types of SVFIR statements
@@ -89,8 +90,54 @@ protected:
89
90
  {
90
91
  }
91
92
 
93
+ SVFStmt(SVFVar* s, SVFVar* d, GEdgeFlag k, EdgeID eid, SVFVar* value, ICFGNode* icfgNode, bool real = true);
94
+
95
+ /**
96
+ * Set the SVF BasicBlock for the new statements, this is used when loading statements from DB
97
+ */
98
+ inline void setBasicBlock(const SVFBasicBlock* bb)
99
+ {
100
+ basicBlock = bb;
101
+ }
102
+
103
+ /**
104
+ * set the call edge lanbel counter for the new statements, this is used when loading statements from DB
105
+ */
106
+ inline void setCallEdgeLabelCounter(u64_t counter)
107
+ {
108
+ callEdgeLabelCounter = counter;
109
+ }
110
+
111
+ /**
112
+ * set the store edge lanbel counter for the new statements, this is used when loading statements from DB
113
+ */
114
+ inline void setStoreEdgeLabelCounter(u64_t counter)
115
+ {
116
+ storeEdgeLabelCounter = counter;
117
+ }
118
+
119
+ /**
120
+ * set the multi operand edge lanbel counter for the new statements, this is used when loading statements from DB
121
+ */
122
+ inline void setMultiOpndLabelCounter(u64_t counter)
123
+ {
124
+ multiOpndLabelCounter = counter;
125
+ }
126
+
127
+ /**
128
+ * Add a call site Instruction to label mapping, this is used when loading statements from DB
129
+ */
130
+ static inline void addInst2Labeled(const ICFGNode* cs, u32_t label)
131
+ {
132
+ inst2LabelMap.emplace(cs, label);
133
+ }
134
+
135
+ static inline void addVar2Labeled(const SVFVar* var, u32_t label)
136
+ {
137
+ var2LabelMap.emplace(var, label);
138
+ }
139
+
92
140
  public:
93
- static u32_t totalEdgeNum; ///< Total edge number
94
141
 
95
142
  /// Constructor
96
143
  SVFStmt(SVFVar* s, SVFVar* d, GEdgeFlag k, bool real = true);
@@ -222,6 +269,33 @@ private:
222
269
  static u64_t callEdgeLabelCounter; ///< Call site Instruction counter
223
270
  static u64_t storeEdgeLabelCounter; ///< Store Instruction counter
224
271
  static u64_t multiOpndLabelCounter; ///< MultiOpndStmt counter
272
+
273
+ public:
274
+ static inline const Inst2LabelMap* getInst2LabelMap()
275
+ {
276
+ return &inst2LabelMap;
277
+ }
278
+
279
+ static inline const Var2LabelMap* getVar2LabelMap()
280
+ {
281
+ return &var2LabelMap;
282
+ }
283
+
284
+ static inline const u64_t* getCallEdgeLabelCounter()
285
+ {
286
+ return &callEdgeLabelCounter;
287
+ }
288
+
289
+ static inline const u64_t* getStoreEdgeLabelCounter()
290
+ {
291
+ return &storeEdgeLabelCounter;
292
+ }
293
+
294
+ static inline const u64_t* getMultiOpndLabelCounter()
295
+ {
296
+ return &multiOpndLabelCounter;
297
+ }
298
+
225
299
  };
226
300
 
227
301
  /*
@@ -231,6 +305,7 @@ private:
231
305
  */
232
306
  class AssignStmt : public SVFStmt
233
307
  {
308
+ friend class GraphDBClient;
234
309
 
235
310
  private:
236
311
  AssignStmt(); ///< place holder
@@ -303,6 +378,7 @@ public:
303
378
  */
304
379
  class AddrStmt: public AssignStmt
305
380
  {
381
+ friend class GraphDBClient;
306
382
 
307
383
  private:
308
384
  AddrStmt(const AddrStmt&); ///< place holder
@@ -355,6 +431,8 @@ public:
355
431
  class CopyStmt: public AssignStmt
356
432
  {
357
433
 
434
+ friend class GraphDBClient;
435
+
358
436
  private:
359
437
  CopyStmt(const CopyStmt&); ///< place holder
360
438
  void operator=(const CopyStmt&); ///< place holder
@@ -430,6 +508,7 @@ public:
430
508
  CopyStmt(SVFVar* s, SVFVar* d, CopyKind k) : AssignStmt(s, d, SVFStmt::Copy), copyKind(k) {}
431
509
 
432
510
  virtual const std::string toString() const override;
511
+
433
512
  private:
434
513
  u32_t copyKind;
435
514
  };
@@ -439,6 +518,7 @@ private:
439
518
  */
440
519
  class StoreStmt: public AssignStmt
441
520
  {
521
+ friend class GraphDBClient;
442
522
 
443
523
  private:
444
524
  StoreStmt(const StoreStmt&); ///< place holder
@@ -465,6 +545,7 @@ public:
465
545
  StoreStmt(SVFVar* s, SVFVar* d, const ICFGNode* st);
466
546
 
467
547
  virtual const std::string toString() const override;
548
+
468
549
  };
469
550
 
470
551
  /*!
@@ -472,6 +553,7 @@ public:
472
553
  */
473
554
  class LoadStmt: public AssignStmt
474
555
  {
556
+ friend class GraphDBClient;
475
557
 
476
558
  private:
477
559
  LoadStmt(const LoadStmt&); ///< place holder
@@ -505,6 +587,8 @@ public:
505
587
  */
506
588
  class GepStmt: public AssignStmt
507
589
  {
590
+ friend class GraphDBClient;
591
+
508
592
 
509
593
  private:
510
594
  GepStmt(const GepStmt &); ///< place holder
@@ -578,6 +662,7 @@ public:
578
662
 
579
663
  virtual const std::string toString() const;
580
664
 
665
+
581
666
  };
582
667
 
583
668
 
@@ -586,6 +671,7 @@ public:
586
671
  */
587
672
  class CallPE: public AssignStmt
588
673
  {
674
+ friend class GraphDBClient;
589
675
 
590
676
  private:
591
677
  CallPE(const CallPE&); ///< place holder
@@ -641,6 +727,7 @@ public:
641
727
  */
642
728
  class RetPE: public AssignStmt
643
729
  {
730
+ friend class GraphDBClient;
644
731
 
645
732
  private:
646
733
  RetPE(const RetPE&); ///< place holder
@@ -689,6 +776,7 @@ public:
689
776
  //@}
690
777
 
691
778
  virtual const std::string toString() const override;
779
+
692
780
  };
693
781
 
694
782
  /*
@@ -696,6 +784,9 @@ public:
696
784
  */
697
785
  class MultiOpndStmt : public SVFStmt
698
786
  {
787
+ friend class GraphDBClient;
788
+
789
+
699
790
 
700
791
  public:
701
792
  typedef std::vector<SVFVar*> OPVars;
@@ -774,7 +865,7 @@ public:
774
865
  */
775
866
  class PhiStmt: public MultiOpndStmt
776
867
  {
777
-
868
+ friend class GraphDBClient;
778
869
  public:
779
870
  typedef std::vector<const ICFGNode*> OpICFGNodeVec;
780
871
 
@@ -806,8 +897,8 @@ public:
806
897
  //@}
807
898
 
808
899
  /// constructor
809
- PhiStmt(SVFVar* s, const OPVars& opnds, const OpICFGNodeVec& icfgNodes)
810
- : MultiOpndStmt(s, opnds, SVFStmt::Phi), opICFGNodes(icfgNodes)
900
+ PhiStmt(SVFVar* res, const OPVars& opnds, const OpICFGNodeVec& icfgNodes)
901
+ : MultiOpndStmt(res, opnds, SVFStmt::Phi), opICFGNodes(icfgNodes)
811
902
  {
812
903
  assert(opnds.size() == icfgNodes.size() &&
813
904
  "Numbers of operands and their ICFGNodes are not consistent?");
@@ -820,6 +911,18 @@ public:
820
911
  "Numbers of operands and their ICFGNodes are not consistent?");
821
912
  }
822
913
 
914
+ void setOpICFGNodeVec(OpICFGNodeVec& icfgNodes)
915
+ {
916
+ assert(opVars.size() == icfgNodes.size() &&
917
+ "Numbers of operands and their ICFGNodes are not consistent?");
918
+ opICFGNodes = icfgNodes;
919
+ }
920
+
921
+ inline const OpICFGNodeVec* getOpICFGNodeVec() const
922
+ {
923
+ return &opICFGNodes;
924
+ }
925
+
823
926
  /// Return the corresponding ICFGNode of this operand
824
927
  inline const ICFGNode* getOpICFGNode(u32_t op_idx) const
825
928
  {
@@ -831,6 +934,7 @@ public:
831
934
  bool isFunctionRetPhi() const;
832
935
 
833
936
  virtual const std::string toString() const override;
937
+
834
938
  };
835
939
 
836
940
  /*!
@@ -838,7 +942,7 @@ public:
838
942
  */
839
943
  class SelectStmt: public MultiOpndStmt
840
944
  {
841
-
945
+ friend class GraphDBClient;
842
946
  private:
843
947
  SelectStmt(const SelectStmt&); ///< place holder
844
948
  void operator=(const SelectStmt&); ///< place holder
@@ -867,7 +971,7 @@ public:
867
971
  //@}
868
972
 
869
973
  /// constructor
870
- SelectStmt(SVFVar* s, const OPVars& opnds, const SVFVar* cond);
974
+ SelectStmt(SVFVar* res, const OPVars& opnds, const SVFVar* cond);
871
975
  virtual const std::string toString() const override;
872
976
 
873
977
  inline const SVFVar* getCondition() const
@@ -882,6 +986,7 @@ public:
882
986
  {
883
987
  return getOpVar(1);
884
988
  }
989
+
885
990
  };
886
991
 
887
992
  /*!
@@ -889,7 +994,7 @@ public:
889
994
  */
890
995
  class CmpStmt: public MultiOpndStmt
891
996
  {
892
-
997
+ friend class GraphDBClient;
893
998
  private:
894
999
  CmpStmt(const CmpStmt&); ///< place holder
895
1000
  void operator=(const CmpStmt&); ///< place holder
@@ -956,7 +1061,7 @@ public:
956
1061
  //@}
957
1062
 
958
1063
  /// constructor
959
- CmpStmt(SVFVar* s, const OPVars& opnds, u32_t pre);
1064
+ CmpStmt(SVFVar* res, const OPVars& opnds, u32_t pre);
960
1065
 
961
1066
  u32_t getPredicate() const
962
1067
  {
@@ -964,6 +1069,7 @@ public:
964
1069
  }
965
1070
 
966
1071
  virtual const std::string toString() const override;
1072
+
967
1073
  };
968
1074
 
969
1075
  /*!
@@ -971,7 +1077,7 @@ public:
971
1077
  */
972
1078
  class BinaryOPStmt: public MultiOpndStmt
973
1079
  {
974
-
1080
+ friend class GraphDBClient;
975
1081
  private:
976
1082
  BinaryOPStmt(const BinaryOPStmt&); ///< place holder
977
1083
  void operator=(const BinaryOPStmt&); ///< place holder
@@ -1022,7 +1128,7 @@ public:
1022
1128
  //@}
1023
1129
 
1024
1130
  /// constructor
1025
- BinaryOPStmt(SVFVar* s, const OPVars& opnds, u32_t oc);
1131
+ BinaryOPStmt(SVFVar* res, const OPVars& opnds, u32_t oc);
1026
1132
 
1027
1133
  u32_t getOpcode() const
1028
1134
  {
@@ -1030,6 +1136,7 @@ public:
1030
1136
  }
1031
1137
 
1032
1138
  virtual const std::string toString() const override;
1139
+
1033
1140
  };
1034
1141
 
1035
1142
  /*!
@@ -1037,6 +1144,7 @@ public:
1037
1144
  */
1038
1145
  class UnaryOPStmt: public SVFStmt
1039
1146
  {
1147
+ friend class GraphDBClient;
1040
1148
 
1041
1149
  private:
1042
1150
  UnaryOPStmt(const UnaryOPStmt&); ///< place holder
@@ -1093,6 +1201,7 @@ public:
1093
1201
  NodeID getResID() const;
1094
1202
 
1095
1203
  virtual const std::string toString() const override;
1204
+
1096
1205
  };
1097
1206
 
1098
1207
  /*!
@@ -1100,6 +1209,7 @@ public:
1100
1209
  */
1101
1210
  class BranchStmt: public SVFStmt
1102
1211
  {
1212
+ friend class GraphDBClient;
1103
1213
 
1104
1214
  public:
1105
1215
  typedef std::vector<std::pair<const ICFGNode*, s32_t>> SuccAndCondPairVec;
@@ -1179,6 +1289,7 @@ public:
1179
1289
  }
1180
1290
  //@}
1181
1291
  virtual const std::string toString() const override;
1292
+
1182
1293
  };
1183
1294
 
1184
1295
  /*!
@@ -1186,6 +1297,7 @@ public:
1186
1297
  */
1187
1298
  class TDForkPE: public CallPE
1188
1299
  {
1300
+ friend class GraphDBClient;
1189
1301
 
1190
1302
  private:
1191
1303
  TDForkPE(const TDForkPE&); ///< place holder
@@ -1216,6 +1328,7 @@ public:
1216
1328
  }
1217
1329
 
1218
1330
  virtual const std::string toString() const;
1331
+
1219
1332
  };
1220
1333
 
1221
1334
  /*!
@@ -1223,6 +1336,7 @@ public:
1223
1336
  */
1224
1337
  class TDJoinPE: public RetPE
1225
1338
  {
1339
+ friend class GraphDBClient;
1226
1340
 
1227
1341
  private:
1228
1342
  TDJoinPE(const TDJoinPE&); ///< place holder
@@ -1253,6 +1367,7 @@ public:
1253
1367
  }
1254
1368
 
1255
1369
  virtual const std::string toString() const;
1370
+
1256
1371
  };
1257
1372
 
1258
1373
  } // End namespace SVF
@@ -46,7 +46,35 @@ class SVFPointerType;
46
46
  class StInfo
47
47
  {
48
48
 
49
+ friend class GraphDBClient;
50
+ friend class IRGraph;
51
+
52
+ protected:
53
+ StInfo (u32_t id, std::vector<u32_t> fldIdxVec, std::vector<u32_t> elemIdxVec, Map<u32_t, const SVFType*> fldIdx2TypeMap,
54
+ std::vector<const SVFType*> finfo,u32_t stride,u32_t numOfFlattenElements,u32_t numOfFlattenFields, std::vector<const SVFType*> flattenElementTypes )
55
+ :StInfoId(id), fldIdxVec(fldIdxVec), elemIdxVec(elemIdxVec), fldIdx2TypeMap(fldIdx2TypeMap), finfo(finfo), stride(stride),
56
+ numOfFlattenElements(numOfFlattenElements), numOfFlattenFields(numOfFlattenFields), flattenElementTypes(flattenElementTypes)
57
+ {
58
+
59
+ }
60
+
61
+ inline const u32_t getStinfoId() const
62
+ {
63
+ return StInfoId;
64
+ }
65
+
66
+ inline const Map<u32_t, const SVFType*>& getFldIdx2TypeMap() const
67
+ {
68
+ return fldIdx2TypeMap;
69
+ }
70
+
71
+ inline void setStinfoId(u32_t id)
72
+ {
73
+ StInfoId = id;
74
+ }
75
+
49
76
  private:
77
+ u32_t StInfoId;
50
78
  /// flattened field indices of a struct (ignoring arrays)
51
79
  std::vector<u32_t> fldIdxVec;
52
80
  /// flattened element indices including structs and arrays by considering
@@ -77,6 +105,7 @@ public:
77
105
  : stride(s), numOfFlattenElements(s), numOfFlattenFields(s)
78
106
  {
79
107
  }
108
+
80
109
  /// Destructor
81
110
  ~StInfo() = default;
82
111
 
@@ -170,6 +199,20 @@ public:
170
199
  SVFOtherTy,
171
200
  };
172
201
 
202
+ protected:
203
+
204
+ /// set svfptrty and svfi8ty when initializing SVFType from db query results
205
+ inline static void setSVFPtrType(SVFType* ptrTy)
206
+ {
207
+ svfPtrTy = ptrTy;
208
+ }
209
+
210
+ inline static void setSVFInt8Type(SVFType* i8Ty)
211
+ {
212
+ svfI8Ty = i8Ty;
213
+ }
214
+
215
+
173
216
  public:
174
217
 
175
218
  inline static SVFType* getSVFPtrType()
@@ -274,6 +317,8 @@ std::ostream& operator<<(std::ostream& os, const SVFType& type);
274
317
  class SVFPointerType : public SVFType
275
318
  {
276
319
 
320
+ friend class GraphDBClient;
321
+
277
322
  public:
278
323
  SVFPointerType(u32_t i, u32_t byteSize = 1)
279
324
  : SVFType(true, SVFPointerTy, i, byteSize)
@@ -290,10 +335,18 @@ public:
290
335
 
291
336
  class SVFIntegerType : public SVFType
292
337
  {
338
+ friend class GraphDBClient;
293
339
 
294
340
  private:
295
341
  short signAndWidth; ///< For printing
296
342
 
343
+ protected:
344
+
345
+ short getSignAndWidth() const
346
+ {
347
+ return signAndWidth;
348
+ }
349
+
297
350
  public:
298
351
  SVFIntegerType(u32_t i, u32_t byteSize = 1) : SVFType(true, SVFIntegerTy, i, byteSize) {}
299
352
  static inline bool classof(const SVFType* node)
@@ -317,11 +370,26 @@ public:
317
370
  class SVFFunctionType : public SVFType
318
371
  {
319
372
 
373
+ friend class GraphDBClient;
320
374
  private:
321
375
  const SVFType* retTy;
322
376
  std::vector<const SVFType*> params;
323
377
  bool varArg;
324
378
 
379
+ protected:
380
+ /**
381
+ * Set return type of function, this is used when loading from DB
382
+ */
383
+ const void setReturnType(const SVFType* rt)
384
+ {
385
+ retTy = rt;
386
+ }
387
+
388
+ void addParamType(const SVFType* type)
389
+ {
390
+ params.push_back(type);
391
+ }
392
+
325
393
  public:
326
394
  SVFFunctionType(u32_t i, const SVFType* rt, const std::vector<const SVFType*>& p, bool isvararg)
327
395
  : SVFType(false, SVFFunctionTy, i, 1), retTy(rt), params(p), varArg(isvararg)
@@ -342,7 +410,6 @@ public:
342
410
  return params;
343
411
  }
344
412
 
345
-
346
413
  bool isVarArg() const
347
414
  {
348
415
  return varArg;
@@ -353,6 +420,19 @@ public:
353
420
 
354
421
  class SVFStructType : public SVFType
355
422
  {
423
+ friend class GraphDBClient;
424
+
425
+ protected:
426
+
427
+ const std::string& getName() const
428
+ {
429
+ return name;
430
+ }
431
+
432
+ void addFieldsType(const SVFType* type)
433
+ {
434
+ fields.push_back(type);
435
+ }
356
436
 
357
437
  private:
358
438
  /// @brief Field for printing & debugging
@@ -376,6 +456,7 @@ public:
376
456
  {
377
457
  return name;
378
458
  }
459
+
379
460
  void setName(const std::string& structName)
380
461
  {
381
462
  name = structName;
@@ -389,10 +470,18 @@ public:
389
470
  {
390
471
  return fields;
391
472
  }
473
+
392
474
  };
393
475
 
394
476
  class SVFArrayType : public SVFType
395
477
  {
478
+ friend class GraphDBClient;
479
+
480
+ protected:
481
+ const unsigned getNumOfElement() const
482
+ {
483
+ return numOfElement;
484
+ }
396
485
 
397
486
  private:
398
487
  unsigned numOfElement; /// For printing & debugging
@@ -431,6 +520,13 @@ public:
431
520
 
432
521
  class SVFOtherType : public SVFType
433
522
  {
523
+ friend class GraphDBClient;
524
+
525
+ protected:
526
+ const std::string& getRepr() const
527
+ {
528
+ return repr;
529
+ }
434
530
 
435
531
  private:
436
532
  std::string repr; /// Field representation for printing
@@ -199,6 +199,7 @@ public:
199
199
  }
200
200
 
201
201
  const std::string valueOnlyToString() const;
202
+ const bool hasLLVMValue() const;
202
203
 
203
204
 
204
205
  protected: