diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-04 17:17:20 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-04 17:17:20 +0000 |
commit | 7bf8f6fa8ab123fe97ccd82d9a0ddff85505ee5f (patch) | |
tree | c5eb10d1d4e1f82ebd3925ca1bde79d1145d73e3 /clang/lib/Sema/SemaTemplateInstantiate.cpp | |
parent | f4302ad35e340f01529bf32919410b2577f899bd (diff) | |
download | bcm5719-llvm-7bf8f6fa8ab123fe97ccd82d9a0ddff85505ee5f.tar.gz bcm5719-llvm-7bf8f6fa8ab123fe97ccd82d9a0ddff85505ee5f.zip |
PR42104: Support instantiations of lambdas that implicitly capture
packs.
Two changes:
* Track odr-use via FunctionParmPackExprs to properly handle dependent
odr-uses of packs in generic lambdas.
* Do not instantiate implicit captures; instead, regenerate them by
instantiating the body of the lambda. This is necessary to
distinguish between cases where only one element of a pack is
captured and cases where the entire pack is captured.
This reinstates r362358 (reverted in r362375) with a fix for an
uninitialized variable use in UpdateMarkingForLValueToRValue.
llvm-svn: 362531
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index ba54d5010ba..973f564d305 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1368,9 +1368,11 @@ TemplateInstantiator::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) { Vars.push_back(D); } - return FunctionParmPackExpr::Create(getSema().Context, T, - E->getParameterPack(), - E->getParameterPackLocation(), Vars); + auto *PackExpr = + FunctionParmPackExpr::Create(getSema().Context, T, E->getParameterPack(), + E->getParameterPackLocation(), Vars); + getSema().MarkFunctionParmPackReferenced(PackExpr); + return PackExpr; } ExprResult @@ -1389,8 +1391,10 @@ TemplateInstantiator::TransformFunctionParmPackRefExpr(DeclRefExpr *E, QualType T = TransformType(E->getType()); if (T.isNull()) return ExprError(); - return FunctionParmPackExpr::Create(getSema().Context, T, PD, - E->getExprLoc(), *Pack); + auto *PackExpr = FunctionParmPackExpr::Create(getSema().Context, T, PD, + E->getExprLoc(), *Pack); + getSema().MarkFunctionParmPackReferenced(PackExpr); + return PackExpr; } TransformedDecl = (*Pack)[getSema().ArgumentPackSubstitutionIndex]; |