Index: include/clang/Sema/ScopeInfo.h
===================================================================
--- include/clang/Sema/ScopeInfo.h	(revision 185042)
+++ include/clang/Sema/ScopeInfo.h	(working copy)
@@ -610,11 +610,20 @@
   /// its list of array index variables.
   SmallVector<unsigned, 4> ArrayIndexStarts;
   
-  LambdaScopeInfo(DiagnosticsEngine &Diag, CXXRecordDecl *Lambda,
-                  CXXMethodDecl *CallOperator)
-    : CapturingScopeInfo(Diag, ImpCap_None), Lambda(Lambda),
-      CallOperator(CallOperator), NumExplicitCaptures(0), Mutable(false),
-      ExprNeedsCleanups(false), ContainsUnexpandedParameterPack(false)
+  /// \brief If this is a generic lambda, use this as the depth of 
+  /// each 'auto' parameter, during initial AST construction.
+  unsigned AutoTemplateParameterDepth;
+
+  /// \brief If this is a generic lambda, store the list of the auto 
+  /// parameters converted into TemplateTypeParmDecls into a vector
+  /// that can be used to construct the generic lambda's template
+  /// parameter list, during initial AST construction.
+  SmallVector<TemplateTypeParmDecl*, 4> AutoTemplateParams;
+  LambdaScopeInfo(DiagnosticsEngine &Diag, unsigned TemplateParamDepth)
+    : CapturingScopeInfo(Diag, ImpCap_None), Lambda(0),
+      CallOperator(0), NumExplicitCaptures(0), Mutable(false),
+      ExprNeedsCleanups(false), ContainsUnexpandedParameterPack(false),
+      AutoTemplateParameterDepth(TemplateParamDepth)
   {
     Kind = SK_Lambda;
   }
Index: include/clang/Sema/Sema.h
===================================================================
--- include/clang/Sema/Sema.h	(revision 185042)
+++ include/clang/Sema/Sema.h	(working copy)
@@ -946,7 +946,7 @@
 
   void PushFunctionScope();
   void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
-  void PushLambdaScope(CXXRecordDecl *Lambda, CXXMethodDecl *CallOperator);
+  void PushLambdaScope(unsigned CurTemplateDepth);
   void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD,
                                RecordDecl *RD,
                                CapturedRegionKind K);
Index: lib/Parse/ParseExprCXX.cpp
===================================================================
--- lib/Parse/ParseExprCXX.cpp	(revision 185042)
+++ lib/Parse/ParseExprCXX.cpp	(working copy)
@@ -901,6 +901,8 @@
   PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), LambdaBeginLoc,
                                 "lambda expression parsing");
 
+  Actions.PushLambdaScope(TemplateParameterDepth);
+
   // FIXME: Call into Actions to add any init-capture declarations to the
   // scope while parsing the lambda-declarator and compound-statement.
 
Index: lib/Sema/Sema.cpp
===================================================================
--- lib/Sema/Sema.cpp	(revision 185042)
+++ lib/Sema/Sema.cpp	(working copy)
@@ -1007,10 +1007,9 @@
                                               BlockScope, Block));
 }
 
-void Sema::PushLambdaScope(CXXRecordDecl *Lambda,
-                           CXXMethodDecl *CallOperator) {
-  FunctionScopes.push_back(new LambdaScopeInfo(getDiagnostics(), Lambda,
-                                               CallOperator));
+void Sema::PushLambdaScope(unsigned CurTemplateDepth) {
+  FunctionScopes.push_back(new LambdaScopeInfo(getDiagnostics(), 
+                                                CurTemplateDepth));
 }
 
 void Sema::PopFunctionScopeInfo(const AnalysisBasedWarnings::Policy *WP,
Index: lib/Sema/SemaLambda.cpp
===================================================================
--- lib/Sema/SemaLambda.cpp	(revision 185042)
+++ lib/Sema/SemaLambda.cpp	(working copy)
@@ -176,8 +176,12 @@
                                         bool ExplicitParams,
                                         bool ExplicitResultType,
                                         bool Mutable) {
-  PushLambdaScope(CallOperator->getParent(), CallOperator);
+  
   LambdaScopeInfo *LSI = getCurLambda();
+  assert(LSI && "getCurLambda() should exist!");
+  LSI->CallOperator = CallOperator;
+  LSI->Lambda = CallOperator->getParent();
+
   if (CaptureDefault == LCD_ByCopy)
     LSI->ImpCaptureStyle = LambdaScopeInfo::ImpCap_LambdaByval;
   else if (CaptureDefault == LCD_ByRef)
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h	(revision 185042)
+++ lib/Sema/TreeTransform.h	(working copy)
@@ -8108,7 +8108,11 @@
 
   // Introduce the context of the call operator.
   Sema::ContextRAII SavedContext(getSema(), CallOperator);
-
+  // We don't need the CurTemplateDepth during transformation, 
+  // it is only needed during initial AST construction and is passed 
+  // in from the Parser into Sema at that time.  
+  const unsigned IgnoreCurTemplateDepth = (unsigned) -1;
+  getSema().PushLambdaScope(/*CurTemplateDepth*/IgnoreCurTemplateDepth);
   // Enter the scope of the lambda.
   sema::LambdaScopeInfo *LSI
     = getSema().enterLambdaScope(CallOperator, E->getIntroducerRange(),
