John McCall | f1549f6 | 2010-07-06 01:34:17 +0000 | [diff] [blame] | 1 | //===-- CGException.h - Classes for exceptions IR generation ----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // These classes support the generation of LLVM IR for exceptions in |
| 11 | // C++ and Objective C. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef CLANG_CODEGEN_CGEXCEPTION_H |
| 16 | #define CLANG_CODEGEN_CGEXCEPTION_H |
| 17 | |
John McCall | 36f893c | 2011-01-28 11:13:47 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/StringRef.h" |
John McCall | f1549f6 | 2010-07-06 01:34:17 +0000 | [diff] [blame] | 19 | |
| 20 | namespace clang { |
John McCall | 36f893c | 2011-01-28 11:13:47 +0000 | [diff] [blame] | 21 | class LangOptions; |
| 22 | |
John McCall | f1549f6 | 2010-07-06 01:34:17 +0000 | [diff] [blame] | 23 | namespace CodeGen { |
| 24 | |
John McCall | 8262b6a | 2010-07-17 00:43:08 +0000 | [diff] [blame] | 25 | /// The exceptions personality for a function. When |
| 26 | class EHPersonality { |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame^] | 27 | StringRef PersonalityFn; |
John McCall | 8262b6a | 2010-07-17 00:43:08 +0000 | [diff] [blame] | 28 | |
| 29 | // If this is non-null, this personality requires a non-standard |
| 30 | // function for rethrowing an exception after a catchall cleanup. |
| 31 | // This function must have prototype void(void*). |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame^] | 32 | StringRef CatchallRethrowFn; |
John McCall | 8262b6a | 2010-07-17 00:43:08 +0000 | [diff] [blame] | 33 | |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame^] | 34 | EHPersonality(StringRef PersonalityFn, |
| 35 | StringRef CatchallRethrowFn = StringRef()) |
John McCall | 8262b6a | 2010-07-17 00:43:08 +0000 | [diff] [blame] | 36 | : PersonalityFn(PersonalityFn), |
| 37 | CatchallRethrowFn(CatchallRethrowFn) {} |
| 38 | |
| 39 | public: |
| 40 | static const EHPersonality &get(const LangOptions &Lang); |
| 41 | static const EHPersonality GNU_C; |
John McCall | 4468078 | 2010-11-07 02:35:25 +0000 | [diff] [blame] | 42 | static const EHPersonality GNU_C_SJLJ; |
John McCall | 8262b6a | 2010-07-17 00:43:08 +0000 | [diff] [blame] | 43 | static const EHPersonality GNU_ObjC; |
David Chisnall | 80558d2 | 2011-03-20 21:35:39 +0000 | [diff] [blame] | 44 | static const EHPersonality GNU_ObjCXX; |
John McCall | 8262b6a | 2010-07-17 00:43:08 +0000 | [diff] [blame] | 45 | static const EHPersonality NeXT_ObjC; |
| 46 | static const EHPersonality GNU_CPlusPlus; |
| 47 | static const EHPersonality GNU_CPlusPlus_SJLJ; |
| 48 | |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame^] | 49 | StringRef getPersonalityFnName() const { return PersonalityFn; } |
| 50 | StringRef getCatchallRethrowFnName() const { return CatchallRethrowFn; } |
John McCall | 8262b6a | 2010-07-17 00:43:08 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
John McCall | f1549f6 | 2010-07-06 01:34:17 +0000 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | |
| 56 | #endif |