diff options
| author | Shoaib Meenai <smeenai@fb.com> | 2018-06-08 00:41:01 +0000 |
|---|---|---|
| committer | Shoaib Meenai <smeenai@fb.com> | 2018-06-08 00:41:01 +0000 |
| commit | a5fc603379e033904e866be18ff845228a58e0ad (patch) | |
| tree | 5b81040088dbfb365e67ff2da75eb57457cda6d8 /clang/lib/CodeGen/CGException.cpp | |
| parent | 1dc1ff85d7d7682619891ae192f250c2e66327b6 (diff) | |
| download | bcm5719-llvm-a5fc603379e033904e866be18ff845228a58e0ad.tar.gz bcm5719-llvm-a5fc603379e033904e866be18ff845228a58e0ad.zip | |
[CodeGen] Always use MSVC personality for windows-msvc targets
The windows-msvc target is meant to be ABI compatible with MSVC,
including the exception handling. Ensure that a windows-msvc triple
always equates to the MSVC personality being used.
This mostly affects the GNUStep and ObjFW Obj-C runtimes. To the best of
my knowledge, those are normally not used with windows-msvc triples. I
believe WinObjC is based on GNUStep (or it at least uses libobjc2), but
that also takes the approach of wrapping Obj-C exceptions in C++
exceptions, so the MSVC personality function is the right one to use
there as well.
Differential Revision: https://reviews.llvm.org/D47862
llvm-svn: 334253
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 27f7eb8d30f..c9820c24255 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -117,12 +117,12 @@ EHPersonality::GNU_Wasm_CPlusPlus = { "__gxx_wasm_personality_v0", nullptr }; static const EHPersonality &getCPersonality(const TargetInfo &Target, const LangOptions &L) { const llvm::Triple &T = Target.getTriple(); + if (T.isWindowsMSVCEnvironment()) + return EHPersonality::MSVC_CxxFrameHandler3; if (L.SjLjExceptions) return EHPersonality::GNU_C_SJLJ; if (L.DWARFExceptions) return EHPersonality::GNU_C; - if (T.isWindowsMSVCEnvironment()) - return EHPersonality::MSVC_CxxFrameHandler3; if (L.SEHExceptions) return EHPersonality::GNU_C_SEH; return EHPersonality::GNU_C; @@ -131,14 +131,15 @@ static const EHPersonality &getCPersonality(const TargetInfo &Target, static const EHPersonality &getObjCPersonality(const TargetInfo &Target, const LangOptions &L) { const llvm::Triple &T = Target.getTriple(); + if (T.isWindowsMSVCEnvironment()) + return EHPersonality::MSVC_CxxFrameHandler3; + switch (L.ObjCRuntime.getKind()) { case ObjCRuntime::FragileMacOSX: return getCPersonality(Target, L); case ObjCRuntime::MacOSX: case ObjCRuntime::iOS: case ObjCRuntime::WatchOS: - if (T.isWindowsMSVCEnvironment()) - return EHPersonality::MSVC_CxxFrameHandler3; return EHPersonality::NeXT_ObjC; case ObjCRuntime::GNUstep: if (L.ObjCRuntime.getVersion() >= VersionTuple(1, 7)) @@ -158,12 +159,12 @@ static const EHPersonality &getObjCPersonality(const TargetInfo &Target, static const EHPersonality &getCXXPersonality(const TargetInfo &Target, const LangOptions &L) { const llvm::Triple &T = Target.getTriple(); + if (T.isWindowsMSVCEnvironment()) + return EHPersonality::MSVC_CxxFrameHandler3; if (L.SjLjExceptions) return EHPersonality::GNU_CPlusPlus_SJLJ; if (L.DWARFExceptions) return EHPersonality::GNU_CPlusPlus; - if (T.isWindowsMSVCEnvironment()) - return EHPersonality::MSVC_CxxFrameHandler3; if (L.SEHExceptions) return EHPersonality::GNU_CPlusPlus_SEH; // Wasm EH is a non-MVP feature for now. @@ -178,6 +179,9 @@ static const EHPersonality &getCXXPersonality(const TargetInfo &Target, /// and Objective-C exceptions are being caught. static const EHPersonality &getObjCXXPersonality(const TargetInfo &Target, const LangOptions &L) { + if (Target.getTriple().isWindowsMSVCEnvironment()) + return EHPersonality::MSVC_CxxFrameHandler3; + switch (L.ObjCRuntime.getKind()) { // In the fragile ABI, just use C++ exception handling and hope // they're not doing crazy exception mixing. |

