clang 24.0.0git
clang ::lifetimes Namespace Reference

Classes

struct  FunctionCallInfo
 Stores the callee and normalized arguments for a function call. More...

Typedefs

using LifetimeBoundParamInfo

Functions

bool isInStlNamespace (const Decl *D)
bool isPointerLikeType (QualType QT)
const FunctionDecl * getDeclWithMergedLifetimeBoundAttrs (const FunctionDecl *FD)
 Returns the most recent declaration of the method to ensure all lifetime-bound attributes from redeclarations are considered.
const CXXMethodDecl * getDeclWithMergedLifetimeBoundAttrs (const CXXMethodDecl *CMD)
 Returns the most recent declaration of the method to ensure all lifetime-bound attributes from redeclarations are considered.
bool isNormalAssignmentOperator (const FunctionDecl *FD)
bool isAssignmentOperatorLifetimeBound (const CXXMethodDecl *CMD)
 Returns true if this is an assignment operator where the parameter has the lifetimebound attribute.
const LifetimeBoundAttr * getDirectImplicitObjectLifetimeBoundAttr (const FunctionDecl *FD)
 Returns the lifetimebound attribute for the implicit this parameter, if it exists on the current type.
const LifetimeBoundAttr * getImplicitObjectParamLifetimeBoundAttr (const FunctionDecl *FD)
 Returns the lifetimebound attribute for the implicit this parameter, if it exists on any redeclaration.
bool implicitObjectParamIsLifetimeBound (const FunctionDecl *FD)
 Returns true if the implicit object parameter (this) should be considered lifetimebound, either due to an explicit lifetimebound attribute on the method or because it's a normal assignment operator.
bool paramIsLifetimeBound (const ParmVarDecl &PVD)
 Returns true if PVD should be considered lifetimebound, either due to an explicit lifetimebound attribute or because it is a constructor parameter marked lifetime_capture_by(this), which has the same meaning.
const LifetimeCaptureByAttr * getCaptureByAttrFromFunctionType (const FunctionDecl *FD)
 Check if a function has a lifetime_capture_by attribute on its declaration or its function type (which represents the implicit 'this' parameter for methods).
bool hasObjectArg (const FunctionDecl &FD)
 Returns true if argument 0 of a call to FD (as listed by FunctionCallInfo) is the object argument, bound either to the implicit object parameter or to an explicit object parameter.
bool hasImplicitObjectArg (const FunctionDecl &FD)
 Returns true if argument 0 of a call to FD is the implicit object argument.
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 argument and for variadic arguments.
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 safety.
std::optional< LifetimeBoundParamInfo > getTrackingInfoForCallArg (const Expr *Call, const Expr *Source)
 Returns lifetime safety tracking info for the call argument containing Source.
bool shouldTrackImplicitObjectArg (const Expr &ImplicitObjectArgument, const CXXMethodDecl *Callee, bool RunningUnderLifetimeSafety)
bool shouldTrackFirstArgument (const FunctionDecl *FD)
bool shouldTrackSecondArgument (const FunctionDecl *FD)
bool isGslPointerType (QualType QT)
bool isGslOwnerType (QualType QT)
bool isGslOwnerType (const CXXRecordDecl *RD)
bool isOwnerPtrCtor (const CXXConstructorDecl *Ctor, const ParmVarDecl *PVD)
bool isUniquePtrRelease (const CXXMethodDecl &MD)
bool isInvalidationMethod (const CXXMethodDecl &MD)
bool destructsFirstArg (const FunctionDecl &FD)
bool isAllocatingFunction (const FunctionDecl &FD)
 Returns true if the function allocates memory that must be freed by the caller (e.g.
bool isFreeingFunction (const FunctionDecl &FD)
 Returns true if the function frees memory it takes ownership of (e.g.
bool isStdCallableWrapperType (const CXXRecordDecl *RD)
 Returns true for standard library callable wrappers (e.g., std::function) that can propagate the stored lambda's origins.
bool isStdReferenceCast (const FunctionDecl *FD)
 Returns true for std reference-cast builtins (e.g., std::move).
const Expr * ignoreParensAndImpCasts (const Expr *E)
 Skips parentheses and implicit casts.

Typedef Documentation

◆ LifetimeBoundParamInfo

using clang ::lifetimes::LifetimeBoundParamInfo
Initial value:
llvm::PointerUnion<const ParmVarDecl *, const CXXMethodDecl *>

Definition at line 78 of file LifetimeAnnotations.h.

Function Documentation

◆ destructsFirstArg()

bool clang ::lifetimes::destructsFirstArg ( const FunctionDecl & FD)

References destructsFirstArg().

Referenced by destructsFirstArg().

◆ getCaptureByAttrFromFunctionType()

const LifetimeCaptureByAttr * clang ::lifetimes::getCaptureByAttrFromFunctionType ( const FunctionDecl * FD)

Check if a function has a lifetime_capture_by attribute on its declaration or its function type (which represents the implicit 'this' parameter for methods).

Returns the attribute if found, nullptr otherwise.

References getCaptureByAttrFromFunctionType().

Referenced by getCaptureByAttrFromFunctionType().

◆ getDeclWithMergedLifetimeBoundAttrs() [1/2]

const CXXMethodDecl * clang ::lifetimes::getDeclWithMergedLifetimeBoundAttrs ( const CXXMethodDecl * CMD)

Returns the most recent declaration of the method to ensure all lifetime-bound attributes from redeclarations are considered.

References getDeclWithMergedLifetimeBoundAttrs().

◆ getDeclWithMergedLifetimeBoundAttrs() [2/2]

const FunctionDecl * clang ::lifetimes::getDeclWithMergedLifetimeBoundAttrs ( const FunctionDecl * FD)

Returns the most recent declaration of the method to ensure all lifetime-bound attributes from redeclarations are considered.

References getDeclWithMergedLifetimeBoundAttrs().

Referenced by getDeclWithMergedLifetimeBoundAttrs(), and getDeclWithMergedLifetimeBoundAttrs().

◆ getDirectImplicitObjectLifetimeBoundAttr()

const LifetimeBoundAttr * clang ::lifetimes::getDirectImplicitObjectLifetimeBoundAttr ( const FunctionDecl * FD)

Returns the lifetimebound attribute for the implicit this parameter, if it exists on the current type.

References getDirectImplicitObjectLifetimeBoundAttr().

Referenced by getDirectImplicitObjectLifetimeBoundAttr().

◆ getImplicitObjectParamLifetimeBoundAttr()

const LifetimeBoundAttr * clang ::lifetimes::getImplicitObjectParamLifetimeBoundAttr ( const FunctionDecl * FD)

Returns the lifetimebound attribute for the implicit this parameter, if it exists on any redeclaration.

References getImplicitObjectParamLifetimeBoundAttr().

Referenced by getImplicitObjectParamLifetimeBoundAttr().

◆ getParamForArg()

const ParmVarDecl * clang ::lifetimes::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 argument and for variadic arguments.

References getParamForArg().

Referenced by getParamForArg().

◆ getTrackedArgInfo()

std::optional< LifetimeBoundParamInfo > clang ::lifetimes::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 safety.

References getTrackedArgInfo().

Referenced by getTrackedArgInfo().

◆ getTrackingInfoForCallArg()

std::optional< LifetimeBoundParamInfo > clang ::lifetimes::getTrackingInfoForCallArg ( const Expr * Call,
const Expr * Source )

Returns lifetime safety tracking info for the call argument containing Source.

References Call, and getTrackingInfoForCallArg().

Referenced by getTrackingInfoForCallArg().

◆ hasImplicitObjectArg()

bool clang ::lifetimes::hasImplicitObjectArg ( const FunctionDecl & FD)

Returns true if argument 0 of a call to FD is the implicit object argument.

An explicit object parameter is an ordinary parameter.

References hasImplicitObjectArg().

Referenced by hasImplicitObjectArg().

◆ hasObjectArg()

bool clang ::lifetimes::hasObjectArg ( const FunctionDecl & FD)

Returns true if argument 0 of a call to FD (as listed by FunctionCallInfo) is the object argument, bound either to the implicit object parameter or to an explicit object parameter.

Constructors have no object argument.

References hasObjectArg().

Referenced by hasObjectArg().

◆ ignoreParensAndImpCasts()

const Expr * clang ::lifetimes::ignoreParensAndImpCasts ( const Expr * E)

Skips parentheses and implicit casts.

Unlike IgnoreParenImpCasts(), stops at a MaterializeTemporaryExpr, which owns the storage of a temporary.

References ignoreParensAndImpCasts().

Referenced by ignoreParensAndImpCasts().

◆ implicitObjectParamIsLifetimeBound()

bool clang ::lifetimes::implicitObjectParamIsLifetimeBound ( const FunctionDecl * FD)

Returns true if the implicit object parameter (this) should be considered lifetimebound, either due to an explicit lifetimebound attribute on the method or because it's a normal assignment operator.

References implicitObjectParamIsLifetimeBound().

Referenced by implicitObjectParamIsLifetimeBound().

◆ isAllocatingFunction()

bool clang ::lifetimes::isAllocatingFunction ( const FunctionDecl & FD)

Returns true if the function allocates memory that must be freed by the caller (e.g.

functions annotated with ownership_returns, such as __attribute__((ownership_returns(malloc)))).

References isAllocatingFunction().

Referenced by isAllocatingFunction().

◆ isAssignmentOperatorLifetimeBound()

bool clang ::lifetimes::isAssignmentOperatorLifetimeBound ( const CXXMethodDecl * CMD)

Returns true if this is an assignment operator where the parameter has the lifetimebound attribute.

References isAssignmentOperatorLifetimeBound().

Referenced by isAssignmentOperatorLifetimeBound().

◆ isFreeingFunction()

bool clang ::lifetimes::isFreeingFunction ( const FunctionDecl & FD)

Returns true if the function frees memory it takes ownership of (e.g.

functions annotated with ownership_takes, such as __attribute__((ownership_takes(malloc, 1)))).

References isFreeingFunction().

Referenced by isFreeingFunction().

◆ isGslOwnerType() [1/2]

bool clang ::lifetimes::isGslOwnerType ( const CXXRecordDecl * RD)

◆ isGslOwnerType() [2/2]

bool clang ::lifetimes::isGslOwnerType ( QualType QT)

◆ isGslPointerType()

bool clang ::lifetimes::isGslPointerType ( QualType QT)

◆ isInStlNamespace()

bool clang ::lifetimes::isInStlNamespace ( const Decl * D)

References isInStlNamespace().

Referenced by isInStlNamespace().

◆ isInvalidationMethod()

bool clang ::lifetimes::isInvalidationMethod ( const CXXMethodDecl & MD)

References isInvalidationMethod().

Referenced by isInvalidationMethod().

◆ isNormalAssignmentOperator()

bool clang ::lifetimes::isNormalAssignmentOperator ( const FunctionDecl * FD)

◆ isOwnerPtrCtor()

bool clang ::lifetimes::isOwnerPtrCtor ( const CXXConstructorDecl * Ctor,
const ParmVarDecl * PVD )

References isOwnerPtrCtor().

Referenced by isOwnerPtrCtor().

◆ isPointerLikeType()

bool clang ::lifetimes::isPointerLikeType ( QualType QT)

References isPointerLikeType().

Referenced by isPointerLikeType().

◆ isStdCallableWrapperType()

bool clang ::lifetimes::isStdCallableWrapperType ( const CXXRecordDecl * RD)

Returns true for standard library callable wrappers (e.g., std::function) that can propagate the stored lambda's origins.

References isStdCallableWrapperType().

Referenced by isStdCallableWrapperType().

◆ isStdReferenceCast()

bool clang ::lifetimes::isStdReferenceCast ( const FunctionDecl * FD)

Returns true for std reference-cast builtins (e.g., std::move).

Their result refers to the same object as the argument, so all origins propagate from argument to result.

References isStdReferenceCast().

Referenced by isStdReferenceCast().

◆ isUniquePtrRelease()

bool clang ::lifetimes::isUniquePtrRelease ( const CXXMethodDecl & MD)

References isUniquePtrRelease().

Referenced by isUniquePtrRelease().

◆ paramIsLifetimeBound()

bool clang ::lifetimes::paramIsLifetimeBound ( const ParmVarDecl & PVD)

Returns true if PVD should be considered lifetimebound, either due to an explicit lifetimebound attribute or because it is a constructor parameter marked lifetime_capture_by(this), which has the same meaning.

References paramIsLifetimeBound().

Referenced by paramIsLifetimeBound().

◆ shouldTrackFirstArgument()

bool clang ::lifetimes::shouldTrackFirstArgument ( const FunctionDecl * FD)

◆ shouldTrackImplicitObjectArg()

bool clang ::lifetimes::shouldTrackImplicitObjectArg ( const Expr & ImplicitObjectArgument,
const CXXMethodDecl * Callee,
bool RunningUnderLifetimeSafety )

◆ shouldTrackSecondArgument()

bool clang ::lifetimes::shouldTrackSecondArgument ( const FunctionDecl * FD)