clang 20.0.0git
EnterExpressionEvaluationContext.h
Go to the documentation of this file.
1//===--- EnterExpressionEvaluationContext.h ---------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_SEMA_ENTEREXPRESSIONEVALUATIONCONTEXT_H
10#define LLVM_CLANG_SEMA_ENTEREXPRESSIONEVALUATIONCONTEXT_H
11
12#include "clang/Sema/Sema.h"
13
14namespace clang {
15
16class Decl;
17
18/// RAII object that enters a new expression evaluation context.
20 Sema &Actions;
21 bool Entered = true;
22
23public:
25 Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
26 Decl *LambdaContextDecl = nullptr,
29 bool ShouldEnter = true)
30 : Actions(Actions), Entered(ShouldEnter) {
31 if (Entered)
32 Actions.PushExpressionEvaluationContext(NewContext, LambdaContextDecl,
33 ExprContext);
34 }
36 Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
40 : Actions(Actions) {
42 NewContext, Sema::ReuseLambdaContextDecl, ExprContext);
43 }
44
47 bool ShouldEnter = true)
48 : Actions(Actions), Entered(false) {
49 // In C++11 onwards, narrowing checks are performed on the contents of
50 // braced-init-lists, even when they occur within unevaluated operands.
51 // Therefore we still need to instantiate constexpr functions used in such
52 // a context.
53 if (ShouldEnter && Actions.isUnevaluatedContext() &&
54 Actions.getLangOpts().CPlusPlus11) {
57 Entered = true;
58 }
59 }
60
62 if (Entered)
64 }
65};
66
67} // namespace clang
68
69#endif
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
RAII object that enters a new expression evaluation context.
EnterExpressionEvaluationContext(Sema &Actions, InitListTag, bool ShouldEnter=true)
EnterExpressionEvaluationContext(Sema &Actions, Sema::ExpressionEvaluationContext NewContext, Sema::ReuseLambdaContextDecl_t, Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext=Sema::ExpressionEvaluationContextRecord::EK_Other)
EnterExpressionEvaluationContext(Sema &Actions, Sema::ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext=Sema::ExpressionEvaluationContextRecord::EK_Other, bool ShouldEnter=true)
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:463
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
Definition: SemaExpr.cpp:17380
void PopExpressionEvaluationContext()
Definition: SemaExpr.cpp:17813
const LangOptions & getLangOpts() const
Definition: Sema.h:524
ReuseLambdaContextDecl_t
Definition: Sema.h:6524
@ ReuseLambdaContextDecl
Definition: Sema.h:6524
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.
Definition: Sema.h:7770
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all.
Definition: Sema.h:6224
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
The JSON file list parser is used to communicate input to InstallAPI.
#define false
Definition: stdbool.h:26
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Definition: Sema.h:6343