clang 20.0.0git
Classes | Enumerations | Functions
clang::sema Namespace Reference

Classes

class  AccessedEntity
 A declaration being accessed, together with information about how it was accessed. More...
 
class  AnalysisBasedWarnings
 
struct  AssignedEntity
 Describes an entity that is being assigned. More...
 
class  BlockScopeInfo
 Retains information about a block that is currently being parsed. More...
 
class  Capture
 
class  CapturedRegionScopeInfo
 Retains information about a captured region. More...
 
class  CapturingScopeInfo
 
class  CompoundScopeInfo
 Contains information about the compound statement currently being parsed. More...
 
class  DelayedDiagnostic
 A diagnostic message which has been conditionally emitted pending the complete parsing of the current declaration. More...
 
class  DelayedDiagnosticPool
 A collection of diagnostics which were delayed. More...
 
class  FunctionScopeInfo
 Retains information about a function, method, or block that is currently being parsed. More...
 
class  LambdaScopeInfo
 
class  PossiblyUnreachableDiag
 
class  RISCVIntrinsicManager
 
class  SemaPPCallbacks
 
class  TemplateDeductionInfo
 Provides information about an attempted template argument deduction, whose success or failure was described by a TemplateDeductionResult value. More...
 

Enumerations

enum class  FirstCoroutineStmtKind { CoReturn , CoAwait , CoYield }
 
enum  PathLifetimeKind { Extend , ShouldExtend , NoExtend }
 Whether a path to an object supports lifetime extension. More...
 

Functions

static LifetimeResult getEntityLifetime (const InitializedEntity *Entity, const InitializedEntity *InitField=nullptr)
 Determine the declaration which an initialized entity ultimately refers to, for the purpose of lifetime-extending a temporary bound to a reference in the initialization of Entity.
 
static bool isVarOnPath (IndirectLocalPath &Path, VarDecl *VD)
 
static bool pathContainsInit (IndirectLocalPath &Path)
 
static void visitLocalsRetainedByInitializer (IndirectLocalPath &Path, Expr *Init, LocalVisitor Visit, bool RevisitSubinits, bool EnableLifetimeWarnings)
 Visit the locals that would be reachable through an object initialized by the prvalue expression Init.
 
static void visitLocalsRetainedByReferenceBinding (IndirectLocalPath &Path, Expr *Init, ReferenceKind RK, LocalVisitor Visit, bool EnableLifetimeWarnings)
 Visit the locals that would be reachable through a reference bound to the glvalue expression Init.
 
template<typename T >
static bool isRecordWithAttr (QualType Type)
 
static bool isInStlNamespace (const Decl *D)
 
static bool shouldTrackImplicitObjectArg (const CXXMethodDecl *Callee)
 
static bool shouldTrackFirstArgument (const FunctionDecl *FD)
 
static void handleGslAnnotatedTypes (IndirectLocalPath &Path, Expr *Call, LocalVisitor Visit)
 
static bool implicitObjectParamIsLifetimeBound (const FunctionDecl *FD)
 
static void visitLifetimeBoundArguments (IndirectLocalPath &Path, Expr *Call, LocalVisitor Visit)
 
static PathLifetimeKind shouldLifetimeExtendThroughPath (const IndirectLocalPath &Path)
 Determine whether this is an indirect path to a temporary that we are supposed to lifetime-extend along.
 
static SourceRange nextPathEntryRange (const IndirectLocalPath &Path, unsigned I, Expr *E)
 Find the range for the first interesting entry in the path at or after I.
 
static bool pathOnlyHandlesGslPointer (IndirectLocalPath &Path)
 
static void checkExprLifetimeImpl (Sema &SemaRef, const InitializedEntity *InitEntity, const InitializedEntity *ExtendingEntity, LifetimeKind LK, const AssignedEntity *AEntity, Expr *Init, bool EnableLifetimeWarnings)
 
void checkExprLifetime (Sema &SemaRef, const InitializedEntity &Entity, Expr *Init)
 Check that the lifetime of the given expr (and its subobjects) is sufficient for initializing the entity, and perform lifetime extension (when permitted) if not.
 
void checkExprLifetime (Sema &SemaRef, const AssignedEntity &Entity, Expr *Init)
 Check that the lifetime of the given expr (and its subobjects) is sufficient for assigning to the entity.
 
AttrinstantiateTemplateAttribute (const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
 
AttrinstantiateTemplateAttributeForDecl (const Attr *At, ASTContext &C, Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs)
 

Enumeration Type Documentation

◆ FirstCoroutineStmtKind

Enumerator
CoReturn 
CoAwait 
CoYield 

Definition at line 100 of file ScopeInfo.h.

◆ PathLifetimeKind

Whether a path to an object supports lifetime extension.

Enumerator
Extend 

Lifetime-extend along this path.

ShouldExtend 

We should lifetime-extend, but we don't because (due to technical limitations) we can't.

This happens for default member initializers, which we don't clone for every use, so we don't have a unique MaterializeTemporaryExpr to update.

NoExtend 

Do not lifetime extend along this path.

Definition at line 912 of file CheckExprLifetime.cpp.

Function Documentation

◆ checkExprLifetime() [1/2]

void clang::sema::checkExprLifetime ( Sema SemaRef,
const AssignedEntity Entity,
Expr Init 
)

Check that the lifetime of the given expr (and its subobjects) is sufficient for assigning to the entity.

Definition at line 1313 of file CheckExprLifetime.cpp.

References checkExprLifetime(), checkExprLifetimeImpl(), clang::Sema::getDiagnostics(), clang::Expr::getType(), clang::DiagnosticsEngine::isIgnored(), clang::Type::isPointerType(), and clang::sema::AssignedEntity::LHS.

◆ checkExprLifetime() [2/2]

void clang::sema::checkExprLifetime ( Sema SemaRef,
const InitializedEntity Entity,
Expr Init 
)

Check that the lifetime of the given expr (and its subobjects) is sufficient for initializing the entity, and perform lifetime extension (when permitted) if not.

Definition at line 1302 of file CheckExprLifetime.cpp.

References checkExprLifetime(), checkExprLifetimeImpl(), clang::Sema::getDiagnostics(), getEntityLifetime(), and clang::DiagnosticsEngine::isIgnored().

Referenced by clang::Sema::CheckAssignmentOperands(), checkExprLifetime(), clang::Sema::checkInitializerLifetime(), and clang::Sema::CreateOverloadedBinOp().

◆ checkExprLifetimeImpl()

static void clang::sema::checkExprLifetimeImpl ( Sema SemaRef,
const InitializedEntity InitEntity,
const InitializedEntity ExtendingEntity,
LifetimeKind  LK,
const AssignedEntity AEntity,
Expr Init,
bool  EnableLifetimeWarnings 
)
static

◆ getEntityLifetime()

static LifetimeResult clang::sema::getEntityLifetime ( const InitializedEntity Entity,
const InitializedEntity InitField = nullptr 
)
static

◆ handleGslAnnotatedTypes()

static void clang::sema::handleGslAnnotatedTypes ( IndirectLocalPath &  Path,
Expr Call,
LocalVisitor  Visit 
)
static

◆ implicitObjectParamIsLifetimeBound()

static bool clang::sema::implicitObjectParamIsLifetimeBound ( const FunctionDecl FD)
static

◆ instantiateTemplateAttribute()

Attr * clang::sema::instantiateTemplateAttribute ( const Attr At,
ASTContext C,
Sema S,
const MultiLevelTemplateArgumentList TemplateArgs 
)

◆ instantiateTemplateAttributeForDecl()

Attr * clang::sema::instantiateTemplateAttributeForDecl ( const Attr At,
ASTContext C,
Sema S,
const MultiLevelTemplateArgumentList TemplateArgs 
)

◆ isInStlNamespace()

static bool clang::sema::isInStlNamespace ( const Decl D)
static

◆ isRecordWithAttr()

template<typename T >
static bool clang::sema::isRecordWithAttr ( QualType  Type)
static

Definition at line 248 of file CheckExprLifetime.cpp.

References clang::Type::getAsCXXRecordDecl(), and clang::T.

◆ isVarOnPath()

static bool clang::sema::isVarOnPath ( IndirectLocalPath &  Path,
VarDecl VD 
)
static

Definition at line 224 of file CheckExprLifetime.cpp.

References E, and Path.

Referenced by visitLocalsRetainedByInitializer(), and visitLocalsRetainedByReferenceBinding().

◆ nextPathEntryRange()

static SourceRange clang::sema::nextPathEntryRange ( const IndirectLocalPath &  Path,
unsigned  I,
Expr E 
)
static

Find the range for the first interesting entry in the path at or after I.

Definition at line 939 of file CheckExprLifetime.cpp.

References D, E, Kind, and Path.

Referenced by checkExprLifetimeImpl().

◆ pathContainsInit()

static bool clang::sema::pathContainsInit ( IndirectLocalPath &  Path)
static

Definition at line 231 of file CheckExprLifetime.cpp.

References E, and Path.

Referenced by checkExprLifetimeImpl().

◆ pathOnlyHandlesGslPointer()

static bool clang::sema::pathOnlyHandlesGslPointer ( IndirectLocalPath &  Path)
static

Definition at line 970 of file CheckExprLifetime.cpp.

References Path.

Referenced by checkExprLifetimeImpl().

◆ shouldLifetimeExtendThroughPath()

static PathLifetimeKind clang::sema::shouldLifetimeExtendThroughPath ( const IndirectLocalPath &  Path)
static

Determine whether this is an indirect path to a temporary that we are supposed to lifetime-extend along.

Definition at line 927 of file CheckExprLifetime.cpp.

References Extend, Kind, NoExtend, Path, and ShouldExtend.

Referenced by checkExprLifetimeImpl().

◆ shouldTrackFirstArgument()

static bool clang::sema::shouldTrackFirstArgument ( const FunctionDecl FD)
static

◆ shouldTrackImplicitObjectArg()

static bool clang::sema::shouldTrackImplicitObjectArg ( const CXXMethodDecl Callee)
static

Definition at line 272 of file CheckExprLifetime.cpp.

References isInStlNamespace().

Referenced by handleGslAnnotatedTypes().

◆ visitLifetimeBoundArguments()

static void clang::sema::visitLifetimeBoundArguments ( IndirectLocalPath &  Path,
Expr Call,
LocalVisitor  Visit 
)
static

◆ visitLocalsRetainedByInitializer()

static void clang::sema::visitLocalsRetainedByInitializer ( IndirectLocalPath &  Path,
Expr Init,
LocalVisitor  Visit,
bool  RevisitSubinits,
bool  EnableLifetimeWarnings 
)
static

◆ visitLocalsRetainedByReferenceBinding()

static void clang::sema::visitLocalsRetainedByReferenceBinding ( IndirectLocalPath &  Path,
Expr Init,
ReferenceKind  RK,
LocalVisitor  Visit,
bool  EnableLifetimeWarnings 
)
static