clang 22.0.0git
|
Running the lifetime safety analysis and querying its results. More...
#include "clang/Analysis/Analyses/LifetimeSafety.h"
Public Member Functions | |
LifetimeSafetyAnalysis (AnalysisDeclContext &AC, LifetimeSafetyReporter *Reporter) | |
~LifetimeSafetyAnalysis () | |
void | run () |
LoanSet | getLoansAtPoint (OriginID OID, ProgramPoint PP) const |
Returns the set of loans an origin holds at a specific program point. | |
std::vector< LoanID > | getExpiredLoansAtPoint (ProgramPoint PP) const |
Returns the set of loans that have expired at a specific program point. | |
std::optional< OriginID > | getOriginIDForDecl (const ValueDecl *D) const |
Finds the OriginID for a given declaration. | |
std::vector< LoanID > | getLoanIDForVar (const VarDecl *VD) const |
Finds the LoanID's for the loan created with the specific variable as their Path. | |
llvm::StringMap< ProgramPoint > | getTestPoints () const |
Retrieves program points that were specially marked in the source code for testing. | |
Running the lifetime safety analysis and querying its results.
It encapsulates the various dataflow analyses.
Definition at line 101 of file LifetimeSafety.h.
clang::lifetimes::internal::LifetimeSafetyAnalysis::LifetimeSafetyAnalysis | ( | AnalysisDeclContext & | AC, |
LifetimeSafetyReporter * | Reporter | ||
) |
Definition at line 1107 of file LifetimeSafety.cpp.
|
default |
std::vector< LoanID > clang::lifetimes::internal::LifetimeSafetyAnalysis::getExpiredLoansAtPoint | ( | ProgramPoint | PP | ) | const |
Returns the set of loans that have expired at a specific program point.
Definition at line 1154 of file LifetimeSafety.cpp.
References clang::Result.
std::vector< LoanID > clang::lifetimes::internal::LifetimeSafetyAnalysis::getLoanIDForVar | ( | const VarDecl * | VD | ) | const |
Finds the LoanID's for the loan created with the specific variable as their Path.
Definition at line 1172 of file LifetimeSafety.cpp.
References clang::Result.
LoanSet clang::lifetimes::internal::LifetimeSafetyAnalysis::getLoansAtPoint | ( | OriginID | OID, |
ProgramPoint | PP | ||
) | const |
Returns the set of loans an origin holds at a specific program point.
Definition at line 1147 of file LifetimeSafety.cpp.
std::optional< OriginID > clang::lifetimes::internal::LifetimeSafetyAnalysis::getOriginIDForDecl | ( | const ValueDecl * | D | ) | const |
Finds the OriginID for a given declaration.
Returns a null optional if not found.
Definition at line 1163 of file LifetimeSafety.cpp.
References D.
llvm::StringMap< ProgramPoint > clang::lifetimes::internal::LifetimeSafetyAnalysis::getTestPoints | ( | ) | const |
Retrieves program points that were specially marked in the source code for testing.
The analysis recognizes special function calls of the form void("__lifetime_test_point_<name>")
as test points. This method returns a map from the annotation string (<name>) to the corresponding ProgramPoint
. This allows test harnesses to query the analysis state at user-defined locations in the code.
Definition at line 1181 of file LifetimeSafety.cpp.
References clang::Block.
void clang::lifetimes::internal::LifetimeSafetyAnalysis::run | ( | ) |
TODO(opt): Consider optimizing individual blocks before running the dataflow analysis.
Definition at line 1112 of file LifetimeSafety.cpp.
References clang::CFG::dump(), clang::lifetimes::internal::FactGenerator::run(), and clang::lifetimes::internal::LifetimeChecker::run().