clang 22.0.0git
clang::lifetimes::internal::PlaceholderLoan Class Reference

A placeholder loan held by a function parameter, representing a borrow from the caller's scope. More...

#include "clang/Analysis/Analyses/LifetimeSafety/Loans.h"

Inheritance diagram for clang::lifetimes::internal::PlaceholderLoan:
[legend]

Public Member Functions

 PlaceholderLoan (LoanID ID, const ParmVarDecl *PVD)
const ParmVarDeclgetParmVarDecl () const
void dump (llvm::raw_ostream &OS) const override
Public Member Functions inherited from clang::lifetimes::internal::Loan
 Loan (Kind K, LoanID ID)
virtual ~Loan ()=default
Kind getKind () const
LoanID getID () const

Static Public Member Functions

static bool classof (const Loan *L)

Additional Inherited Members

Public Types inherited from clang::lifetimes::internal::Loan
enum class  Kind : uint8_t { Path , Placeholder }
 TODO: Represent opaque loans. More...

Detailed Description

A placeholder loan held by a function parameter, representing a borrow from the caller's scope.

Created at function entry for each pointer or reference parameter with an origin. Unlike PathLoan, placeholder loans:

  • Have no IssueExpr (created at function entry, not at a borrow site)
  • Have no AccessPath (the borrowed object is not visible to the function)
  • Do not currently expire, but may in the future when modeling function invalidations (e.g., vector::push_back)

When a placeholder loan escapes the function (e.g., via return), it indicates the parameter should be marked [[clang::lifetimebound]], enabling lifetime annotation suggestions.

Definition at line 97 of file Loans.h.

Constructor & Destructor Documentation

◆ PlaceholderLoan()

clang::lifetimes::internal::PlaceholderLoan::PlaceholderLoan ( LoanID ID,
const ParmVarDecl * PVD )
inline

Member Function Documentation

◆ classof()

bool clang::lifetimes::internal::PlaceholderLoan::classof ( const Loan * L)
inlinestatic

◆ dump()

void clang::lifetimes::internal::PlaceholderLoan::dump ( llvm::raw_ostream & OS) const
overridevirtual

Implements clang::lifetimes::internal::Loan.

Definition at line 18 of file Loans.cpp.

References clang::lifetimes::internal::Loan::getID().

◆ getParmVarDecl()

const ParmVarDecl * clang::lifetimes::internal::PlaceholderLoan::getParmVarDecl ( ) const
inline

Definition at line 105 of file Loans.h.


The documentation for this class was generated from the following files: