This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Reviewers
rsmith
cor3ntin
Group Reviewers
Restricted Project
Summary

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.

Fixes https://github.com/llvm/llvm-project/issues/63677

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?

Thanks!

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.
clang/test/SemaCXX/lambda-pack-expansion.cpp
36

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
clang/lib/Sema/TreeTransform.h
13323

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.
clang/lib/Sema/TreeTransform.h
13323

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?