================
@@ -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);
----------------
MitalAshok wrote:

```suggestion
    EnterExpressionEvaluationContext Ctx(
        getSema(), Sema::ExpressionEvaluationContext::ImmediateFunctionContext, 
nullptr,
        Sema::ExpressionEvaluationContextRecord::EK_Other,
        S->isNonNegatedConsteval());
```

(and ditto for the else branch) to only push a context if needed

https://github.com/llvm/llvm-project/pull/91939
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to