public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4184] Make flow of option processing more readily visible
@ 2021-10-05 11:34 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-10-05 11:34 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9856132b5b8a5e75a81763fe06e4b8c06011d870
commit r12-4184-g9856132b5b8a5e75a81763fe06e4b8c06011d870
Author: Richard Biener <rguenther@suse.de>
Date: Tue Oct 5 12:35:57 2021 +0200
Make flow of option processing more readily visible
This moves calls to various option processing stages to one place,
toplev::main.
2021-10-05 Richard Biener <rguenther@suse.de>
* toplev.c (no_backend): Remove global var.
(process_options): Pass in no_backend, move post_options
langhook call to toplev::main.
(do_compile): Pass in no_backend, move process_options call
to toplev::main.
(toplev::run_self_tests): Check no_backend at the caller.
(toplev::main): Call post_options and process_options
split out from do_compile, do self-tests only if
no_backend is initialized.
Diff:
---
gcc/toplev.c | 43 +++++++++++++++++++------------------------
1 file changed, 19 insertions(+), 24 deletions(-)
diff --git a/gcc/toplev.c b/gcc/toplev.c
index ec9f998a49b..70769087c13 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -104,8 +104,6 @@ along with GCC; see the file COPYING3. If not see
#endif
static void general_init (const char *, bool);
-static void do_compile ();
-static void process_options (void);
static void backend_init (void);
static int lang_dependent_init (const char *);
static void init_asm_output (const char *);
@@ -114,9 +112,6 @@ static void finalize (bool);
static void crash_signal (int) ATTRIBUTE_NORETURN;
static void compile_file (void);
-/* True if we don't need a backend (e.g. preprocessing only). */
-static bool no_backend;
-
/* Decoded options, and number of such options. */
struct cl_decoded_option *save_decoded_options;
unsigned int save_decoded_options_count;
@@ -1233,7 +1228,7 @@ parse_alignment_opts (void)
/* Process the options that have been parsed. */
static void
-process_options (void)
+process_options (bool no_backend)
{
const char *language_string = lang_hooks.name;
/* Just in case lang_hooks.post_options ends up calling a debug_hook.
@@ -1242,12 +1237,6 @@ process_options (void)
maximum_field_alignment = initial_max_fld_align * BITS_PER_UNIT;
- /* Allow the front end to perform consistency checks and do further
- initialization based on the command line options. This hook also
- sets the original filename if appropriate (e.g. foo.i -> foo.c)
- so we can correctly initialize debug output. */
- no_backend = lang_hooks.post_options (&main_input_filename);
-
/* Some machines may reject certain combinations of options. */
location_t saved_location = input_location;
input_location = UNKNOWN_LOCATION;
@@ -2145,10 +2134,8 @@ standard_type_bitsize (int bitsize)
/* Initialize the compiler, and compile the input file. */
static void
-do_compile ()
+do_compile (bool no_backend)
{
- process_options ();
-
/* Don't do any more if an error has already occurred. */
if (!seen_error ())
{
@@ -2277,11 +2264,6 @@ toplev::start_timevars ()
void
toplev::run_self_tests ()
{
- if (no_backend)
- {
- error_at (UNKNOWN_LOCATION, "self-tests incompatible with %<-E%>");
- return;
- }
#if CHECKING_P
/* Reset some state. */
input_location = UNKNOWN_LOCATION;
@@ -2368,17 +2350,30 @@ toplev::main (int argc, char **argv)
/* Exit early if we can (e.g. -help). */
if (!exit_after_options)
{
+ /* Allow the front end to perform consistency checks and do further
+ initialization based on the command line options. This hook also
+ sets the original filename if appropriate (e.g. foo.i -> foo.c)
+ so we can correctly initialize debug output. */
+ bool no_backend = lang_hooks.post_options (&main_input_filename);
+
+ process_options (no_backend);
+
if (m_use_TV_TOTAL)
start_timevars ();
- do_compile ();
+ do_compile (no_backend);
+
+ if (flag_self_test)
+ {
+ if (no_backend)
+ error_at (UNKNOWN_LOCATION, "self-tests incompatible with %<-E%>");
+ else
+ run_self_tests ();
+ }
}
if (warningcount || errorcount || werrorcount)
print_ignored_options ();
- if (flag_self_test)
- run_self_tests ();
-
/* Invoke registered plugin callbacks if any. Some plugins could
emit some diagnostics here. */
invoke_plugin_callbacks (PLUGIN_FINISH, NULL);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-05 11:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 11:34 [gcc r12-4184] Make flow of option processing more readily visible Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).