[clang] [Clang] Ensure ``if consteval`` consititute an immediate function context (PR #91939)

via cfe-commits cfe-commits at lists.llvm.org
Mon May 13 03:40:25 PDT 2024


================
@@ -7964,6 +7964,15 @@ TreeTransform<Derived>::TransformIfStmt(IfStmt *S) {
   // Transform the "then" branch.
   StmtResult Then;
   if (!ConstexprConditionValue || *ConstexprConditionValue) {
+    Sema::ExpressionEvaluationContext Context =
+        S->isNonNegatedConsteval()
+            ? Sema::ExpressionEvaluationContext::ImmediateFunctionContext
+            : Sema::ExpressionEvaluationContext::PotentiallyEvaluated;
+
+    EnterExpressionEvaluationContext Ctx(
+        getSema(), Context, nullptr,
+        Sema::ExpressionEvaluationContextRecord::EK_Other);
----------------
cor3ntin wrote:

You are right, it's nicer this way, thanks.

https://github.com/llvm/llvm-project/pull/91939


More information about the cfe-commits mailing list