File indexing completed on 2026-05-10 08:37:00
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_SEMA_ENTEREXPRESSIONEVALUATIONCONTEXT_H
0010 #define LLVM_CLANG_SEMA_ENTEREXPRESSIONEVALUATIONCONTEXT_H
0011
0012 #include "clang/Sema/Sema.h"
0013
0014 namespace clang {
0015
0016 class Decl;
0017
0018
0019 class EnterExpressionEvaluationContext {
0020 Sema &Actions;
0021 bool Entered = true;
0022
0023 public:
0024 EnterExpressionEvaluationContext(
0025 Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
0026 Decl *LambdaContextDecl = nullptr,
0027 Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext =
0028 Sema::ExpressionEvaluationContextRecord::EK_Other,
0029 bool ShouldEnter = true)
0030 : Actions(Actions), Entered(ShouldEnter) {
0031 if (Entered)
0032 Actions.PushExpressionEvaluationContext(NewContext, LambdaContextDecl,
0033 ExprContext);
0034 }
0035 EnterExpressionEvaluationContext(
0036 Sema &Actions, Sema::ExpressionEvaluationContext NewContext,
0037 Sema::ReuseLambdaContextDecl_t,
0038 Sema::ExpressionEvaluationContextRecord::ExpressionKind ExprContext =
0039 Sema::ExpressionEvaluationContextRecord::EK_Other)
0040 : Actions(Actions) {
0041 Actions.PushExpressionEvaluationContext(
0042 NewContext, Sema::ReuseLambdaContextDecl, ExprContext);
0043 }
0044
0045 enum InitListTag { InitList };
0046 EnterExpressionEvaluationContext(Sema &Actions, InitListTag,
0047 bool ShouldEnter = true)
0048 : Actions(Actions), Entered(false) {
0049
0050
0051
0052
0053 if (ShouldEnter && Actions.isUnevaluatedContext() &&
0054 Actions.getLangOpts().CPlusPlus11) {
0055 Actions.PushExpressionEvaluationContext(
0056 Sema::ExpressionEvaluationContext::UnevaluatedList);
0057 Entered = true;
0058 }
0059 }
0060
0061 ~EnterExpressionEvaluationContext() {
0062 if (Entered)
0063 Actions.PopExpressionEvaluationContext();
0064 }
0065 };
0066
0067 }
0068
0069 #endif