clang 24.0.0git
clang::lifetimes::internal::AccessPath Class Reference

Represents the storage location being borrowed, e.g., a specific stack variable or a field within it: var.field. More...

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

Public Member Functions

 AccessPath (const clang::ValueDecl *D)
 AccessPath (const clang::MaterializeTemporaryExpr *MTE)
 AccessPath (const PlaceholderBase *PB)
 AccessPath (const clang::CXXNewExpr *New)
 AccessPath (const AccessPath &Other, PathElement E)
 Creates an extended access path by appending a path element.
const clang::ValueDeclgetAsValueDecl () const
const clang::MaterializeTemporaryExprgetAsMaterializeTemporaryExpr () const
const PlaceholderBasegetAsPlaceholderBase () const
const clang::CXXNewExprgetAsNewAllocation () const
bool operator== (const AccessPath &RHS) const
bool operator!= (const AccessPath &RHS) const
bool isPrefixOf (const AccessPath &Other) const
 Returns true if this path is a prefix of Other (or same as Other).
bool isStrictPrefixOf (const AccessPath &Other) const
 Returns true if this path is a strict prefix of Other.
llvm::ArrayRef< PathElementgetElements () const
void dump (llvm::raw_ostream &OS) const

Detailed Description

Represents the storage location being borrowed, e.g., a specific stack variable or a field within it: var.field.

Examples:

  • x -> Base=x, Elements=[]
  • x.field -> Base=x, Elements=[.field]
  • x.* (e.g., string_view from string) -> Base=x, Elements=[.*]
  • x.field.* -> Base=x, Elements=[.field, .*]
  • $param.field -> Base=$param, Elements=[.field]

TODO: Model access paths of other types, e.g. heap and globals.

Definition at line 113 of file Loans.h.

Constructor & Destructor Documentation

◆ AccessPath() [1/5]

clang::lifetimes::internal::AccessPath::AccessPath ( const clang::ValueDecl * D)
inline

Definition at line 124 of file Loans.h.

Referenced by AccessPath(), isPrefixOf(), isStrictPrefixOf(), operator!=(), and operator==().

◆ AccessPath() [2/5]

clang::lifetimes::internal::AccessPath::AccessPath ( const clang::MaterializeTemporaryExpr * MTE)
inline

Definition at line 125 of file Loans.h.

◆ AccessPath() [3/5]

clang::lifetimes::internal::AccessPath::AccessPath ( const PlaceholderBase * PB)
inline

Definition at line 126 of file Loans.h.

◆ AccessPath() [4/5]

clang::lifetimes::internal::AccessPath::AccessPath ( const clang::CXXNewExpr * New)
inline

Definition at line 127 of file Loans.h.

References New.

◆ AccessPath() [5/5]

clang::lifetimes::internal::AccessPath::AccessPath ( const AccessPath & Other,
PathElement E )
inline

Creates an extended access path by appending a path element.

Example: AccessPath(x_path, field) creates path to x.field.

Definition at line 131 of file Loans.h.

References AccessPath(), and clang::Other.

Member Function Documentation

◆ dump()

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

◆ getAsMaterializeTemporaryExpr()

const clang::MaterializeTemporaryExpr * clang::lifetimes::internal::AccessPath::getAsMaterializeTemporaryExpr ( ) const
inline

Definition at line 140 of file Loans.h.

Referenced by dump().

◆ getAsNewAllocation()

const clang::CXXNewExpr * clang::lifetimes::internal::AccessPath::getAsNewAllocation ( ) const
inline

Definition at line 148 of file Loans.h.

Referenced by dump().

◆ getAsPlaceholderBase()

const PlaceholderBase * clang::lifetimes::internal::AccessPath::getAsPlaceholderBase ( ) const
inline

Definition at line 144 of file Loans.h.

Referenced by dump().

◆ getAsValueDecl()

const clang::ValueDecl * clang::lifetimes::internal::AccessPath::getAsValueDecl ( ) const
inline

Definition at line 136 of file Loans.h.

Referenced by dump().

◆ getElements()

llvm::ArrayRef< PathElement > clang::lifetimes::internal::AccessPath::getElements ( ) const
inline

Definition at line 174 of file Loans.h.

◆ isPrefixOf()

bool clang::lifetimes::internal::AccessPath::isPrefixOf ( const AccessPath & Other) const
inline

Returns true if this path is a prefix of Other (or same as Other).

Examples:

  • x is a prefix of x, x.field, x.field.*
  • x.field is a prefix of x.field and x.field.nested
  • x.field is NOT a prefix of x.other_field

Definition at line 162 of file Loans.h.

References AccessPath(), and clang::Other.

Referenced by isStrictPrefixOf().

◆ isStrictPrefixOf()

bool clang::lifetimes::internal::AccessPath::isStrictPrefixOf ( const AccessPath & Other) const
inline

Returns true if this path is a strict prefix of Other.

Example:

  • x is a strict prefix of x.field but NOT of x

Definition at line 171 of file Loans.h.

References AccessPath(), isPrefixOf(), and clang::Other.

◆ operator!=()

bool clang::lifetimes::internal::AccessPath::operator!= ( const AccessPath & RHS) const
inline

Definition at line 155 of file Loans.h.

References AccessPath().

◆ operator==()

bool clang::lifetimes::internal::AccessPath::operator== ( const AccessPath & RHS) const
inline

Definition at line 152 of file Loans.h.

References AccessPath().


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