Add -fseh-exceptions for MinGW-w64

This adds a flag called -fseh-exceptions that uses the native Windows
.pdata and .xdata unwind mechanism to throw exceptions. The other EH
possibilities are DWARF and SJLJ exceptions.

Patch by Martell Malone!

Reviewed By: asl, rnk

Differential Revision: http://reviews.llvm.org/D3419

llvm-svn: 217790
diff --git a/clang/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp b/clang/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
new file mode 100644
index 0000000..f247e99
--- /dev/null
+++ b/clang/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple x86_64-w64-windows-gnu -o - | FileCheck %s
+
+extern "C" void foo();
+extern "C" void bar();
+
+struct Cleanup {
+  ~Cleanup() {
+    bar();
+  }
+};
+
+extern "C" void test() {
+  Cleanup x;
+  foo();
+}
+
+// CHECK: define void @test()
+// CHECK: invoke void @foo()
+// CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_seh0 to i8*)