clang 19.0.0git
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
clang::Sema::ExpressionEvaluationContextRecord Struct Reference

Data structure used to record current or nested expression evaluation contexts. More...

#include "clang/Sema/Sema.h"

Classes

struct  InitializationContext
 

Public Types

enum  ExpressionKind { EK_Decltype , EK_TemplateArgument , EK_BoundsAttrArgument , EK_Other }
 Describes whether we are in an expression constext which we have to handle differently. More...
 

Public Member Functions

 ExpressionEvaluationContextRecord (ExpressionEvaluationContext Context, unsigned NumCleanupObjects, CleanupInfo ParentCleanup, Decl *ManglingContextDecl, ExpressionKind ExprContext)
 
bool isUnevaluated () const
 
bool isConstantEvaluated () const
 
bool isImmediateFunctionContext () const
 
bool isDiscardedStatementContext () const
 

Public Attributes

ExpressionEvaluationContext Context
 The expression evaluation context.
 
CleanupInfo ParentCleanup
 Whether the enclosing context needed a cleanup.
 
unsigned NumCleanupObjects
 The number of active cleanup objects when we entered this expression evaluation context.
 
unsigned NumTypos
 The number of typos encountered during this expression evaluation context (i.e.
 
MaybeODRUseExprSet SavedMaybeODRUseExprs
 
SmallVector< LambdaExpr *, 2 > Lambdas
 The lambdas that are present within this context, if it is indeed an unevaluated context.
 
DeclManglingContextDecl
 The declaration that provides context for lambda expressions and block literals if the normal declaration context does not suffice, e.g., in a default function argument.
 
SmallVector< CallExpr *, 8 > DelayedDecltypeCalls
 If we are processing a decltype type, a set of call expressions for which we have deferred checking the completeness of the return type.
 
SmallVector< CXXBindTemporaryExpr *, 8 > DelayedDecltypeBinds
 If we are processing a decltype type, a set of temporary binding expressions for which we have deferred checking the destructor.
 
llvm::SmallPtrSet< const Expr *, 8 > PossibleDerefs
 
SmallVector< Expr *, 2 > VolatileAssignmentLHSs
 Expressions appearing as the LHS of a volatile assignment in this context.
 
llvm::SmallVector< ImmediateInvocationCandidate, 4 > ImmediateInvocationCandidates
 Set of candidates for starting an immediate invocation.
 
llvm::SmallPtrSet< DeclRefExpr *, 4 > ReferenceToConsteval
 Set of DeclRefExprs referencing a consteval function when used in a context not already known to be immediately invoked.
 
SmallVector< MaterializeTemporaryExpr *, 8 > ForRangeLifetimeExtendTemps
 P2718R0 - Lifetime extension in range-based for loops.
 
enum clang::Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext
 
bool InDiscardedStatement
 
bool InImmediateFunctionContext
 
bool InImmediateEscalatingFunctionContext
 
bool IsCurrentlyCheckingDefaultArgumentOrInitializer = false
 
bool InConditionallyConstantEvaluateContext = false
 
bool InLifetimeExtendingContext = false
 Whether we are currently in a context in which all temporaries must be lifetime-extended, even if they're not bound to a reference (for example, in a for-range initializer).
 
bool InMaterializeTemporaryObjectContext = false
 Whether we are currently in a context in which all temporaries must be materialized.
 
std::optional< InitializationContextDelayedDefaultInitializationContext
 

Detailed Description

Data structure used to record current or nested expression evaluation contexts.

Definition at line 5186 of file Sema.h.

Member Enumeration Documentation

◆ ExpressionKind

Describes whether we are in an expression constext which we have to handle differently.

Enumerator
EK_Decltype 
EK_TemplateArgument 
EK_BoundsAttrArgument 
EK_Other 

Definition at line 5243 of file Sema.h.

Constructor & Destructor Documentation

◆ ExpressionEvaluationContextRecord()

clang::Sema::ExpressionEvaluationContextRecord::ExpressionEvaluationContextRecord ( ExpressionEvaluationContext  Context,
unsigned  NumCleanupObjects,
CleanupInfo  ParentCleanup,
Decl ManglingContextDecl,
ExpressionKind  ExprContext 
)
inline

Definition at line 5313 of file Sema.h.

Member Function Documentation

◆ isConstantEvaluated()

bool clang::Sema::ExpressionEvaluationContextRecord::isConstantEvaluated ( ) const
inline

◆ isDiscardedStatementContext()

bool clang::Sema::ExpressionEvaluationContextRecord::isDiscardedStatementContext ( ) const
inline

Definition at line 5350 of file Sema.h.

◆ isImmediateFunctionContext()

bool clang::Sema::ExpressionEvaluationContextRecord::isImmediateFunctionContext ( ) const
inline

Definition at line 5335 of file Sema.h.

Referenced by clang::Sema::isImmediateFunctionContext().

◆ isUnevaluated()

bool clang::Sema::ExpressionEvaluationContextRecord::isUnevaluated ( ) const
inline

Member Data Documentation

◆ Context

ExpressionEvaluationContext clang::Sema::ExpressionEvaluationContextRecord::Context

The expression evaluation context.

Definition at line 5188 of file Sema.h.

Referenced by HandleImmediateInvocations(), and clang::Sema::isCheckingDefaultArgumentOrInitializer().

◆ DelayedDecltypeBinds

SmallVector<CXXBindTemporaryExpr *, 8> clang::Sema::ExpressionEvaluationContextRecord::DelayedDecltypeBinds

If we are processing a decltype type, a set of temporary binding expressions for which we have deferred checking the destructor.

Definition at line 5218 of file Sema.h.

◆ DelayedDecltypeCalls

SmallVector<CallExpr *, 8> clang::Sema::ExpressionEvaluationContextRecord::DelayedDecltypeCalls

If we are processing a decltype type, a set of call expressions for which we have deferred checking the completeness of the return type.

Definition at line 5214 of file Sema.h.

◆ DelayedDefaultInitializationContext

std::optional<InitializationContext> clang::Sema::ExpressionEvaluationContextRecord::DelayedDefaultInitializationContext

Definition at line 5311 of file Sema.h.

◆ ExprContext

enum clang::Sema::ExpressionEvaluationContextRecord::ExpressionKind clang::Sema::ExpressionEvaluationContextRecord::ExprContext

◆ ForRangeLifetimeExtendTemps

SmallVector<MaterializeTemporaryExpr *, 8> clang::Sema::ExpressionEvaluationContextRecord::ForRangeLifetimeExtendTemps

P2718R0 - Lifetime extension in range-based for loops.

MaterializeTemporaryExprs in for-range-init expressions which need to extend lifetime. Add MaterializeTemporaryExpr* if the value of InLifetimeExtendingContext is true.

Definition at line 5239 of file Sema.h.

Referenced by clang::Sema::PopExpressionEvaluationContext().

◆ ImmediateInvocationCandidates

llvm::SmallVector<ImmediateInvocationCandidate, 4> clang::Sema::ExpressionEvaluationContextRecord::ImmediateInvocationCandidates

Set of candidates for starting an immediate invocation.

Definition at line 5229 of file Sema.h.

Referenced by HandleImmediateInvocations(), and RemoveNestedImmediateInvocation().

◆ InConditionallyConstantEvaluateContext

bool clang::Sema::ExpressionEvaluationContextRecord::InConditionallyConstantEvaluateContext = false

Definition at line 5261 of file Sema.h.

Referenced by clang::Sema::isAlwaysConstantEvaluatedContext().

◆ InDiscardedStatement

bool clang::Sema::ExpressionEvaluationContextRecord::InDiscardedStatement

Definition at line 5252 of file Sema.h.

◆ InImmediateEscalatingFunctionContext

bool clang::Sema::ExpressionEvaluationContextRecord::InImmediateEscalatingFunctionContext

Definition at line 5254 of file Sema.h.

Referenced by HandleImmediateInvocations().

◆ InImmediateFunctionContext

bool clang::Sema::ExpressionEvaluationContextRecord::InImmediateFunctionContext

Definition at line 5253 of file Sema.h.

◆ InLifetimeExtendingContext

bool clang::Sema::ExpressionEvaluationContextRecord::InLifetimeExtendingContext = false

Whether we are currently in a context in which all temporaries must be lifetime-extended, even if they're not bound to a reference (for example, in a for-range initializer).

Definition at line 5266 of file Sema.h.

◆ InMaterializeTemporaryObjectContext

bool clang::Sema::ExpressionEvaluationContextRecord::InMaterializeTemporaryObjectContext = false

Whether we are currently in a context in which all temporaries must be materialized.

[class.temporary]/p2: The materialization of a temporary object is generally delayed as long as possible in order to avoid creating unnecessary temporary objects.

Temporary objects are materialized: (2.1) when binding a reference to a prvalue ([dcl.init.ref], [expr.type.conv], [expr.dynamic.cast], [expr.static.cast], [expr.const.cast], [expr.cast]),

(2.2) when performing member access on a class prvalue ([expr.ref], [expr.mptr.oper]),

(2.3) when performing an array-to-pointer conversion or subscripting on an array prvalue ([conv.array], [expr.sub]),

(2.4) when initializing an object of type std​::​initializer_list<T> from a braced-init-list ([dcl.init.list]),

(2.5) for certain unevaluated operands ([expr.typeid], [expr.sizeof])

(2.6) when a prvalue that has type other than cv void appears as a discarded-value expression ([expr.context]).

Definition at line 5294 of file Sema.h.

◆ IsCurrentlyCheckingDefaultArgumentOrInitializer

bool clang::Sema::ExpressionEvaluationContextRecord::IsCurrentlyCheckingDefaultArgumentOrInitializer = false

Definition at line 5256 of file Sema.h.

Referenced by clang::Sema::isCheckingDefaultArgumentOrInitializer().

◆ Lambdas

SmallVector<LambdaExpr *, 2> clang::Sema::ExpressionEvaluationContextRecord::Lambdas

The lambdas that are present within this context, if it is indeed an unevaluated context.

Definition at line 5205 of file Sema.h.

Referenced by clang::Sema::PopExpressionEvaluationContext().

◆ ManglingContextDecl

Decl* clang::Sema::ExpressionEvaluationContextRecord::ManglingContextDecl

The declaration that provides context for lambda expressions and block literals if the normal declaration context does not suffice, e.g., in a default function argument.

Definition at line 5210 of file Sema.h.

◆ NumCleanupObjects

unsigned clang::Sema::ExpressionEvaluationContextRecord::NumCleanupObjects

The number of active cleanup objects when we entered this expression evaluation context.

Definition at line 5195 of file Sema.h.

Referenced by clang::Sema::PopExpressionEvaluationContext().

◆ NumTypos

unsigned clang::Sema::ExpressionEvaluationContextRecord::NumTypos

The number of typos encountered during this expression evaluation context (i.e.

the number of TypoExprs created).

Definition at line 5199 of file Sema.h.

Referenced by clang::Sema::PopExpressionEvaluationContext().

◆ ParentCleanup

CleanupInfo clang::Sema::ExpressionEvaluationContextRecord::ParentCleanup

Whether the enclosing context needed a cleanup.

Definition at line 5191 of file Sema.h.

Referenced by clang::Sema::PopExpressionEvaluationContext().

◆ PossibleDerefs

llvm::SmallPtrSet<const Expr *, 8> clang::Sema::ExpressionEvaluationContextRecord::PossibleDerefs

Definition at line 5220 of file Sema.h.

Referenced by clang::Sema::WarnOnPendingNoDerefs().

◆ ReferenceToConsteval

llvm::SmallPtrSet<DeclRefExpr *, 4> clang::Sema::ExpressionEvaluationContextRecord::ReferenceToConsteval

Set of DeclRefExprs referencing a consteval function when used in a context not already known to be immediately invoked.

Definition at line 5233 of file Sema.h.

Referenced by HandleImmediateInvocations(), and RemoveNestedImmediateInvocation().

◆ SavedMaybeODRUseExprs

MaybeODRUseExprSet clang::Sema::ExpressionEvaluationContextRecord::SavedMaybeODRUseExprs

Definition at line 5201 of file Sema.h.

Referenced by clang::Sema::PopExpressionEvaluationContext().

◆ VolatileAssignmentLHSs

SmallVector<Expr *, 2> clang::Sema::ExpressionEvaluationContextRecord::VolatileAssignmentLHSs

Expressions appearing as the LHS of a volatile assignment in this context.

We produce a warning for these when popping the context if they are not discarded-value expressions nor unevaluated operands.

Definition at line 5225 of file Sema.h.

Referenced by clang::Sema::PopExpressionEvaluationContext().


The documentation for this struct was generated from the following file: