When compiling the following code, DoMarkVarDeclReferenced fails to capture variable "outerp":
auto lambda =[&](auto p) { return ^{ return p + outerp; }(); };
This happens because Sema::getCurLambda() returns the lambda scope only when it's the last scope that has been pushed to Sema::FunctionScopes and therefore returns null if there is a block enclosed in the lambda. To fix this bug, this patch defines function Sema::getInnermostLambda() and uses it in DoMarkVarDeclReferenced to get the innermost lambda scope.
rdar://problem/28412462