Skip to content

Commit f89a263

Browse files
authored
Merge pull request #3167 from rudkx/fix-callee-analysis-leak
2 parents 4b85069 + f47cd8a commit f89a263

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

include/swift/SILOptimizer/Analysis/BasicCalleeAnalysis.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class CalleeCache {
118118

119119
class BasicCalleeAnalysis : public SILAnalysis {
120120
SILModule &M;
121-
CalleeCache *Cache;
121+
std::unique_ptr<CalleeCache> Cache;
122122

123123
public:
124124
BasicCalleeAnalysis(SILModule *M)
@@ -129,17 +129,15 @@ class BasicCalleeAnalysis : public SILAnalysis {
129129
}
130130

131131
virtual void invalidate(SILAnalysis::InvalidationKind K) {
132-
if (K & InvalidationKind::Functions) {
133-
delete Cache;
134-
Cache = nullptr;
135-
}
132+
if (K & InvalidationKind::Functions)
133+
Cache.reset();
136134
}
137135

138136
virtual void invalidate(SILFunction *F, InvalidationKind K) { invalidate(K); }
139137

140138
CalleeList getCalleeList(FullApplySite FAS) {
141139
if (!Cache)
142-
Cache = new CalleeCache(M);
140+
Cache = llvm::make_unique<CalleeCache>(M);
143141

144142
return Cache->getCalleeList(FAS);
145143
}

0 commit comments

Comments
 (0)