Due to not resetting that, clang still thinks that it is in immediate
function context even if it already entered non-consteval function.
This caused consteval functions reaching codegen in some cases.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks, for working on this
Congrats on finding the underlying issue, it must not have been easy!
clang/lib/Sema/SemaDecl.cpp | ||
---|---|---|
15177 | I think it might be worth adding a comment there to explain why this is necessary. | |
clang/test/CodeGenCXX/cxx20-consteval-crash.cpp | ||
138 | Just to make sure, did you check that this fixes the other examples in the issue? I was afraid i reduced too much |
clang/lib/Sema/SemaDecl.cpp | ||
---|---|---|
15187 | I am a bit concerned that we are updating InImmediateFunctionContext outside of PushExpressionEvaluationContext. So we are now spreading the logic outside of where it was originally contained. I am wondering if instead inside of PushExpressionEvaluationContext we could set InImmediateFunctionContext like so: ExprEvalContexts.back().InImmediateFunctionContext = ExprEvalContexts[ExprEvalContexts.size() - 2] .isImmediateFunctionContext() || NewContext == ImmediateFunctionContext; or something along those lines. |
clang/lib/Sema/SemaDecl.cpp | ||
---|---|---|
15187 | Here isImmediateFunctionContext() will be true, we want it to be false If we wanted to do somelink like what you are suggesting, we'd need something like a new EnteringFunctionDefinitionContext boolean parameter to PushExpressionEvaluationContext. so that Given that we should only get in that situation from ActOnStartOfFunctionDef, I'm not sure that would be a better design |