Split the storage of lambda information between the LambdaExpr and the
CXXRecordDecl in a way that actually makes some sense:
  - LambdaExpr contains all of the information for initializing the
  lambda object, including the capture initializers and associated
  array index variables.
  - CXXRecordDecl's LambdaDefinitionData contains the captures, which
  are needed to understand the captured variable references in the
  body of the lambda.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150401 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index fcd4508..5b9ab4f 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -35,55 +35,6 @@
   return new (Mem) AccessSpecDecl(EmptyShell());
 }
 
-void CXXRecordDecl::LambdaDefinitionData::allocateExtra(
-       ArrayRef<LambdaExpr::Capture> Captures,
-       ArrayRef<Expr *> CaptureInits,
-       ArrayRef<VarDecl *> ArrayIndexVars,
-       ArrayRef<unsigned> ArrayIndexStarts,
-       Stmt *Body) {
-  NumCaptures = Captures.size();
-  NumExplicitCaptures = 0;
-  
-  ASTContext &Context = Definition->getASTContext();
-  unsigned ArrayIndexSize = 0;
-  if (ArrayIndexVars.size() > 0) {
-    HasArrayIndexVars = true;
-    ArrayIndexSize = sizeof(unsigned) * (Captures.size() + 1)
-                   + sizeof(VarDecl *) * ArrayIndexVars.size();
-  }
-  
-  this->Extra = Context.Allocate(sizeof(Capture) * Captures.size() +
-                                 sizeof(Stmt*) * (Captures.size() + 1) +
-                                 ArrayIndexSize);
-  
-  // Copy captures.
-  Capture *ToCapture = getCaptures();
-  for (unsigned I = 0, N = Captures.size(); I != N; ++I) {
-    if (Captures[I].isExplicit())
-      ++NumExplicitCaptures;
-    
-    *ToCapture++ = Captures[I];
-  }
-  
-  // Copy initialization expressions for the non-static data members.
-  Stmt **Stored = getStoredStmts();
-  for (unsigned I = 0, N = CaptureInits.size(); I != N; ++I)
-    *Stored++ = CaptureInits[I];
-  
-  // Copy the body of the lambda.
-  *Stored++ = Body;
-  
-  if (ArrayIndexVars.size() > 0) {
-    assert(ArrayIndexStarts.size() == Captures.size());
-    memcpy(getArrayIndexVars(), ArrayIndexVars.data(),
-           sizeof(VarDecl *) * ArrayIndexVars.size());
-    memcpy(getArrayIndexStarts(), ArrayIndexStarts.data(), 
-           sizeof(unsigned) * Captures.size());
-    getArrayIndexStarts()[Captures.size()] = ArrayIndexVars.size();
-  }
-}
-
-
 CXXRecordDecl::DefinitionData::DefinitionData(CXXRecordDecl *D)
   : UserDeclaredConstructor(false), UserDeclaredCopyConstructor(false),
     UserDeclaredMoveConstructor(false), UserDeclaredCopyAssignment(false),
@@ -1035,8 +986,7 @@
 
   LambdaDefinitionData &Lambda = getLambdaData();
   RecordDecl::field_iterator Field = field_begin();
-  for (LambdaExpr::Capture *C = Lambda.getCaptures(), 
-                        *CEnd = C + Lambda.NumCaptures;
+  for (LambdaExpr::Capture *C = Lambda.Captures, *CEnd = C + Lambda.NumCaptures;
        C != CEnd; ++C, ++Field) {
     if (C->capturesThis()) {
       ThisCapture = *Field;