r319363 - [EH] Use __CxxFrameHandler3 for C++ EH in MS environments

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 13:35:34 PST 2017


Author: rnk
Date: Wed Nov 29 13:35:34 2017
New Revision: 319363

URL: http://llvm.org/viewvc/llvm-project?rev=319363&view=rev
Log:
[EH] Use __CxxFrameHandler3 for C++ EH in MS environments

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.

Added:
    cfe/trunk/test/CodeGenCXX/ms-eh-personality.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGException.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=319363&r1=319362&r2=319363&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Wed Nov 29 13:35:34 2017
@@ -205,12 +205,9 @@ const EHPersonality &EHPersonality::get(
   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)

Added: cfe/trunk/test/CodeGenCXX/ms-eh-personality.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ms-eh-personality.cpp?rev=319363&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/ms-eh-personality.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/ms-eh-personality.cpp Wed Nov 29 13:35:34 2017
@@ -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();
+}




More information about the cfe-commits mailing list