Update concepts branch to revision 131834
[official-gcc.git] / gcc / except.h
blobae3264e6f3efba560a8746be2ebf47183ab2fa6e
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 *);
39 /* Invokes CALLBACK for every exception handler label. Only used by old
40 loop hackery; should not be used by new code. */
41 extern void for_each_eh_label (void (*) (rtx));
43 /* Invokes CALLBACK for every exception region in the current function. */
44 extern void for_each_eh_region (void (*) (struct eh_region *));
46 /* Determine if the given INSN can throw an exception. */
47 extern bool can_throw_internal_1 (int, bool);
48 extern bool can_throw_internal (const_rtx);
49 extern bool can_throw_external_1 (int, bool);
50 extern bool can_throw_external (const_rtx);
52 /* Set TREE_NOTHROW and cfun->all_throwers_are_sibcalls. */
53 extern unsigned int set_nothrow_function_flags (void);
55 /* After initial rtl generation, call back to finish generating
56 exception support code. */
57 extern void finish_eh_generation (void);
59 extern void init_eh (void);
60 extern void init_eh_for_function (void);
62 extern rtx reachable_handlers (rtx);
63 extern void maybe_remove_eh_handler (rtx);
65 extern void convert_from_eh_region_ranges (void);
66 extern unsigned int convert_to_eh_region_ranges (void);
67 extern void find_exception_handler_labels (void);
68 extern bool current_function_has_exception_handlers (void);
69 extern void output_function_exception_table (const char *);
71 extern void expand_builtin_unwind_init (void);
72 extern rtx expand_builtin_eh_return_data_regno (tree);
73 extern rtx expand_builtin_extract_return_addr (tree);
74 extern void expand_builtin_init_dwarf_reg_sizes (tree);
75 extern rtx expand_builtin_frob_return_addr (tree);
76 extern rtx expand_builtin_dwarf_sp_column (void);
77 extern void expand_builtin_eh_return (tree, tree);
78 extern void expand_eh_return (void);
79 extern rtx expand_builtin_extend_pointer (tree);
80 extern rtx get_exception_pointer (void);
81 extern rtx get_exception_filter (void);
82 typedef tree (*duplicate_eh_regions_map) (tree, void *);
83 extern int duplicate_eh_regions (struct function *, duplicate_eh_regions_map,
84 void *, int, int);
86 extern void sjlj_emit_function_exit_after (rtx);
87 extern void default_init_unwind_resume_libfunc (void);
89 extern struct eh_region *gen_eh_region_cleanup (struct eh_region *,
90 struct eh_region *);
91 extern struct eh_region *gen_eh_region_try (struct eh_region *);
92 extern struct eh_region *gen_eh_region_catch (struct eh_region *, tree);
93 extern struct eh_region *gen_eh_region_allowed (struct eh_region *, tree);
94 extern struct eh_region *gen_eh_region_must_not_throw (struct eh_region *);
95 extern int get_eh_region_number (struct eh_region *);
96 extern bool get_eh_region_may_contain_throw (struct eh_region *);
97 extern tree get_eh_region_tree_label (struct eh_region *);
98 extern void set_eh_region_tree_label (struct eh_region *, tree);
100 extern void foreach_reachable_handler (int, bool,
101 void (*) (struct eh_region *, void *),
102 void *);
104 extern void collect_eh_region_array (void);
105 extern void expand_resx_expr (tree);
106 extern void verify_eh_tree (struct function *);
107 extern void dump_eh_tree (FILE *, struct function *);
108 extern bool eh_region_outer_p (struct function *, int, int);
109 extern int eh_region_outermost (struct function *, int, int);
111 /* tree-eh.c */
112 extern void add_stmt_to_eh_region_fn (struct function *, tree, int);
113 extern bool remove_stmt_from_eh_region_fn (struct function *, tree);
114 extern int lookup_stmt_eh_region_fn (struct function *, const_tree);
115 extern int lookup_stmt_eh_region (const_tree);
116 extern bool verify_eh_edges (tree);
118 /* If non-NULL, this is a function that returns an expression to be
119 executed if an unhandled exception is propagated out of a cleanup
120 region. For example, in C++, an exception thrown by a destructor
121 during stack unwinding is required to result in a call to
122 `std::terminate', so the C++ version of this function returns a
123 CALL_EXPR for `std::terminate'. */
124 extern tree (*lang_protect_cleanup_actions) (void);
126 /* Return true if type A catches type B. */
127 extern int (*lang_eh_type_covers) (tree a, tree b);
129 /* Map a type to a runtime object to match type. */
130 extern tree (*lang_eh_runtime_type) (tree);
133 /* Just because the user configured --with-sjlj-exceptions=no doesn't
134 mean that we can use call frame exceptions. Detect that the target
135 has appropriate support. */
137 #ifndef MUST_USE_SJLJ_EXCEPTIONS
138 # if defined (EH_RETURN_DATA_REGNO) \
139 && (defined (TARGET_UNWIND_INFO) \
140 || (DWARF2_UNWIND_INFO \
141 && (defined (EH_RETURN_HANDLER_RTX) \
142 || defined (HAVE_eh_return))))
143 # define MUST_USE_SJLJ_EXCEPTIONS 0
144 # else
145 # define MUST_USE_SJLJ_EXCEPTIONS 1
146 # endif
147 #endif
149 #ifdef CONFIG_SJLJ_EXCEPTIONS
150 # if CONFIG_SJLJ_EXCEPTIONS == 1
151 # define USING_SJLJ_EXCEPTIONS 1
152 # endif
153 # if CONFIG_SJLJ_EXCEPTIONS == 0
154 # define USING_SJLJ_EXCEPTIONS 0
155 # if !defined(EH_RETURN_DATA_REGNO)
156 #error "EH_RETURN_DATA_REGNO required"
157 # endif
158 # if ! (defined(TARGET_UNWIND_INFO) || DWARF2_UNWIND_INFO)
159 #error "{DWARF2,TARGET}_UNWIND_INFO required"
160 # endif
161 # if !defined(TARGET_UNWIND_INFO) \
162 && !(defined(EH_RETURN_HANDLER_RTX) || defined(HAVE_eh_return))
163 #error "EH_RETURN_HANDLER_RTX or eh_return required"
164 # endif
165 /* Usually the above error checks will have already triggered an
166 error, but backends may set MUST_USE_SJLJ_EXCEPTIONS for their own
167 reasons. */
168 # if MUST_USE_SJLJ_EXCEPTIONS
169 #error "Must use SJLJ exceptions but configured not to"
170 # endif
171 # endif
172 #else
173 # define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS
174 #endif
176 struct throw_stmt_node GTY(())
178 tree stmt;
179 int region_nr;
182 extern struct htab *get_eh_throw_stmt_table (struct function *);
183 extern void set_eh_throw_stmt_table (struct function *, struct htab *);