]> granicus.if.org Git - clang/commitdiff
[EH] Use __CxxFrameHandler3 for C++ EH in MS environments
authorReid Kleckner <rnk@google.com>
Wed, 29 Nov 2017 21:35:34 +0000 (21:35 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 29 Nov 2017 21:35:34 +0000 (21:35 +0000)
Fixes regression introduced by r319297. MSVC environments still use SEH
unwind opcodes but they should use the Microsoft C++ EH personality, not
the mingw one.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319363 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGException.cpp
test/CodeGenCXX/ms-eh-personality.cpp [new file with mode: 0644]

index d6a9538bc1fd93ba45b398b219f2cc80a368acc0..6c9d9f170ace60da177b25d4c5ec9058ec4937de 100644 (file)
@@ -205,12 +205,9 @@ const EHPersonality &EHPersonality::get(CodeGenModule &CGM,
   if (T.isWindowsMSVCEnvironment() && !L.ObjC1) {
     if (L.SjLjExceptions)
       return EHPersonality::GNU_CPlusPlus_SJLJ;
-    if (L.SEHExceptions)
-      return EHPersonality::GNU_CPlusPlus_SEH;
     if (L.DWARFExceptions)
       return EHPersonality::GNU_CPlusPlus;
-    else
-      return EHPersonality::MSVC_CxxFrameHandler3;
+    return EHPersonality::MSVC_CxxFrameHandler3;
   }
 
   if (L.CPlusPlus && L.ObjC1)
diff --git a/test/CodeGenCXX/ms-eh-personality.cpp b/test/CodeGenCXX/ms-eh-personality.cpp
new file mode 100644 (file)
index 0000000..592ab69
--- /dev/null
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fexceptions -fcxx-exceptions %s -emit-llvm -o - | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fexceptions -fcxx-exceptions -fsjlj-exceptions %s -emit-llvm -o - | FileCheck %s --check-prefix=SJLJ
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fexceptions -fcxx-exceptions -fseh-exceptions %s -emit-llvm -o - | FileCheck %s --check-prefix=MSVC
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fexceptions -fcxx-exceptions -fdwarf-exceptions %s -emit-llvm -o - | FileCheck %s --check-prefix=DWARF
+
+// MSVC: define void @f(){{.*}}@__CxxFrameHandler3
+// SJLJ: define void @f(){{.*}}@__gxx_personality_sj0
+// DWARF: define void @f(){{.*}}@__gxx_personality_v0
+
+struct Cleanup {
+  Cleanup();
+  ~Cleanup();
+  int x = 0;
+};
+
+void g();
+extern "C" void f() {
+  Cleanup c;
+  g();
+}