[clang] [Clang] Ensure ``if consteval`` consititute an immediate function context (PR #91939)
Mital Ashok via cfe-commits
cfe-commits at lists.llvm.org
Mon May 13 03:16:56 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);
----------------
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
More information about the cfe-commits
mailing list