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 { |
John McCall | b259383 | 2010-09-16 06:16:50 +0000 | [diff] [blame] | 27 | llvm::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*). |
John McCall | b259383 | 2010-09-16 06:16:50 +0000 | [diff] [blame] | 32 | llvm::StringRef CatchallRethrowFn; |
John McCall | 8262b6a | 2010-07-17 00:43:08 +0000 | [diff] [blame] | 33 | |
John McCall | b259383 | 2010-09-16 06:16:50 +0000 | [diff] [blame] | 34 | EHPersonality(llvm::StringRef PersonalityFn, |
| 35 | llvm::StringRef CatchallRethrowFn = llvm::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; |
| 44 | static const EHPersonality NeXT_ObjC; |
| 45 | static const EHPersonality GNU_CPlusPlus; |
| 46 | static const EHPersonality GNU_CPlusPlus_SJLJ; |
| 47 | |
John McCall | b259383 | 2010-09-16 06:16:50 +0000 | [diff] [blame] | 48 | llvm::StringRef getPersonalityFnName() const { return PersonalityFn; } |
| 49 | llvm::StringRef getCatchallRethrowFnName() const { return CatchallRethrowFn; } |
John McCall | 8262b6a | 2010-07-17 00:43:08 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
John McCall | f1549f6 | 2010-07-06 01:34:17 +0000 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | |
| 55 | #endif |