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

A placeholder loan held by a function parameter or an implicit 'this' object, 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)
 PlaceholderLoan (LoanID ID, const CXXMethodDecl *MD)
const ParmVarDeclgetParmVarDecl () const
const CXXMethodDeclgetMethodDecl () 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 or an implicit 'this' object, representing a borrow from the caller's scope.

Created at function entry for each pointer or reference parameter or for the implicit 'this' parameter of instance methods, 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 or method should be marked [[clang::lifetimebound]], enabling lifetime annotation suggestions.

Definition at line 118 of file Loans.h.

Constructor & Destructor Documentation

◆ PlaceholderLoan() [1/2]

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

◆ PlaceholderLoan() [2/2]

clang::lifetimes::internal::PlaceholderLoan::PlaceholderLoan ( LoanID ID,
const CXXMethodDecl * MD )
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 26 of file Loans.cpp.

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

◆ getMethodDecl()

const CXXMethodDecl * clang::lifetimes::internal::PlaceholderLoan::getMethodDecl ( ) const
inline

Definition at line 134 of file Loans.h.

◆ getParmVarDecl()

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

Definition at line 130 of file Loans.h.


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