Ensure that the correct information whether an init-capture of a lambda
is passed by reference or by copy. This information is already computed
and has to be passed to the place where NewInitCaptureType is
created.
Before this fix it has been checked whether the VarDecl is a reference
type. This doesn't work for packed expansions, as the information
whether it is passed by reference or by copy is stored at the pattern of
a PackExpansionType and not at the type itself.
However, as the information has been already computed, we just have to
pass it.
Add test that lambda captures with var decls which are reference types
are created in the AST.
Fixes #49266
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.