diff --git a/clang/lib/CodeGen/CGCleanup.h b/clang/lib/CodeGen/CGCleanup.h index 079a3e25d6dc7..fcfbf41b0eaff 100644 --- a/clang/lib/CodeGen/CGCleanup.h +++ b/clang/lib/CodeGen/CGCleanup.h @@ -613,6 +613,7 @@ struct EHPersonality { static const EHPersonality MSVC_CxxFrameHandler3; static const EHPersonality GNU_Wasm_CPlusPlus; static const EHPersonality XL_CPlusPlus; + static const EHPersonality ZOS_CPlusPlus; /// Does this personality use landingpads or the family of pad instructions /// designed to form funclets? diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 0d507da5c1ba9..9bad7637b8d05 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -127,6 +127,8 @@ const EHPersonality EHPersonality::GNU_Wasm_CPlusPlus = { "__gxx_wasm_personality_v0", nullptr }; const EHPersonality EHPersonality::XL_CPlusPlus = {"__xlcxx_personality_v1", nullptr}; +const EHPersonality EHPersonality::ZOS_CPlusPlus = {"__zos_cxx_personality_v2", + nullptr}; static const EHPersonality &getCPersonality(const TargetInfo &Target, const LangOptions &L) { @@ -185,6 +187,8 @@ static const EHPersonality &getCXXPersonality(const TargetInfo &Target, return EHPersonality::GNU_CPlusPlus_SEH; if (L.hasWasmExceptions()) return EHPersonality::GNU_Wasm_CPlusPlus; + if (T.isOSzOS()) + return EHPersonality::ZOS_CPlusPlus; return EHPersonality::GNU_CPlusPlus; } diff --git a/clang/test/CodeGenCXX/personality.cpp b/clang/test/CodeGenCXX/personality.cpp index 1c8baa2c412fe..42ba2c227f028 100644 --- a/clang/test/CodeGenCXX/personality.cpp +++ b/clang/test/CodeGenCXX/personality.cpp @@ -15,6 +15,9 @@ // RUN: %clang_cc1 -triple powerpc-unknown-aix-xcoff -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-AIX // RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-AIX +// RUN: %clang_cc1 -triple s390x-unknown-zos -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-ZOS +// RUN: %clang_cc1 -triple systemz-unknown-zos -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-ZOS + extern void g(); // CHECK-GNU: personality ptr @__gxx_personality_v0 @@ -26,6 +29,8 @@ extern void g(); // CHECK-AIX: personality ptr @__xlcxx_personality_v1 +// CHECK-ZOS: personality ptr @__zos_cxx_personality_v2 + void f() { try { g();