[clang] [Sema] Preserve ContainsUnexpandedParameterPack in TransformLambdaExpr (PR #86265)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 04:25:37 PDT 2024
================
@@ -14636,6 +14645,20 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
/*IsInstantiation*/ true);
SavedContext.pop();
+ // Parts other than the capture e.g. the lambda body might still contain a
+ // pattern that an outer fold expression would expand.
+ //
+ // We don't have a way to propagate up the ContainsUnexpandedParameterPack
+ // flag from a Stmt, so we have to revisit the lambda.
+ if (!LSICopy.ContainsUnexpandedParameterPack) {
+ llvm::SmallVector<UnexpandedParameterPack> UnexpandedPacks;
+ getSema().collectUnexpandedParameterPacksFromLambda(NewCallOperator,
+ UnexpandedPacks);
+ // FIXME: Should we call Sema::DiagnoseUnexpandedParameterPacks() instead?
+ // Unfortunately, that requires the LambdaScopeInfo to exist, which has been
+ // removed by ActOnFinishFunctionBody().
+ LSICopy.ContainsUnexpandedParameterPack = !UnexpandedPacks.empty();
+ }
----------------
zyn0217 wrote:
We probably need a refactor here to teach `ActOnFinishFunctionBody()` not to pop the LSI eventually. How about leaving it as an NFC?
https://github.com/llvm/llvm-project/pull/86265
More information about the cfe-commits
mailing list