[PATCH] gcc.c: Split up the driver's "main" into smaller functions

Joseph S. Myers joseph@codesourcery.com
Fri Oct 3 16:18:00 GMT 2014


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&regrtested 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



More information about the Gcc-patches mailing list