18#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_H
19#define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_H
23#include "llvm/ADT/DenseMapInfo.h"
24#include "llvm/ADT/ImmutableMap.h"
25#include "llvm/ADT/ImmutableSet.h"
26#include "llvm/ADT/StringMap.h"
50 LifetimeSafetyReporter *Reporter);
62template <
typename Tag>
struct ID {
73 void Profile(llvm::FoldingSetNodeID &IDBuilder)
const {
74 IDBuilder.AddInteger(
Value);
78template <
typename Tag>
89using LoanSet = llvm::ImmutableSet<LoanID>;
137 std::unique_ptr<LifetimeFactory> Factory;
138 std::unique_ptr<FactManager> FactMgr;
139 std::unique_ptr<LoanPropagationAnalysis> LoanPropagation;
140 std::unique_ptr<ExpiredLoansAnalysis> ExpiredLoans;
146template <
typename Tag>
147struct DenseMapInfo<
clang::lifetimes::internal::ID<Tag>> {
151 return {DenseMapInfo<uint32_t>::getEmptyKey()};
155 return {DenseMapInfo<uint32_t>::getTombstoneKey()};
159 return DenseMapInfo<uint32_t>::getHashValue(Val.
Value);
162 static bool isEqual(
const ID &LHS,
const ID &RHS) {
return LHS == RHS; }
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Defines the clang::SourceLocation class and associated facilities.
AnalysisDeclContext contains the context data for the function, method or block under analysis.
This represents one expression.
Encodes a location in the source.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
virtual void reportUseAfterFree(const Expr *IssueExpr, const Expr *UseExpr, SourceLocation FreeLoc, Confidence Confidence)
virtual ~LifetimeSafetyReporter()=default
LifetimeSafetyReporter()=default
The analysis that tracks which loans have expired.
An abstract base class for a single, atomic lifetime-relevant event.
Running the lifetime safety analysis and querying its results.
LoanSet getLoansAtPoint(OriginID OID, ProgramPoint PP) const
Returns the set of loans an origin holds at a specific program point.
std::optional< OriginID > getOriginIDForDecl(const ValueDecl *D) const
Finds the OriginID for a given declaration.
std::vector< LoanID > getExpiredLoansAtPoint(ProgramPoint PP) const
Returns the set of loans that have expired at a specific program point.
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.
~LifetimeSafetyAnalysis()
The analysis that tracks which loans belong to which origins.
llvm::ImmutableSet< LoanID > LoanSet
llvm::ImmutableSet< OriginID > OriginSet
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, ID< Tag > ID)
void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC, LifetimeSafetyReporter *Reporter)
The main entry point for the analysis.
Confidence
Enum to track the confidence level of a potential error.
The JSON file list parser is used to communicate input to InstallAPI.
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
A generic, type-safe wrapper for an ID, distinguished by its Tag type.
bool operator==(const ID< Tag > &Other) const
bool operator!=(const ID< Tag > &Other) const
bool operator<(const ID< Tag > &Other) const
void Profile(llvm::FoldingSetNodeID &IDBuilder) const
ID< Tag > operator++(int)
An object to hold the factories for immutable collections, ensuring that all created states share the...
static bool isEqual(const ID &LHS, const ID &RHS)
static unsigned getHashValue(const ID &Val)
static ID getTombstoneKey()