Start of IRGen for lambda conversion operators.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150649 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp
index 38fdb34..b1096d2 100644
--- a/lib/CodeGen/CGClass.cpp
+++ b/lib/CodeGen/CGClass.cpp
@@ -1720,3 +1720,11 @@
 
   return CGM.GetAddrOfFunction(MD, Ty);
 }
+
+void CodeGenFunction::EmitLambdaToBlockPointerBody(FunctionArgList &Args) {
+  CGM.ErrorUnsupported(CurFuncDecl, "lambda conversion to block");
+}
+
+void CodeGenFunction::EmitLambdaToFunctionPointerBody(FunctionArgList &Args) {
+  CGM.ErrorUnsupported(CurFuncDecl, "lambda conversion to function");
+}
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 0c528b2..1034de7 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -447,6 +447,15 @@
            !CGM.getCodeGenOpts().CUDAIsDevice &&
            FD->hasAttr<CUDAGlobalAttr>())
     CGM.getCUDARuntime().EmitDeviceStubBody(*this, Args);
+  else if (isa<CXXConversionDecl>(FD) &&
+           cast<CXXConversionDecl>(FD)->getParent()->isLambda()) {
+    // The lambda conversion operators are special; the semantics can't be
+    // expressed in the AST, so IRGen needs to special-case them.
+    if (cast<CXXConversionDecl>(FD)->isLambdaToBlockPointerConversion())
+      EmitLambdaToBlockPointerBody(Args);
+    else
+      EmitLambdaToFunctionPointerBody(Args);
+  }
   else
     EmitFunctionBody(Args);
 
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 263a063..7a954ec 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -1376,6 +1376,9 @@
   void EmitDestructorBody(FunctionArgList &Args);
   void EmitFunctionBody(FunctionArgList &Args);
 
+  void EmitLambdaToBlockPointerBody(FunctionArgList &Args);
+  void EmitLambdaToFunctionPointerBody(FunctionArgList &Args);
+
   /// EmitReturnBlock - Emit the unified return block, trying to avoid its
   /// emission when possible.
   void EmitReturnBlock();