From c28d46ea3cf1d961e3ba3cc8fd09ebd83f2d3405 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 22 Jul 2015 23:46:21 +0000 Subject: [PATCH] Move EHPersonality to CGCleanup This makes it possible to use EHPersonality in other parts of CodeGen. Differential Revision: http://reviews.llvm.org/D11440 llvm-svn: 242971 --- clang/lib/CodeGen/CGCleanup.h | 29 +++++++++++++++++++++++++++++ clang/lib/CodeGen/CGException.cpp | 36 ++++-------------------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/clang/lib/CodeGen/CGCleanup.h b/clang/lib/CodeGen/CGCleanup.h index 34866d4..8338691 100644 --- a/clang/lib/CodeGen/CGCleanup.h +++ b/clang/lib/CodeGen/CGCleanup.h @@ -26,7 +26,10 @@ class AllocaInst; } namespace clang { +class FunctionDecl; namespace CodeGen { +class CodeGenModule; +class CodeGenFunction; /// A protected scope for zero-cost EH handling. class EHScope { @@ -560,6 +563,32 @@ EHScopeStack::stabilize(iterator ir) const { return stable_iterator(EndOfBuffer - ir.Ptr); } +/// The exceptions personality for a function. +struct EHPersonality { + const char *PersonalityFn; + + // If this is non-null, this personality requires a non-standard + // function for rethrowing an exception after a catchall cleanup. + // This function must have prototype void(void*). + const char *CatchallRethrowFn; + + static const EHPersonality &get(CodeGenModule &CGM, const FunctionDecl *FD); + static const EHPersonality &get(CodeGenFunction &CGF); + + static const EHPersonality GNU_C; + static const EHPersonality GNU_C_SJLJ; + static const EHPersonality GNU_C_SEH; + static const EHPersonality GNU_ObjC; + static const EHPersonality GNUstep_ObjC; + static const EHPersonality GNU_ObjCXX; + static const EHPersonality NeXT_ObjC; + static const EHPersonality GNU_CPlusPlus; + static const EHPersonality GNU_CPlusPlus_SJLJ; + static const EHPersonality GNU_CPlusPlus_SEH; + static const EHPersonality MSVC_except_handler; + static const EHPersonality MSVC_C_specific_handler; + static const EHPersonality MSVC_CxxFrameHandler3; +}; } } diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 7b8368e..d0e86ae 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -81,38 +81,6 @@ static llvm::Constant *getCatchallRethrowFn(CodeGenModule &CGM, return CGM.CreateRuntimeFunction(FTy, Name); } -namespace { - /// The exceptions personality for a function. - struct EHPersonality { - const char *PersonalityFn; - - // If this is non-null, this personality requires a non-standard - // function for rethrowing an exception after a catchall cleanup. - // This function must have prototype void(void*). - const char *CatchallRethrowFn; - - static const EHPersonality &get(CodeGenModule &CGM, - const FunctionDecl *FD); - static const EHPersonality &get(CodeGenFunction &CGF) { - return get(CGF.CGM, dyn_cast_or_null(CGF.CurCodeDecl)); - } - - static const EHPersonality GNU_C; - static const EHPersonality GNU_C_SJLJ; - static const EHPersonality GNU_C_SEH; - static const EHPersonality GNU_ObjC; - static const EHPersonality GNUstep_ObjC; - static const EHPersonality GNU_ObjCXX; - static const EHPersonality NeXT_ObjC; - static const EHPersonality GNU_CPlusPlus; - static const EHPersonality GNU_CPlusPlus_SJLJ; - static const EHPersonality GNU_CPlusPlus_SEH; - static const EHPersonality MSVC_except_handler; - static const EHPersonality MSVC_C_specific_handler; - static const EHPersonality MSVC_CxxFrameHandler3; - }; -} - const EHPersonality EHPersonality::GNU_C = { "__gcc_personality_v0", nullptr }; const EHPersonality EHPersonality::GNU_C_SJLJ = { "__gcc_personality_sj0", nullptr }; @@ -243,6 +211,10 @@ const EHPersonality &EHPersonality::get(CodeGenModule &CGM, return getCPersonality(T, L); } +const EHPersonality &EHPersonality::get(CodeGenFunction &CGF) { + return get(CGF.CGM, dyn_cast_or_null(CGF.CurCodeDecl)); +} + static llvm::Constant *getPersonalityFn(CodeGenModule &CGM, const EHPersonality &Personality) { llvm::Constant *Fn = -- 2.7.4