10#ifndef LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMEANNOTATIONS_H
11#define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMEANNOTATIONS_H
15#include "llvm/ADT/ArrayRef.h"
16#include "llvm/ADT/PointerUnion.h"
17#include "llvm/ADT/SmallVector.h"
21class LifetimeBoundAttr;
54const LifetimeBoundAttr *
59const LifetimeBoundAttr *
75const LifetimeCaptureByAttr *
79 llvm::PointerUnion<const ParmVarDecl *, const CXXMethodDecl *>;
83 const FunctionDecl *
FD =
nullptr;
105std::optional<LifetimeBoundParamInfo>
111std::optional<LifetimeBoundParamInfo>
121 const CXXMethodDecl *Callee,
122 bool RunningUnderLifetimeSafety);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
bool isAllocatingFunction(const FunctionDecl &FD)
Returns true if the function allocates memory that must be freed by the caller (e....
bool paramIsLifetimeBound(const ParmVarDecl &PVD)
Returns true if PVD should be considered lifetimebound, either due to an explicit lifetimebound attri...
bool isInvalidationMethod(const CXXMethodDecl &MD)
bool isFreeingFunction(const FunctionDecl &FD)
Returns true if the function frees memory it takes ownership of (e.g.
bool isStdReferenceCast(const FunctionDecl *FD)
Returns true for std reference-cast builtins (e.g., std::move).
bool isAssignmentOperatorLifetimeBound(const CXXMethodDecl *CMD)
Returns true if this is an assignment operator where the parameter has the lifetimebound attribute.
bool isPointerLikeType(QualType QT)
bool shouldTrackImplicitObjectArg(const Expr &ImplicitObjectArgument, const CXXMethodDecl *Callee, bool RunningUnderLifetimeSafety)
bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD)
Returns true if the implicit object parameter (this) should be considered lifetimebound,...
std::optional< LifetimeBoundParamInfo > getTrackedArgInfo(const FunctionDecl *FD, llvm::ArrayRef< const Expr * > Args, unsigned I)
Returns the parameter corresponding to argument I when the argument should be tracked for lifetime sa...
bool shouldTrackFirstArgument(const FunctionDecl *FD)
bool hasObjectArg(const FunctionDecl &FD)
Returns true if argument 0 of a call to FD (as listed by FunctionCallInfo) is the object argument,...
bool shouldTrackSecondArgument(const FunctionDecl *FD)
bool destructsFirstArg(const FunctionDecl &FD)
const FunctionDecl * getDeclWithMergedLifetimeBoundAttrs(const FunctionDecl *FD)
Returns the most recent declaration of the method to ensure all lifetime-bound attributes from redecl...
const Expr * ignoreParensAndImpCasts(const Expr *E)
Skips parentheses and implicit casts.
const LifetimeBoundAttr * getImplicitObjectParamLifetimeBoundAttr(const FunctionDecl *FD)
Returns the lifetimebound attribute for the implicit this parameter, if it exists on any redeclaratio...
bool hasImplicitObjectArg(const FunctionDecl &FD)
Returns true if argument 0 of a call to FD is the implicit object argument.
std::optional< LifetimeBoundParamInfo > getTrackingInfoForCallArg(const Expr *Call, const Expr *Source)
Returns lifetime safety tracking info for the call argument containing Source.
const LifetimeCaptureByAttr * getCaptureByAttrFromFunctionType(const FunctionDecl *FD)
Check if a function has a lifetime_capture_by attribute on its declaration or its function type (whic...
bool isOwnerPtrCtor(const CXXConstructorDecl *Ctor, const ParmVarDecl *PVD)
bool isNormalAssignmentOperator(const FunctionDecl *FD)
bool isUniquePtrRelease(const CXXMethodDecl &MD)
bool isInStlNamespace(const Decl *D)
llvm::PointerUnion< const ParmVarDecl *, const CXXMethodDecl * > LifetimeBoundParamInfo
bool isStdCallableWrapperType(const CXXRecordDecl *RD)
Returns true for standard library callable wrappers (e.g., std::function) that can propagate the stor...
const LifetimeBoundAttr * getDirectImplicitObjectLifetimeBoundAttr(const FunctionDecl *FD)
Returns the lifetimebound attribute for the implicit this parameter, if it exists on the current type...
const ParmVarDecl * getParamForArg(const FunctionDecl &FD, unsigned I)
Returns the parameter that argument I of a call to FD binds to, or null for the implicit object argum...
bool isGslPointerType(QualType QT)
bool isGslOwnerType(QualType QT)
Top level wrappers for InstallAPI frontend operations.
llvm::SmallVector< const Expr *, 4 > Args
FunctionCallInfo(const Expr *Call)