Skip to content

Commit 0c1eae5

Browse files
committed
liveness-based-lifetime-policy
1 parent 271e174 commit 0c1eae5

File tree

4 files changed

+577
-460
lines changed

4 files changed

+577
-460
lines changed

clang/include/clang/Analysis/Analyses/LifetimeSafety.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Fact;
5555
class FactManager;
5656
class LoanPropagationAnalysis;
5757
class ExpiredLoansAnalysis;
58+
class LiveOriginAnalysis;
5859
struct LifetimeFactory;
5960

6061
/// A generic, type-safe wrapper for an ID, distinguished by its `Tag` type.
@@ -89,6 +90,7 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, OriginID ID) {
8990
// TODO(opt): Consider using a bitset to represent the set of loans.
9091
using LoanSet = llvm::ImmutableSet<LoanID>;
9192
using OriginSet = llvm::ImmutableSet<OriginID>;
93+
using OriginLoanMap = llvm::ImmutableMap<OriginID, LoanSet>;
9294

9395
/// A `ProgramPoint` identifies a location in the CFG by pointing to a specific
9496
/// `Fact`. identified by a lifetime-related event (`Fact`).
@@ -110,8 +112,9 @@ class LifetimeSafetyAnalysis {
110112
/// Returns the set of loans an origin holds at a specific program point.
111113
LoanSet getLoansAtPoint(OriginID OID, ProgramPoint PP) const;
112114

113-
/// Returns the set of loans that have expired at a specific program point.
114-
std::vector<LoanID> getExpiredLoansAtPoint(ProgramPoint PP) const;
115+
/// TODO:Document.
116+
std::vector<std::pair<OriginID, Confidence>>
117+
getLiveOriginsAtPoint(ProgramPoint PP) const;
115118

116119
/// Finds the OriginID for a given declaration.
117120
/// Returns a null optional if not found.
@@ -138,7 +141,7 @@ class LifetimeSafetyAnalysis {
138141
std::unique_ptr<LifetimeFactory> Factory;
139142
std::unique_ptr<FactManager> FactMgr;
140143
std::unique_ptr<LoanPropagationAnalysis> LoanPropagation;
141-
std::unique_ptr<ExpiredLoansAnalysis> ExpiredLoans;
144+
std::unique_ptr<LiveOriginAnalysis> LiveOrigins;
142145
};
143146
} // namespace internal
144147
} // namespace clang::lifetimes

0 commit comments

Comments
 (0)