Re-land "MS ABI: lambda call operators are instance methods and should use thiscall"

Update the test cases to pass when lambda call operators use thiscall.

Update the lambda-to-block conversion operator to use the default free
function calling convention instead of the call operator's convention.

This reverts commit r233082 and re-instates r233023.

llvm-svn: 233835
diff --git a/clang/test/SemaCXX/decl-microsoft-call-conv.cpp b/clang/test/SemaCXX/decl-microsoft-call-conv.cpp
index a4b68cd..6c392ea 100644
--- a/clang/test/SemaCXX/decl-microsoft-call-conv.cpp
+++ b/clang/test/SemaCXX/decl-microsoft-call-conv.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -verify %s
-// RUN: %clang_cc1 -triple i686-pc-mingw32 -verify %s
-// RUN: %clang_cc1 -triple i686-pc-mingw32 -fms-extensions -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple i686-pc-win32 -fms-extensions -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple i686-pc-mingw32 -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple i686-pc-mingw32 -fms-extensions -verify %s
 
 typedef void void_fun_t();
 typedef void __cdecl cdecl_fun_t();
@@ -242,3 +242,19 @@
     s.f(p); // expected-note {{in instantiation of member function 'test8::S<void *>::f' requested here}}
   }
 }
+
+namespace test9 {
+  // Used to fail when we forgot to make lambda call operators use __thiscall.
+  template <typename F>
+  decltype(auto) deduce(F f) {
+    return &decltype(f)::operator();
+  }
+  template <typename C, typename R, typename A>
+  decltype(auto) signaturehelper(R (C::*f)(A) const) {
+    return R();
+  }
+  void f() {
+    auto l = [](int x) { return x * 2; };
+    decltype(signaturehelper(deduce(l))) p;
+  }
+}