Page MenuHomePhabricator

Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline

[SemaCXX] Fix bug where unexpanded lambda captures where assumed to be expanded

Authored by MitalAshok on Jul 7 2023, 6:37 AM.


Group Reviewers
Restricted Project

When instantiating the closure type of a lambda in a template, sometimes a capture which is a pack is not expanded. When that happens, it is replaced with a pack of size 1 containing that pack. Before it is replaced by another instantiation where the pack is expanded, the size is reported to be 1 instead of unknown.

This checks if this is happening (i.e., trying to replace a pack declaration with a single declaration that is itself a pack), and not expanding it out in that case.


Diff Detail

Event Timeline

MitalAshok created this revision.Jul 7 2023, 6:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 6:37 AM
MitalAshok published this revision for review.Jul 7 2023, 6:53 AM
MitalAshok edited the summary of this revision. (Show Details)
MitalAshok added reviewers: rsmith, cor3ntin.
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 6:54 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This looks reasonable to me.
But can you add an entry into clang/docs/ReleaseNotes.rst?


cor3ntin added a reviewer: Restricted Project.Jul 12 2023, 7:20 AM
shafik added a subscriber: shafik.Jul 12 2023, 3:37 PM
shafik added inline comments.

Can we also have an example similar to the bug report where we have multiple arguments.

shafik added inline comments.Jul 12 2023, 3:47 PM

Based on the changes is this comment still accurate?

MitalAshok edited the summary of this revision. (Show Details)

Added entry to changelog and the test from the bug report

MitalAshok marked an inline comment as done.Jul 22 2023, 7:07 AM
MitalAshok added inline comments.

Yes, the code was just changed so it's more clear that the result either has N distinct arguments for a pack of size N or just 1 argument with a (possible dependent) pack type

cor3ntin accepted this revision.Jul 24 2023, 12:18 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jul 24 2023, 12:18 AM

@MitalAshok Are you still working on this? Do you need further help on this patch? You have commit access, correct?