@@ -59,7 +59,7 @@ using LoanID = ID<struct LoanTag>;
5959using OriginID = ID<struct OriginTag >;
6060
6161// / Information about a single borrow, or "Loan". A loan is created when a
62- // / reference or pointer is taken .
62+ // / reference or pointer is created .
6363struct Loan {
6464 // / TODO: Represent opaque loans.
6565 // / TODO: Represent nullptr: loans to no path. Accessing it UB! Currently it
@@ -82,6 +82,9 @@ struct Loan {
8282// / https://github.com/llvm/llvm-project/pull/142313/commits/0cd187b01e61b200d92ca0b640789c1586075142#r2137644238
8383struct Origin {
8484 OriginID ID;
85+ // / A pointer to the AST node that this origin represents. This union
86+ // / distinguishes between origins from lvalues (named variables or parameter)
87+ // / and rvalues (expressions).
8588 llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *> Ptr;
8689
8790 Origin (OriginID ID, const clang::ValueDecl *D) : ID(ID), Ptr(D) {}
@@ -95,6 +98,7 @@ struct Origin {
9598 }
9699};
97100
101+ // / Manages the creation, storage and retrieval of loans.
98102class LoanManager {
99103public:
100104 LoanManager () = default ;
@@ -119,6 +123,8 @@ class LoanManager {
119123 llvm::SmallVector<Loan> AllLoans;
120124};
121125
126+ // / Manages the creation, storage, and retrieval of origins for pointer-like
127+ // / variables and expressions.
122128class OriginManager {
123129public:
124130 OriginManager () = default ;
@@ -212,7 +218,7 @@ class Fact {
212218 Expire,
213219 // / An origin is propagated from a source to a destination (e.g., p = q).
214220 AssignOrigin,
215- // / An origin is part of a function's return value.
221+ // / An origin escapes the function by flowing into the return value.
216222 ReturnOfOrigin
217223 };
218224
@@ -449,7 +455,7 @@ class FactGenerator : public ConstStmtVisitor<FactGenerator> {
449455 }
450456
451457private:
452- // Check if a type have an origin.
458+ // Check if a type has an origin.
453459 bool hasOrigin (QualType QT) { return QT->isPointerOrReferenceType (); }
454460
455461 template <typename Destination, typename Source>
0 commit comments