* passes.c (init_optimization_passes): Remove two copies of ehcleanup
[official-gcc/constexpr.git] / gcc / except.h
blobe407ec2c7f80d45e0f05da207b5f34daaa572902
1 /* Exception Handling interface routines.
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2007, 2008 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/>. */
22 #include "sbitmap.h"
23 #include "vecprim.h"
25 struct function;
27 /* Per-function EH data. Used only in except.c, but GC and others
28 manipulate pointers to the opaque type. */
29 struct eh_status;
31 /* Internal structure describing a region. */
32 struct eh_region;
34 /* Test: is exception handling turned on? */
35 extern int doing_eh (int);
37 /* Note that the current EH region (if any) may contain a throw, or a
38 call to a function which itself may contain a throw. */
39 extern void note_eh_region_may_contain_throw (struct eh_region *);
41 /* Invokes CALLBACK for every exception handler label. Only used by old
42 loop hackery; should not be used by new code. */
43 extern void for_each_eh_label (void (*) (rtx));
45 /* Invokes CALLBACK for every exception region in the current function. */
46 extern void for_each_eh_region (void (*) (struct eh_region *));
48 /* Determine if the given INSN can throw an exception. */
49 extern bool can_throw_internal_1 (int, bool, bool);
50 extern bool can_throw_internal (const_rtx);
51 extern bool can_throw_external_1 (int, bool, bool);
52 extern bool can_throw_external (const_rtx);
54 /* Set TREE_NOTHROW and cfun->all_throwers_are_sibcalls. */
55 extern unsigned int set_nothrow_function_flags (void);
57 /* After initial rtl generation, call back to finish generating
58 exception support code. */
59 extern void finish_eh_generation (void);
61 extern void init_eh (void);
62 extern void init_eh_for_function (void);
64 extern rtx reachable_handlers (rtx);
65 extern void maybe_remove_eh_handler (rtx);
66 void remove_eh_region (int);
68 extern void convert_from_eh_region_ranges (void);
69 extern unsigned int convert_to_eh_region_ranges (void);
70 extern void find_exception_handler_labels (void);
71 extern bool current_function_has_exception_handlers (void);
72 extern void output_function_exception_table (const char *);
74 extern void expand_builtin_unwind_init (void);
75 extern rtx expand_builtin_eh_return_data_regno (tree);
76 extern rtx expand_builtin_extract_return_addr (tree);
77 extern void expand_builtin_init_dwarf_reg_sizes (tree);
78 extern rtx expand_builtin_frob_return_addr (tree);
79 extern rtx expand_builtin_dwarf_sp_column (void);
80 extern void expand_builtin_eh_return (tree, tree);
81 extern void expand_eh_return (void);
82 extern rtx expand_builtin_extend_pointer (tree);
83 extern rtx get_exception_pointer (void);
84 extern rtx get_exception_filter (void);
85 typedef tree (*duplicate_eh_regions_map) (tree, void *);
86 extern int duplicate_eh_regions (struct function *, duplicate_eh_regions_map,
87 void *, int, int);
89 extern void sjlj_emit_function_exit_after (rtx);
90 extern void default_init_unwind_resume_libfunc (void);
92 extern struct eh_region *gen_eh_region_cleanup (struct eh_region *,
93 struct eh_region *);
94 extern struct eh_region *gen_eh_region_try (struct eh_region *);
95 extern struct eh_region *gen_eh_region_catch (struct eh_region *, tree);
96 extern struct eh_region *gen_eh_region_allowed (struct eh_region *, tree);
97 extern struct eh_region *gen_eh_region_must_not_throw (struct eh_region *);
98 extern int get_eh_region_number (struct eh_region *);
99 extern bool get_eh_region_may_contain_throw (struct eh_region *);
100 extern tree get_eh_region_tree_label (struct eh_region *);
101 extern void set_eh_region_tree_label (struct eh_region *, tree);
103 extern void foreach_reachable_handler (int, bool, bool,
104 void (*) (struct eh_region *, void *),
105 void *);
107 extern void collect_eh_region_array (void);
108 extern void expand_resx_expr (tree);
109 extern void verify_eh_tree (struct function *);
110 extern void dump_eh_tree (FILE *, struct function *);
111 extern bool eh_region_outer_p (struct function *, int, int);
112 extern int eh_region_outermost (struct function *, int, int);
114 /* If non-NULL, this is a function that returns an expression to be
115 executed if an unhandled exception is propagated out of a cleanup
116 region. For example, in C++, an exception thrown by a destructor
117 during stack unwinding is required to result in a call to
118 `std::terminate', so the C++ version of this function returns a
119 CALL_EXPR for `std::terminate'. */
120 extern gimple (*lang_protect_cleanup_actions) (void);
122 /* Return true if type A catches type B. */
123 extern int (*lang_eh_type_covers) (tree a, tree b);
125 /* Map a type to a runtime object to match type. */
126 extern tree (*lang_eh_runtime_type) (tree);
129 /* Just because the user configured --with-sjlj-exceptions=no doesn't
130 mean that we can use call frame exceptions. Detect that the target
131 has appropriate support. */
133 #ifndef MUST_USE_SJLJ_EXCEPTIONS
134 # if defined (EH_RETURN_DATA_REGNO) \
135 && (defined (TARGET_UNWIND_INFO) \
136 || (DWARF2_UNWIND_INFO \
137 && (defined (EH_RETURN_HANDLER_RTX) \
138 || defined (HAVE_eh_return))))
139 # define MUST_USE_SJLJ_EXCEPTIONS 0
140 # else
141 # define MUST_USE_SJLJ_EXCEPTIONS 1
142 # endif
143 #endif
145 #ifdef CONFIG_SJLJ_EXCEPTIONS
146 # if CONFIG_SJLJ_EXCEPTIONS == 1
147 # define USING_SJLJ_EXCEPTIONS 1
148 # endif
149 # if CONFIG_SJLJ_EXCEPTIONS == 0
150 # define USING_SJLJ_EXCEPTIONS 0
151 # if !defined(EH_RETURN_DATA_REGNO)
152 #error "EH_RETURN_DATA_REGNO required"
153 # endif
154 # if ! (defined(TARGET_UNWIND_INFO) || DWARF2_UNWIND_INFO)
155 #error "{DWARF2,TARGET}_UNWIND_INFO required"
156 # endif
157 # if !defined(TARGET_UNWIND_INFO) \
158 && !(defined(EH_RETURN_HANDLER_RTX) || defined(HAVE_eh_return))
159 #error "EH_RETURN_HANDLER_RTX or eh_return required"
160 # endif
161 /* Usually the above error checks will have already triggered an
162 error, but backends may set MUST_USE_SJLJ_EXCEPTIONS for their own
163 reasons. */
164 # if MUST_USE_SJLJ_EXCEPTIONS
165 #error "Must use SJLJ exceptions but configured not to"
166 # endif
167 # endif
168 #else
169 # define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS
170 #endif
172 struct throw_stmt_node GTY(())
174 gimple stmt;
175 int region_nr;
178 extern struct htab *get_eh_throw_stmt_table (struct function *);
179 extern void set_eh_throw_stmt_table (struct function *, struct htab *);
180 extern void remove_unreachable_regions (sbitmap, sbitmap);
181 extern VEC(int,heap) * label_to_region_map (void);
182 extern int num_eh_regions (void);