[PATCH] D139125: [clang] Correctly handle by-reference capture with an initializer that is a pack expansion in lambdas.

Jens Massberg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 7 00:55:39 PST 2022


massberg added inline comments.


================
Comment at: clang/lib/Sema/TreeTransform.h:13156
           getSema().buildLambdaInitCaptureInitialization(
-              C->getLocation(), OldVD->getType()->isReferenceType(),
+              C->getLocation(), isReferenceType,
               EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
----------------
massberg wrote:
> massberg wrote:
> > ilya-biryukov wrote:
> > > Could we use `C->getCaptureKind() == LCK_ByRef` instead?
> > > 
> > > It seems like that was the intention of the function in the first place (that's was the other callsite from the parser is doing): pass what was written by the user and let the function figure out how to actually build the types.
> > > Normally we want to unify the code that parser uses for non-dependent code and the tree-transforms where possible.
> > `C-getCaptureKind` is equal to `LCK_ByCopy`, even if the expansion pack is passed by refernece.
> I will check if this is by error and if it should be set to `LCK_ByRef` in case of references to pack expansions.
I have fixed the code and updated the description.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139125/new/

https://reviews.llvm.org/D139125



More information about the cfe-commits mailing list