[REFACTOR] Refactored some of the generic-lambda capturing code.

Employed the following refactorings:
  - Renamed some functions
  - Introduced explaining variables
  - Cleaned up & added comments
  - Used Optional<unsigned> for return value instead of an out parameter
  - Added assertions
  - Constified a few member functions
  
No functionality change.
All regressions pass.  

llvm-svn: 196662
diff --git a/clang/lib/Sema/ScopeInfo.cpp b/clang/lib/Sema/ScopeInfo.cpp
index 6d50885..1e54c5a 100644
--- a/clang/lib/Sema/ScopeInfo.cpp
+++ b/clang/lib/Sema/ScopeInfo.cpp
@@ -190,10 +190,11 @@
   ThisUse->markSafe();
 }
 
-void LambdaScopeInfo::getPotentialVariableCapture(unsigned Idx, VarDecl *&VD, Expr *&E) {
+void LambdaScopeInfo::getPotentialVariableCapture(unsigned Idx, VarDecl *&VD,
+                                                  Expr *&E) const {
   assert(Idx < getNumPotentialVariableCaptures() &&
-    "Index of potential capture must be within 0 to less than the "
-    "number of captures!");
+         "Index of potential capture must be within 0 to less than the "
+         "number of captures!");
   E = PotentiallyCapturingExprs[Idx];
   if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
     VD = dyn_cast<VarDecl>(DRE->getFoundDecl());