================ @@ -15504,10 +15504,25 @@ LambdaScopeInfo *Sema::RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator) { LSI->CallOperator = CallOperator; LSI->Lambda = LambdaClass; LSI->ReturnType = CallOperator->getReturnType(); - // This function in calls in situation where the context of the call operator - // is not entered, so we set AfterParameterList to false, so that + // When this function is called in situation where the context of the call + // operator is not entered, we set AfterParameterList to false, so that // `tryCaptureVariable` finds explicit captures in the appropriate context. - LSI->AfterParameterList = false; + // + // There is also at least a situation as in FinishTemplateArgumentDeduction(), + // where we would set the CurContext to the lambda operator before + // substituting into it. In this case the flag needs to be true such that + // tryCaptureVariable can correctly handle potential captures thereof. + LSI->AfterParameterList = CurContext == CallOperator; + // GLTemplateParameterList is necessary for getCurGenericLambda() which is ---------------- erichkeane wrote:
I would like a new-line right above this comment (after the actual source), as it makes it REALLY easy to miss that line of code here. https://github.com/llvm/llvm-project/pull/118176 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits