This is an archive of the discontinued LLVM Phabricator instance.

[C++20] Determine the dependency of unevaluated lambdas more accurately
ClosedPublic

Authored by lime on Dec 22 2022, 7:02 AM.

Details

Summary

During template instantiation, the instantiator will enter constant evaluated
context before instantiate a template argument originated from an expression,
and this impedes the instantiator from creating lambdas with independent types.

This patch solves the problem via widening the condition that the instantiator
marks lambdas as never dependent, and fixes the issue #57960

Diff Detail

Event Timeline

lime created this revision.Dec 22 2022, 7:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2022, 7:02 AM
lime requested review of this revision.Dec 22 2022, 7:02 AM
lime edited the summary of this revision. (Show Details)Dec 22 2022, 7:06 AM

I am not sure if this is moving in the right direction or not, I will wait for @cor3ntin to chime in.

@shafik I'm not sure either it's the right direction but I don't think it makes the situation any worse.
And given I still don't really know what a proper fix would look like (except that it would probably be pretty involved), I think we might has well do that as an improvement of the pre existing workaround.

@lime Can you add a release note indicating the issue has been fixed? Thanks!

I agree with Corentin here, I've got no idea what the RIGHT solution looks like here, but this looks to be at least an improvement. 1 nit, plus need a release note. Otherwise LGTM.

clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
5

Nit: need a space after the name and before the {.

lime updated this revision to Diff 486591.Jan 5 2023, 8:23 AM

Added release notes.

lime updated this revision to Diff 486764.Jan 6 2023, 12:17 AM

Just rebased, and the check-profile target passed on my local machine.

cor3ntin accepted this revision.Jan 6 2023, 4:17 AM

Thanks. I think this looks good!

This revision is now accepted and ready to land.Jan 6 2023, 4:17 AM
lime added a comment.Jan 6 2023, 4:36 AM

Could you please help to commit this? My name and email are Liming Liu <gangliugangliu.ml@outlook.com>

Done, though I think it is more than time for you to ask for commit permissions.