When first parsing a lambda expression, BuildDeclRefExpr is called on the parameter declarations with the lambda scope already pushed. But when transforming a lambda expression as part of instantiating an outer template, BuildDeclRefExpr is called again without the scope pushed. This causes tryCaptureVariable to get confused when a lambda parameter references an earlier parameter, e.g.:
[](auto c, int x = sizeof(decltype(c))) {}
Fix this by moving up the call to PushLambdaScope in TreeTransform::TransformLambdaExpr to match Parser::ParseLambdaExpressionAfterIntroducer.
(Note: I do not have commit access.)