clang 22.0.0git
clang::lifetimes::internal Namespace Reference

Namespaces

namespace  utils

Classes

struct  AccessPath
 Represents the storage location being borrowed, e.g., a specific stack variable. More...
class  DataflowAnalysis
 A generic, policy-based driver for dataflow analyses. More...
class  ExpireFact
class  Fact
 An abstract base class for a single, atomic lifetime-relevant event. More...
class  FactManager
class  FactsGenerator
class  IssueFact
struct  LifetimeFactory
 An object to hold the factories for immutable collections, ensuring that all created states share the same underlying memory management. More...
class  LifetimeSafetyAnalysis
 Running the lifetime safety analysis and querying its results. More...
struct  LivenessInfo
 Information about why an origin is live at a program point. More...
class  LiveOriginsAnalysis
struct  Loan
 Information about a single borrow, or "Loan". More...
class  LoanManager
 Manages the creation, storage and retrieval of loans. More...
class  LoanPropagationAnalysis
struct  Origin
 An Origin is a symbolic identifier that represents the set of possible loans a pointer-like object could hold at any given time. More...
class  OriginFlowFact
class  OriginManager
 Manages the creation, storage, and retrieval of origins for pointer-like variables and expressions. More...
class  ReturnOfOriginFact
class  TestPointFact
 A dummy-fact used to mark a specific point in the code for testing. More...
class  UseFact

Typedefs

using ProgramPoint = const Fact *
 A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.
using LivenessMap = llvm::ImmutableMap<OriginID, LivenessInfo>
using LoanSet = llvm::ImmutableSet<LoanID>
using OriginLoanMap = llvm::ImmutableMap<OriginID, LoanSet>
using LoanID = utils::ID<struct LoanTag>
using OriginID = utils::ID<struct OriginTag>

Enumerations

enum class  LivenessKind : uint8_t { Dead , Maybe , Must }
enum class  Direction { Forward , Backward }

Functions

void runLifetimeChecker (const LoanPropagationAnalysis &LoanPropagation, const LiveOriginsAnalysis &LiveOrigins, const FactManager &FactMgr, AnalysisDeclContext &ADC, LifetimeSafetyReporter *Reporter)
 Runs the lifetime checker, which detects use-after-free errors by examining loan expiration points and checking if any live origins hold the expired loan.
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, LoanID ID)
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, OriginID ID)
static Confidence livenessKindToConfidence (LivenessKind K)
static bool isGslPointerType (QualType QT)
static bool isPointerType (QualType QT)
static bool hasOrigin (const Expr *E)
static bool hasOrigin (const VarDecl *VD)
static const LoancreateLoan (FactManager &FactMgr, const DeclRefExpr *DRE)
 Creates a loan for the storage path of a given declaration reference.

Typedef Documentation

◆ LivenessMap

Definition at line 74 of file LiveOrigins.h.

◆ LoanID

Definition at line 23 of file Loans.h.

◆ LoanSet

using clang::lifetimes::internal::LoanSet = llvm::ImmutableSet<LoanID>

Definition at line 29 of file LoanPropagation.h.

◆ OriginID

Definition at line 23 of file Origins.h.

◆ OriginLoanMap

Definition at line 30 of file LoanPropagation.h.

◆ ProgramPoint

A ProgramPoint identifies a location in the CFG by pointing to a specific Fact.

identified by a lifetime-related event (Fact).

A ProgramPoint has "after" semantics: it represents the location immediately after its corresponding Fact.

Definition at line 74 of file Facts.h.

Enumeration Type Documentation

◆ Direction

Enumerator
Forward 
Backward 

Definition at line 29 of file Dataflow.h.

◆ LivenessKind

enum class clang::lifetimes::internal::LivenessKind : uint8_t
strong
Enumerator
Dead 
Maybe 
Must 

Definition at line 34 of file LiveOrigins.h.

Function Documentation

◆ createLoan()

const Loan * clang::lifetimes::internal::createLoan ( FactManager & FactMgr,
const DeclRefExpr * DRE )
static

Creates a loan for the storage path of a given declaration reference.

This function should be called whenever a DeclRefExpr represents a borrow.

Parameters
DREThe declaration reference expression that initiates the borrow.
Returns
The new Loan on success, nullptr otherwise.

Definition at line 44 of file FactsGenerator.cpp.

References clang::lifetimes::internal::LoanManager::addLoan(), clang::DeclRefExpr::getDecl(), and clang::lifetimes::internal::FactManager::getLoanMgr().

Referenced by clang::lifetimes::internal::FactsGenerator::VisitDeclRefExpr().

◆ hasOrigin() [1/2]

◆ hasOrigin() [2/2]

bool clang::lifetimes::internal::hasOrigin ( const VarDecl * VD)
static

Definition at line 36 of file FactsGenerator.cpp.

References clang::ValueDecl::getType(), and isPointerType().

◆ isGslPointerType()

◆ isPointerType()

◆ livenessKindToConfidence()

Confidence clang::lifetimes::internal::livenessKindToConfidence ( LivenessKind K)
static

◆ operator<<() [1/2]

llvm::raw_ostream & clang::lifetimes::internal::operator<< ( llvm::raw_ostream & OS,
LoanID ID )
inline

Definition at line 24 of file Loans.h.

◆ operator<<() [2/2]

llvm::raw_ostream & clang::lifetimes::internal::operator<< ( llvm::raw_ostream & OS,
OriginID ID )
inline

Definition at line 25 of file Origins.h.

◆ runLifetimeChecker()

void clang::lifetimes::internal::runLifetimeChecker ( const LoanPropagationAnalysis & LoanPropagation,
const LiveOriginsAnalysis & LiveOrigins,
const FactManager & FactMgr,
AnalysisDeclContext & ADC,
LifetimeSafetyReporter * Reporter )

Runs the lifetime checker, which detects use-after-free errors by examining loan expiration points and checking if any live origins hold the expired loan.

Definition at line 122 of file Checker.cpp.

Referenced by clang::lifetimes::internal::LifetimeSafetyAnalysis::run().