================ @@ -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:
Despite these, I have another concern on performance issue after some deliberation. This is actually a workaround given that we don't have any flags on a `Stmt` to tell whether it contains unexpanded expressions - what we do now leads to visiting the lambda body twice, which might cause some impact in lambda instantiation, if the body is large enough. A compromise is, we remove this traversal in this patch and *leave it for future fixes*. (Sigh!) https://github.com/llvm/llvm-project/pull/86265 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits