[clang] Suggest lifetime annotations [Issue Id: 169375] (PR #169767)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 27 06:14:41 PST 2025
================
@@ -31,7 +31,7 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, LoanID ID) {
struct AccessPath {
const clang::ValueDecl *D;
- AccessPath(const clang::ValueDecl *D) : D(D) {}
+ AccessPath(const clang::ValueDecl *D = nullptr) : D(D) {}
----------------
usx95 wrote:
> If the root of the access path is a `ParmVarDecl,` we know it was a placeholder loan
This is different from borrowing the `ParmVarDecl` itself. A place holder loan is a loan held by the origin of ParmVarDecl and not a loan to the decl.
Example in `int* foo(int* p) { int**x = &p; }`, `&p` has a loan to `p` but `p` itself would contain the placeholder loan. Another thing is that these placeholder loans never expire(unlike other loans which expire when there access path gets destructed)
https://github.com/llvm/llvm-project/pull/169767
More information about the cfe-commits
mailing list