svf-lib 1.0.1328 → 1.0.1330

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.
@@ -89,7 +89,7 @@ private:
89
89
  void collectCxtInsenEdgeForRecur(PointerAnalysis* pta, const SVFG* svfg,SVFGEdgeSet& insensitveEdges);
90
90
  void collectCxtInsenEdgeForVFCycle(PointerAnalysis* pta, const SVFG* svfg,const SVFGSCC* svfgSCC, SVFGEdgeSet& insensitveEdges);
91
91
 
92
- PointerAnalysis* _pta; ///< pointer analysis to be executed.
92
+ std::unique_ptr<PointerAnalysis> _pta; ///< pointer analysis to be executed.
93
93
  DDAClient* _client; ///< DDA client used
94
94
 
95
95
  };
@@ -158,7 +158,7 @@ public:
158
158
  //@}
159
159
 
160
160
  /// Union pts
161
- virtual bool unionDDAPts(LocDPItem dpm, const PointsTo& targetPts) override
161
+ bool unionDDAPts(LocDPItem dpm, const PointsTo& targetPts) override
162
162
  {
163
163
  if (isTopLevelPtrStmt(dpm.getLoc())) return unionPts(dpm.getCurNodeID(), targetPts);
164
164
  else return dpmToADCPtSetMap[dpm] |= targetPts;
@@ -81,7 +81,7 @@ public:
81
81
  ICFG();
82
82
 
83
83
  /// Destructor
84
- virtual ~ICFG();
84
+ ~ICFG() override;
85
85
 
86
86
  /// Get a ICFG node
87
87
  inline ICFGNode* getICFGNode(NodeID id) const
@@ -102,14 +102,14 @@ protected:
102
102
  FunctionToFormalINsMapTy funToFormalINMap;
103
103
  FunctionToFormalOUTsMapTy funToFormalOUTMap;
104
104
  SVFGStat * stat;
105
- MemSSA* mssa;
105
+ std::unique_ptr<MemSSA> mssa;
106
106
  PointerAnalysis* pta;
107
107
 
108
108
  /// Clean up memory
109
109
  void destroy();
110
110
 
111
111
  /// Constructor
112
- SVFG(MemSSA* mssa, VFGK k);
112
+ SVFG(std::unique_ptr<MemSSA> mssa, VFGK k);
113
113
 
114
114
  /// Start building SVFG
115
115
  virtual void buildSVFG();
@@ -130,14 +130,13 @@ public:
130
130
  /// Clear MSSA
131
131
  inline void clearMSSA()
132
132
  {
133
- delete mssa;
134
133
  mssa = nullptr;
135
134
  }
136
135
 
137
136
  /// Get SVFG memory SSA
138
137
  inline MemSSA* getMSSA() const
139
138
  {
140
- return mssa;
139
+ return mssa.get();
141
140
  }
142
141
 
143
142
  /// Get Pointer Analysis
@@ -61,12 +61,12 @@ class SVFGOPT : public SVFG
61
61
 
62
62
  public:
63
63
  /// Constructor
64
- SVFGOPT(MemSSA* _mssa, VFGK kind) : SVFG(_mssa, kind)
64
+ SVFGOPT(std::unique_ptr<MemSSA> mssa, VFGK kind) : SVFG(std::move(mssa), kind)
65
65
  {
66
66
  keepAllSelfCycle = keepContextSelfCycle = keepActualOutFormalIn = false;
67
67
  }
68
68
  /// Destructor
69
- virtual ~SVFGOPT() {}
69
+ ~SVFGOPT() override = default;
70
70
 
71
71
  inline void setTokeepActualOutFormalIn()
72
72
  {
@@ -82,11 +82,11 @@ public:
82
82
  }
83
83
 
84
84
  protected:
85
- virtual void buildSVFG();
85
+ void buildSVFG() override;
86
86
 
87
87
  /// Connect SVFG nodes between caller and callee for indirect call sites
88
88
  //@{
89
- virtual inline void connectAParamAndFParam(const PAGNode* cs_arg, const PAGNode* fun_arg, const CallICFGNode*, CallSiteID csId, SVFGEdgeSetTy& edges)
89
+ inline void connectAParamAndFParam(const PAGNode* cs_arg, const PAGNode* fun_arg, const CallICFGNode*, CallSiteID csId, SVFGEdgeSetTy& edges) override
90
90
  {
91
91
  NodeID phiId = getDef(fun_arg);
92
92
  SVFGEdge* edge = addCallEdge(getDef(cs_arg), phiId, csId);
@@ -98,7 +98,7 @@ protected:
98
98
  }
99
99
  }
100
100
  /// Connect formal-ret and actual ret
101
- virtual inline void connectFRetAndARet(const PAGNode* fun_ret, const PAGNode* cs_ret, CallSiteID csId, SVFGEdgeSetTy& edges)
101
+ inline void connectFRetAndARet(const PAGNode* fun_ret, const PAGNode* cs_ret, CallSiteID csId, SVFGEdgeSetTy& edges) override
102
102
  {
103
103
  NodeID phiId = getDef(cs_ret);
104
104
  NodeID retdef = getDef(fun_ret);
@@ -117,7 +117,7 @@ protected:
117
117
  }
118
118
  }
119
119
  /// Connect actual-in and formal-in
120
- virtual inline void connectAInAndFIn(const ActualINSVFGNode* actualIn, const FormalINSVFGNode* formalIn, CallSiteID csId, SVFGEdgeSetTy& edges)
120
+ inline void connectAInAndFIn(const ActualINSVFGNode* actualIn, const FormalINSVFGNode* formalIn, CallSiteID csId, SVFGEdgeSetTy& edges) override
121
121
  {
122
122
  NodeBS intersection = actualIn->getPointsTo();
123
123
  intersection &= formalIn->getPointsTo();
@@ -130,7 +130,7 @@ protected:
130
130
  }
131
131
  }
132
132
  /// Connect formal-out and actual-out
133
- virtual inline void connectFOutAndAOut(const FormalOUTSVFGNode* formalOut, const ActualOUTSVFGNode* actualOut, CallSiteID csId, SVFGEdgeSetTy& edges)
133
+ inline void connectFOutAndAOut(const FormalOUTSVFGNode* formalOut, const ActualOUTSVFGNode* actualOut, CallSiteID csId, SVFGEdgeSetTy& edges) override
134
134
  {
135
135
  NodeBS intersection = formalOut->getPointsTo();
136
136
  intersection &= actualOut->getPointsTo();
@@ -154,6 +154,8 @@ private:
154
154
  MRSet varKills;
155
155
  //@}
156
156
 
157
+ std::vector<std::unique_ptr<MRVer>> usedMRVers;
158
+
157
159
  /// Release the memory
158
160
  void destroy();
159
161
 
@@ -49,27 +49,18 @@ public:
49
49
  typedef SVFG::SVFGEdgeSetTy SVFGEdgeSet;
50
50
 
51
51
  /// Constructor
52
- SVFGBuilder(bool _SVFGWithIndCall = false): svfg(nullptr), SVFGWithIndCall(_SVFGWithIndCall) {}
52
+ explicit SVFGBuilder(bool _SVFGWithIndCall = false): svfg(nullptr), SVFGWithIndCall(_SVFGWithIndCall) {}
53
53
 
54
54
  /// Destructor
55
- virtual ~SVFGBuilder() {}
56
-
57
- static SVFG* globalSvfg;
55
+ virtual ~SVFGBuilder() = default;
58
56
 
59
57
  SVFG* buildPTROnlySVFG(BVDataPTAImpl* pta);
60
58
  SVFG* buildFullSVFG(BVDataPTAImpl* pta);
61
59
 
62
- /// Clean up
63
- static void releaseSVFG()
64
- {
65
- if (globalSvfg)
66
- delete globalSvfg;
67
- globalSvfg = nullptr;
68
- }
69
60
  /// Get SVFG instance
70
61
  inline SVFG* getSVFG() const
71
62
  {
72
- return svfg;
63
+ return svfg.get();
73
64
  }
74
65
 
75
66
  /// Mark feasible VF edge by removing it from set vfEdgesAtIndCallSite
@@ -85,7 +76,7 @@ public:
85
76
  }
86
77
 
87
78
  /// Build Memory SSA
88
- virtual MemSSA* buildMSSA(BVDataPTAImpl* pta, bool ptrOnlyMSSA);
79
+ virtual std::unique_ptr<MemSSA> buildMSSA(BVDataPTAImpl* pta, bool ptrOnlyMSSA);
89
80
 
90
81
  protected:
91
82
  /// Create a DDA SVFG. By default actualOut and FormalIN are removed, unless withAOFI is set true.
@@ -97,7 +88,7 @@ protected:
97
88
 
98
89
  /// SVFG Edges connected at indirect call/ret sites
99
90
  SVFGEdgeSet vfEdgesAtIndCallSite;
100
- SVFG* svfg;
91
+ std::unique_ptr<SVFG> svfg;
101
92
  /// SVFG with precomputed indirect call edges
102
93
  bool SVFGWithIndCall;
103
94
  };
@@ -89,8 +89,8 @@ public:
89
89
  }
90
90
  private:
91
91
  ThreadCallGraph* tcg;
92
- TCT* tct;
93
- MTAStat* stat;
92
+ std::unique_ptr<TCT> tct;
93
+ std::unique_ptr<MTAStat> stat;
94
94
  MHP* mhp;
95
95
  LockAnalysis* lsa;
96
96
  };
@@ -234,16 +234,16 @@ public:
234
234
  typedef typename MutablePTData<Key, KeySet, Data, DataSet>::PtsMap PtsMap;
235
235
 
236
236
  /// Constructor
237
- MutableDiffPTData(bool reversePT = true, PTDataTy ty = PTDataTy::Diff) : BaseDiffPTData(reversePT, ty), mutPTData(reversePT) { }
237
+ explicit MutableDiffPTData(bool reversePT = true, PTDataTy ty = PTDataTy::Diff) : BaseDiffPTData(reversePT, ty), mutPTData(reversePT) { }
238
238
 
239
- virtual ~MutableDiffPTData() { }
239
+ ~MutableDiffPTData() override = default;
240
240
 
241
241
  virtual inline const PtsMap& getPtsMap() const
242
242
  {
243
243
  return mutPTData.getPtsMap();
244
244
  }
245
245
 
246
- virtual inline void clear() override
246
+ inline void clear() override
247
247
  {
248
248
  mutPTData.clear();
249
249
  }
@@ -44,7 +44,7 @@ public:
44
44
  public:
45
45
  PersistentPointsToCache(void) : idCounter(1)
46
46
  {
47
- idToPts.push_back(new Data());
47
+ idToPts.push_back(std::make_unique<Data>());
48
48
  ptsToId[Data()] = emptyPointsToId();
49
49
 
50
50
  initStats();
@@ -53,7 +53,6 @@ public:
53
53
  /// Clear the cache.
54
54
  void clear()
55
55
  {
56
- for (const Data *d : idToPts) delete d;
57
56
  idToPts.clear();
58
57
  ptsToId.clear();
59
58
 
@@ -69,7 +68,7 @@ public:
69
68
 
70
69
  // Put the empty data back in.
71
70
  ptsToId[Data()] = emptyPointsToId();
72
- idToPts.push_back(new Data());
71
+ idToPts.push_back(std::make_unique<Data>());
73
72
 
74
73
  idCounter = 1;
75
74
  // Cache is empty...
@@ -79,7 +78,7 @@ public:
79
78
  /// Remaps all points-to sets stored in the cache to the current mapping.
80
79
  void remapAllPts(void)
81
80
  {
82
- for (Data *d : idToPts) d->checkAndRemap();
81
+ for (auto &d : idToPts) d->checkAndRemap();
83
82
 
84
83
  // Rebuild ptsToId from idToPts.
85
84
  ptsToId.clear();
@@ -96,7 +95,7 @@ public:
96
95
 
97
96
  // Otherwise, insert it.
98
97
  PointsToID id = newPointsToId();
99
- idToPts.push_back(new Data(pts));
98
+ idToPts.push_back(std::make_unique<Data>(pts));
100
99
  ptsToId[pts] = id;
101
100
 
102
101
  return id;
@@ -345,7 +344,7 @@ public:
345
344
  Map<Data, unsigned> getAllPts(void)
346
345
  {
347
346
  Map<Data, unsigned> allPts;
348
- for (const Data *d : idToPts) allPts[*d] = 1;
347
+ for (const auto &d : idToPts) allPts[*d] = 1;
349
348
  return allPts;
350
349
  }
351
350
 
@@ -389,7 +388,7 @@ private:
389
388
  else
390
389
  {
391
390
  resultId = newPointsToId();
392
- idToPts.push_back(new Data(result));
391
+ idToPts.push_back(std::make_unique<Data>(result));
393
392
  ptsToId[result] = resultId;
394
393
  }
395
394
 
@@ -426,7 +425,7 @@ private:
426
425
  /// Elements are only added through push_back, so the number of elements
427
426
  /// stored is the size of the vector.
428
427
  /// Not const so we can remap.
429
- std::vector<Data *> idToPts;
428
+ std::vector<std::unique_ptr<Data>> idToPts;
430
429
  /// Maps points-to sets to their corresponding ID.
431
430
  PTSToIDMap ptsToId;
432
431