D96215 takes care of the situation where the variable is captured into a nearby lambda. This patch takes care of the situation where the current function is the lambda and the variable is one of its captures from an enclosing scope.
The analogous problem for ^{blocks} is already handled automagically by the previous patch. That said, I added two FIXME tests that demonstrate an unrelated (but fairly disturbing) problem: because BlockDecl isn't a FunctionDecl, the forFunction() matcher doesn't behave as expected. This time it manifests through alias analysis analyzing more code than necessary but there are other annoying effects of this bug that I'll get to later.
const auto* could be used because type is spelled in same statement.