CurContext during variable capture for Lambda

I was going through the Sema::tryCaptureVariable function. I noticed that when PerformCopyInitialization is called for variables of record types, it eventually does the lookup and resolution of the copy constructor for those types. During that entire machinery, the Sema::CurContext is set to the MethodDecl of the operator() of the Lambda. Given that the copy actually happens outside the operator() of the lambda, shouldn’t CurContext point to the parent context during that time? Or am I missing something?

Manjunath

Your analysis appears to be correct. That said, I can't think of any
case where it would actually make a difference...

-Eli

Your analysis appears to be correct. That said, I can’t think of any
case where it would actually make a difference…

It did make a difference for a personal project of mine. I got around it by doing “ContextRAII SavedContext(*this, CurContext->getParent());” at appropriate places. The omission definitely violates the invariant on CurContext. But I don’t know how to rate its severity as it doesn’t make a difference in practice. I will leave it up to the experts to decide if this is actionable.