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

Manages the creation, storage, and retrieval of origins for pointer-like variables and expressions. More...

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

Public Member Functions

 OriginManager (ASTContext &AST, const Decl *D)
OriginListgetOrCreateList (const ValueDecl *D)
 Gets or creates the OriginList for a given ValueDecl.
OriginListgetOrCreateList (const Expr *E)
 Gets or creates the OriginList for a given Expr.
std::optional< OriginList * > getThisOrigins () const
 Returns the OriginList for the implicit 'this' parameter if the current declaration is an instance method.
const OrigingetOrigin (OriginID ID) const
llvm::ArrayRef< OrigingetOrigins () const
unsigned getNumOrigins () const
void dump (OriginID OID, llvm::raw_ostream &OS) const
void collectMissingOrigins (Stmt &FunctionBody, LifetimeSafetyStats &LSStats)
 Collects statistics about expressions that lack associated origins.

Detailed Description

Manages the creation, storage, and retrieval of origins for pointer-like variables and expressions.

Definition at line 126 of file Origins.h.

Constructor & Destructor Documentation

◆ OriginManager()

clang::lifetimes::internal::OriginManager::OriginManager ( ASTContext & AST,
const Decl * D )
explicit

Definition at line 90 of file Origins.cpp.

Member Function Documentation

◆ collectMissingOrigins()

void clang::lifetimes::internal::OriginManager::collectMissingOrigins ( Stmt & FunctionBody,
LifetimeSafetyStats & LSStats )

Collects statistics about expressions that lack associated origins.

Definition at line 217 of file Origins.cpp.

Referenced by clang::lifetimes::internal::collectLifetimeStats().

◆ dump()

◆ getNumOrigins()

unsigned clang::lifetimes::internal::OriginManager::getNumOrigins ( ) const
inline

Definition at line 156 of file Origins.h.

Referenced by clang::lifetimes::internal::computePersistentOrigins().

◆ getOrCreateList() [1/2]

OriginList * clang::lifetimes::internal::OriginManager::getOrCreateList ( const Expr * E)

Gets or creates the OriginList for a given Expr.

Creates a list based on the expression's type and value category:

  • Lvalues get an implicit reference level (modeling addressability)
  • Rvalues of non-pointer type return nullptr (no trackable origin)
  • DeclRefExpr may reuse the underlying declaration's list
Returns
The OriginList, or nullptr for non-pointer rvalues.

Definition at line 132 of file Origins.cpp.

References clang::lifetimes::internal::doesDeclHaveStorage(), getOrCreateList(), clang::Expr::getType(), clang::lifetimes::internal::hasOrigins(), clang::Expr::IgnoreParens(), clang::isa(), clang::Expr::isGLValue(), clang::Type::isReferenceType(), and clang::lifetimes::internal::OriginList::setInnerOriginList().

◆ getOrCreateList() [2/2]

OriginList * clang::lifetimes::internal::OriginManager::getOrCreateList ( const ValueDecl * D)

Gets or creates the OriginList for a given ValueDecl.

Creates a list structure mirroring the levels of indirection in the declaration's type (e.g., int** p creates list of size 2).

Returns
The OriginList, or nullptr if the type is not pointer-like.

Definition at line 123 of file Origins.cpp.

References clang::ValueDecl::getType(), and clang::lifetimes::internal::hasOrigins().

Referenced by getOrCreateList().

◆ getOrigin()

const Origin & clang::lifetimes::internal::OriginManager::getOrigin ( OriginID ID) const

Definition at line 212 of file Origins.cpp.

Referenced by dump().

◆ getOrigins()

llvm::ArrayRef< Origin > clang::lifetimes::internal::OriginManager::getOrigins ( ) const
inline

Definition at line 154 of file Origins.h.

◆ getThisOrigins()

std::optional< OriginList * > clang::lifetimes::internal::OriginManager::getThisOrigins ( ) const
inline

Returns the OriginList for the implicit 'this' parameter if the current declaration is an instance method.

Definition at line 150 of file Origins.h.


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