@@ -34,17 +34,16 @@ struct AccessPath {
3434 AccessPath (const clang::ValueDecl *D) : D(D) {}
3535};
3636
37- // / An abstract base class for a single "Loan" which represents a lifetime
38- // / dependency .
37+ // / An abstract base class for a single "Loan" which represents lending a
38+ // / storage in memory .
3939class Loan {
4040 // / TODO: Represent opaque loans.
4141 // / TODO: Represent nullptr: loans to no path. Accessing it UB! Currently it
4242 // / is represented as empty LoanSet
4343public:
4444 enum class Kind : uint8_t {
45- // / A regular borrow of a variable within the function that has a path and
46- // / can expire.
47- Borrow,
45+ // / A loan with an access path to a storage location.
46+ Path,
4847 // / A non-expiring placeholder loan for a parameter, representing a borrow
4948 // / from the function's caller.
5049 Placeholder
@@ -63,30 +62,30 @@ class Loan {
6362 const LoanID ID;
6463};
6564
66- // / Information about a single borrow loan. A borrow loan is created when a
67- // / reference or pointer is created .
68- class BorrowLoan : public Loan {
65+ // / PathLoan represents lending a storage location that is visible within the
66+ // / function's scope (e.g., a local variable on stack) .
67+ class PathLoan : public Loan {
6968 AccessPath Path;
7069 // / The expression that creates the loan, e.g., &x.
7170 const Expr *IssueExpr;
7271
7372public:
74- BorrowLoan (LoanID ID, AccessPath Path, const Expr *IssueExpr)
75- : Loan(Kind::Borrow , ID), Path(Path), IssueExpr(IssueExpr) {}
73+ PathLoan (LoanID ID, AccessPath Path, const Expr *IssueExpr)
74+ : Loan(Kind::Path , ID), Path(Path), IssueExpr(IssueExpr) {}
7675
7776 const AccessPath &getAccessPath () const { return Path; }
7877 const Expr *getIssueExpr () const { return IssueExpr; }
7978
8079 void dump (llvm::raw_ostream &OS) const override ;
8180
82- static bool classof (const Loan *L) { return L->getKind () == Kind::Borrow ; }
81+ static bool classof (const Loan *L) { return L->getKind () == Kind::Path ; }
8382};
8483
8584// / A placeholder loan held by a function parameter, representing a borrow from
8685// / the caller's scope.
8786// /
8887// / Created at function entry for each pointer or reference parameter with an
89- // / origin. Unlike BorrowLoan , placeholder loans:
88+ // / origin. Unlike PathLoan , placeholder loans:
9089// / - Have no IssueExpr (created at function entry, not at a borrow site)
9190// / - Have no AccessPath (the borrowed object is not visible to the function)
9291// / - Do not currently expire, but may in the future when modeling function
@@ -120,9 +119,9 @@ class LoanManager {
120119 template <typename LoanType, typename ... Args>
121120 LoanType *createLoan (Args &&...args) {
122121 static_assert (
123- std::is_same_v<LoanType, BorrowLoan > ||
122+ std::is_same_v<LoanType, PathLoan > ||
124123 std::is_same_v<LoanType, PlaceholderLoan>,
125- " createLoan can only be used with BorrowLoan or PlaceholderLoan" );
124+ " createLoan can only be used with PathLoan or PlaceholderLoan" );
126125 void *Mem = LoanAllocator.Allocate <LoanType>();
127126 auto *NewLoan =
128127 new (Mem) LoanType (getNextLoanID (), std::forward<Args>(args)...);
0 commit comments