clang 24.0.0git
clang::lifetimes::internal::Origin Struct Reference

An Origin is a symbolic identifier that represents the set of possible loans a pointer-like object could hold at any given time. More...

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

Public Member Functions

 Origin (OriginID ID, const clang::ValueDecl *D, const Type *QT, bool NamesDeclStorage)
 Origin (OriginID ID, const clang::Expr *E, const Type *QT, bool NamesDeclStorage)
const clang::ValueDecl * getDecl () const
const clang::Expr * getExpr () const

Public Attributes

OriginID ID
llvm::PointerUnion< const clang::ValueDecl *, const clang::Expr * > Ptr
 A pointer to the AST node that this origin represents.
const Type * Ty
 The type at this indirection level.
bool NamesDeclStorage
 True if this origin only holds a loan to a declaration named in scope, so it can never hold an expired loan.

Detailed Description

An Origin is a symbolic identifier that represents the set of possible loans a pointer-like object could hold at any given time.

Each Origin corresponds to a single level of indirection. For complex types with multiple levels of indirection (e.g., int**), multiple Origins are organized into an OriginList structure (see below).

Definition at line 40 of file Origins.h.

Constructor & Destructor Documentation

◆ Origin() [1/2]

clang::lifetimes::internal::Origin::Origin ( OriginID ID,
const clang::ValueDecl * D,
const Type * QT,
bool NamesDeclStorage )
inline

Definition at line 64 of file Origins.h.

References ID, NamesDeclStorage, Ptr, and Ty.

◆ Origin() [2/2]

clang::lifetimes::internal::Origin::Origin ( OriginID ID,
const clang::Expr * E,
const Type * QT,
bool NamesDeclStorage )
inline

Definition at line 67 of file Origins.h.

References ID, NamesDeclStorage, Ptr, and Ty.

Member Function Documentation

◆ getDecl()

const clang::ValueDecl * clang::lifetimes::internal::Origin::getDecl ( ) const
inline

Definition at line 71 of file Origins.h.

References Ptr.

Referenced by clang::lifetimes::internal::OriginManager::dump().

◆ getExpr()

const clang::Expr * clang::lifetimes::internal::Origin::getExpr ( ) const
inline

Definition at line 74 of file Origins.h.

References Ptr.

Referenced by clang::lifetimes::internal::OriginManager::dump().

Member Data Documentation

◆ ID

OriginID clang::lifetimes::internal::Origin::ID

Definition at line 41 of file Origins.h.

Referenced by Origin(), and Origin().

◆ NamesDeclStorage

bool clang::lifetimes::internal::Origin::NamesDeclStorage

True if this origin only holds a loan to a declaration named in scope, so it can never hold an expired loan.

For example, in int s = 42; int t = s; the outer origin of the expression s holds a loan to s, which is alive wherever s can be named.

Definition at line 62 of file Origins.h.

Referenced by clang::lifetimes::internal::OriginManager::getOrCreateList(), Origin(), and Origin().

◆ Ptr

llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *> clang::lifetimes::internal::Origin::Ptr

A pointer to the AST node that this origin represents.

This union distinguishes between origins from declarations (variables or parameters) and origins from expressions.

Definition at line 45 of file Origins.h.

Referenced by getDecl(), getExpr(), Origin(), and Origin().

◆ Ty

const Type* clang::lifetimes::internal::Origin::Ty

The type at this indirection level.

For int** pp: Root origin: QT = int** (what pp points to) Pointee origin: QT = int* (what *pp points to)

Null for synthetic lvalue origins (e.g., outer origin of DeclRefExpr).

Definition at line 54 of file Origins.h.

Referenced by clang::lifetimes::internal::OriginManager::dump(), Origin(), and Origin().


The documentation for this struct was generated from the following file: