Mark as release
[official-gcc.git] / gcc / except.h
blobcdc5c7335c2c26b16c56b2acaa969d6e1daf9e78
1 /* Exception Handling interface routines.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2007 Free Software Foundation, Inc.
4 Contributed by Mike Stump <mrs@cygnus.com>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
23 struct function;
25 /* Per-function EH data. Used only in except.c, but GC and others
26 manipulate pointers to the opaque type. */
27 struct eh_status;
29 /* Internal structure describing a region. */
30 struct eh_region;
32 /* Test: is exception handling turned on? */
33 extern int doing_eh (int);
35 /* Note that the current EH region (if any) may contain a throw, or a
36 call to a function which itself may contain a throw. */
37 extern void note_eh_region_may_contain_throw (struct eh_region *);
38 extern void note_current_region_may_contain_throw (void);
40 /* Invokes CALLBACK for every exception handler label. Only used by old
41 loop hackery; should not be used by new code. */
42 extern void for_each_eh_label (void (*) (rtx));
44 /* Invokes CALLBACK for every exception region in the current function. */
45 extern void for_each_eh_region (void (*) (struct eh_region *));
47 /* Determine if the given INSN can throw an exception. */
48 extern bool can_throw_internal_1 (int, bool);
49 extern bool can_throw_internal (rtx);
50 extern bool can_throw_external_1 (int, bool);
51 extern bool can_throw_external (rtx);
53 /* Set TREE_NOTHROW and cfun->all_throwers_are_sibcalls. */
54 extern unsigned int set_nothrow_function_flags (void);
56 /* After initial rtl generation, call back to finish generating
57 exception support code. */
58 extern void finish_eh_generation (void);
60 extern void init_eh (void);
61 extern void init_eh_for_function (void);
63 extern rtx reachable_handlers (rtx);
64 extern void maybe_remove_eh_handler (rtx);
66 extern void convert_from_eh_region_ranges (void);
67 extern unsigned int convert_to_eh_region_ranges (void);
68 extern void find_exception_handler_labels (void);
69 extern bool current_function_has_exception_handlers (void);
70 extern void output_function_exception_table (void);
72 extern void expand_builtin_unwind_init (void);
73 extern rtx expand_builtin_eh_return_data_regno (tree);
74 extern rtx expand_builtin_extract_return_addr (tree);
75 extern void expand_builtin_init_dwarf_reg_sizes (tree);
76 extern rtx expand_builtin_frob_return_addr (tree);
77 extern rtx expand_builtin_dwarf_sp_column (void);
78 extern void expand_builtin_eh_return (tree, tree);
79 extern void expand_eh_return (void);
80 extern rtx expand_builtin_extend_pointer (tree);
81 extern rtx get_exception_pointer (struct function *);
82 extern rtx get_exception_filter (struct function *);
83 typedef tree (*duplicate_eh_regions_map) (tree, void *);
84 extern int duplicate_eh_regions (struct function *, duplicate_eh_regions_map,
85 void *, int, int);
87 extern void sjlj_emit_function_exit_after (rtx);
88 extern void default_init_unwind_resume_libfunc (void);
90 extern struct eh_region *gen_eh_region_cleanup (struct eh_region *,
91 struct eh_region *);
92 extern struct eh_region *gen_eh_region_try (struct eh_region *);
93 extern struct eh_region *gen_eh_region_catch (struct eh_region *, tree);
94 extern struct eh_region *gen_eh_region_allowed (struct eh_region *, tree);
95 extern struct eh_region *gen_eh_region_must_not_throw (struct eh_region *);
96 extern int get_eh_region_number (struct eh_region *);
97 extern bool get_eh_region_may_contain_throw (struct eh_region *);
98 extern tree get_eh_region_tree_label (struct eh_region *);
99 extern void set_eh_region_tree_label (struct eh_region *, tree);
101 extern void foreach_reachable_handler (int, bool,
102 void (*) (struct eh_region *, void *),
103 void *);
105 extern void collect_eh_region_array (void);
106 extern void expand_resx_expr (tree);
107 extern void verify_eh_tree (struct function *);
108 extern void dump_eh_tree (FILE *, struct function *);
109 extern bool eh_region_outer_p (struct function *, int, int);
110 extern int eh_region_outermost (struct function *, int, int);
112 /* tree-eh.c */
113 extern void add_stmt_to_eh_region_fn (struct function *, tree, int);
114 extern bool remove_stmt_from_eh_region_fn (struct function *, tree);
115 extern int lookup_stmt_eh_region_fn (struct function *, tree);
116 extern int lookup_stmt_eh_region (tree);
117 extern bool verify_eh_edges (tree);
119 /* If non-NULL, this is a function that returns an expression to be
120 executed if an unhandled exception is propagated out of a cleanup
121 region. For example, in C++, an exception thrown by a destructor
122 during stack unwinding is required to result in a call to
123 `std::terminate', so the C++ version of this function returns a
124 CALL_EXPR for `std::terminate'. */
125 extern tree (*lang_protect_cleanup_actions) (void);
127 /* Return true if type A catches type B. */
128 extern int (*lang_eh_type_covers) (tree a, tree b);
130 /* Map a type to a runtime object to match type. */
131 extern tree (*lang_eh_runtime_type) (tree);
134 /* Just because the user configured --with-sjlj-exceptions=no doesn't
135 mean that we can use call frame exceptions. Detect that the target
136 has appropriate support. */
138 #ifndef MUST_USE_SJLJ_EXCEPTIONS
139 # if !(defined (EH_RETURN_DATA_REGNO) \
140 && (defined (TARGET_UNWIND_INFO) \
141 || (DWARF2_UNWIND_INFO \
142 && (defined (EH_RETURN_HANDLER_RTX) \
143 || defined (HAVE_eh_return)))))
144 # define MUST_USE_SJLJ_EXCEPTIONS 1
145 # else
146 # define MUST_USE_SJLJ_EXCEPTIONS 0
147 # endif
148 #endif
150 #ifdef CONFIG_SJLJ_EXCEPTIONS
151 # if CONFIG_SJLJ_EXCEPTIONS == 1
152 # define USING_SJLJ_EXCEPTIONS 1
153 # endif
154 # if CONFIG_SJLJ_EXCEPTIONS == 0
155 # define USING_SJLJ_EXCEPTIONS 0
156 # ifndef EH_RETURN_DATA_REGNO
157 #error "EH_RETURN_DATA_REGNO required"
158 # endif
159 # if !defined(EH_RETURN_HANDLER_RTX) && !defined(HAVE_eh_return)
160 #error "EH_RETURN_HANDLER_RTX or eh_return required"
161 # endif
162 # if !defined(DWARF2_UNWIND_INFO) && !defined(TARGET_UNWIND_INFO)
163 #error "{DWARF2,TARGET}_UNWIND_INFO required"
164 # endif
165 # endif
166 #else
167 # define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS
168 #endif
170 struct throw_stmt_node GTY(())
172 tree stmt;
173 int region_nr;
176 extern struct htab *get_eh_throw_stmt_table (struct function *);
177 extern void set_eh_throw_stmt_table (struct function *, struct htab *);
179 #ifdef ENABLE_CHECKING
180 extern void verify_eh_throw_table_statements (void);
181 #endif