clang 22.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)
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.
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 125 of file Origins.h.

Constructor & Destructor Documentation

◆ OriginManager()

clang::lifetimes::internal::OriginManager::OriginManager ( ASTContext & AST)
inlineexplicit

Definition at line 127 of file Origins.h.

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 192 of file Origins.cpp.

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

◆ dump()

◆ getNumOrigins()

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

Definition at line 151 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 124 of file Origins.cpp.

References clang::lifetimes::internal::doesDeclHaveStorage(), getOrCreateList(), clang::Expr::getType(), clang::lifetimes::internal::hasOrigins(), clang::Expr::IgnoreParens(), 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 115 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 187 of file Origins.cpp.

Referenced by dump().

◆ getOrigins()

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

Definition at line 149 of file Origins.h.


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