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

Running the lifetime safety analysis and querying its results. More...

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

Public Member Functions

 LifetimeSafetyAnalysis (AnalysisDeclContext &AC, LifetimeSafetySemaHelper *SemaHelper, const LifetimeSafetyOpts &LSOpts)
void run ()
LoanPropagationAnalysis & getLoanPropagation () const
LiveOriginsAnalysis & getLiveOrigins () const
FactManager & getFactManager ()

Detailed Description

Running the lifetime safety analysis and querying its results.

It encapsulates the various dataflow analyses.

Definition at line 194 of file LifetimeSafety.h.

Constructor & Destructor Documentation

◆ LifetimeSafetyAnalysis()

clang::lifetimes::internal::LifetimeSafetyAnalysis::LifetimeSafetyAnalysis ( AnalysisDeclContext & AC,
LifetimeSafetySemaHelper * SemaHelper,
const LifetimeSafetyOpts & LSOpts )

Definition at line 51 of file LifetimeSafety.cpp.

Member Function Documentation

◆ getFactManager()

FactManager & clang::lifetimes::internal::LifetimeSafetyAnalysis::getFactManager ( )
inline

Definition at line 207 of file LifetimeSafety.h.

Referenced by clang::lifetimes::runLifetimeSafetyAnalysis().

◆ getLiveOrigins()

LiveOriginsAnalysis & clang::lifetimes::internal::LifetimeSafetyAnalysis::getLiveOrigins ( ) const
inline

Definition at line 206 of file LifetimeSafety.h.

◆ getLoanPropagation()

LoanPropagationAnalysis & clang::lifetimes::internal::LifetimeSafetyAnalysis::getLoanPropagation ( ) const
inline
Note
These are provided only for testing purposes.

Definition at line 203 of file LifetimeSafety.h.

◆ run()

void clang::lifetimes::internal::LifetimeSafetyAnalysis::run ( )

TODO(opt): Consider optimizing individual blocks before running the dataflow analysis.

  1. Expression Origins: These are assigned once and read at most once, forming simple chains. These chains can be compressed into a single assignment.
  2. Block-Local Loans: Origins of expressions are never read by other blocks; only Decls are visible. Therefore, loans in a block that never reach an Origin associated with a Decl can be safely dropped by the analysis.
  3. Collapse ExpireFacts belonging to same source location into a single Fact.

Definition at line 56 of file LifetimeSafety.cpp.

References clang::lifetimes::internal::DebugOnlyFunction(), clang::CFG::dump(), clang::CFG::getNumBlockIDs(), clang::if(), clang::lifetimes::internal::FactsGenerator::run(), and clang::lifetimes::internal::runLifetimeChecker().

Referenced by clang::lifetimes::runLifetimeSafetyAnalysis().


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