14#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_ORIGINS_H
15#define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_ORIGINS_H
24#include "llvm/Support/raw_ostream.h"
31 return OS << ID.Value;
45 llvm::PointerUnion<const clang::ValueDecl *, const clang::Expr *>
Ptr;
109 while (T->InnerList) {
170 OriginID getNextOriginID() {
return NextOriginID++; }
175 template <
typename T>
176 OriginList *buildListForType(
QualType QT,
const T *Node);
178 void initializeThisOrigins(
const Decl *D);
184 void registerLifetimeAnnotatedOriginType(
QualType QT);
191 llvm::BumpPtrAllocator ListAllocator;
192 llvm::DenseMap<const clang::ValueDecl *, OriginList *> DeclToList;
193 llvm::DenseMap<const clang::Expr *, OriginList *> ExprToList;
194 std::optional<OriginList *> ThisOrigins;
198 llvm::DenseSet<const Type *> LifetimeAnnotatedOriginTypes;
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
A (possibly-)qualified type.
Stmt - This represents one statement.
The base class of the type hierarchy.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
A list of origins representing levels of indirection for pointer-like types.
OriginID getOuterOriginID() const
OriginList * peelOuterOrigin() const
void setInnerOriginList(OriginList *Inner)
std::optional< OriginList * > getThisOrigins() const
Returns the OriginList for the implicit 'this' parameter if the current declaration is an instance me...
OriginList * getOrCreateList(const ValueDecl *D)
Gets or creates the OriginList for a given ValueDecl.
OriginList * createSingleOriginList(OriginID OID)
Wraps an existing OriginID in a new single-element OriginList, so a fact can refer to a single level ...
bool hasOrigins(QualType QT) const
const Origin & getOrigin(OriginID ID) const
llvm::ArrayRef< Origin > getOrigins() const
void collectMissingOrigins(Stmt &FunctionBody, LifetimeSafetyStats &LSStats)
Collects statistics about expressions that lack associated origins.
unsigned getNumOrigins() const
OriginManager(const AnalysisDeclContext &AC)
void dump(OriginID OID, llvm::raw_ostream &OS) const
utils::ID< struct OriginTag > OriginID
bool doesDeclHaveStorage(const ValueDecl *D)
Returns true if the declaration has its own storage that can be borrowed.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, LoanID ID)
A structure to hold the statistics related to LifetimeAnalysis.
An Origin is a symbolic identifier that represents the set of possible loans a pointer-like object co...
const clang::Expr * getExpr() const
const clang::ValueDecl * getDecl() const
llvm::PointerUnion< const clang::ValueDecl *, const clang::Expr * > Ptr
A pointer to the AST node that this origin represents.
const Type * Ty
The type at this indirection level.
Origin(OriginID ID, const clang::ValueDecl *D, const Type *QT)
Origin(OriginID ID, const clang::Expr *E, const Type *QT)
A generic, type-safe wrapper for an ID, distinguished by its Tag type.