This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] gcc.c: Split up the driver's "main" into smaller functions
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: David Malcolm <dmalcolm at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 3 Oct 2014 16:18:30 +0000
- Subject: Re: [PATCH] gcc.c: Split up the driver's "main" into smaller functions
- Authentication-results: sourceware.org; auth=none
- References: <1412348534-32325-1-git-send-email-dmalcolm at redhat dot com>
On Fri, 3 Oct 2014, David Malcolm wrote:
> The "main" function for the driver in gcc.c has grown from ~200 lines
> in its original form (way back in r262) to ~1000 lines today, with a
> dozen locals (if we include the params).
>
> The following patch splits it up into 15 smaller functions, moving the
> various locals into the places where they're needed, so we can easily
> see e.g where argc/argv get read vs written.
>
> The functions are private methods of a new "driver" class to give an
> extra level of encapsualation beyond just being static in gcc.c, and so
> that we can hide some state as member data inside the driver instance.
>
> Turning them into named functions/methods also makes it easier to talk
> about the different phases of "main", and put breakpoints on them.
>
> Bootstrapped®rtested on x86_64-unknown-linux-gnu (Fedora 20).
>
> OK for trunk?
OK, minus the if (0) code:
> + if (0)
> + {
> + int i;
> + for (i = 0; i < argc; i++)
> + printf ("argc[%i]: %s\n", i, argv[i]);
> + }
--
Joseph S. Myers
joseph@codesourcery.com