This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ast-optimizer-branch] langhooks for pretty printer


On Sun, Jun 09, 2002 at 08:43:20PM +0200, Gabriel Dos Reis wrote:
> 
> First, we should work to incorporate recent changes from mainline.
Ok.

> Second, we should use a single code to hanlde the intersection of C
> and C++ pretty-printing.  
That's a little bit more difficult since (for the moment) nodes 
defined in cp-tree.def are not accessible from the c front-end.

A possible solution is to merge all nodes from c-tree.def and from 
cp-tree.def in a single file.

> 
> [...]
> 
> | 2002-06-09  Sebastian Pop  <s.pop@laposte.net>
> | 
> | 	Added langhooks for pretty printing.
> | 	Use output_indent for indenting.
> | 
> | 	* pretty-print.h: New file.
> | 
> | 	* pretty-print.c: New file.
> 
> I think, there should be c-pretty-print.[ch]
> 
These files contain only language independent functions.

> [...]
> 
> | Index: langhooks.h
> | ===================================================================
> | RCS file: /cvsroot/gcc/gcc/gcc/langhooks.h,v
> | retrieving revision 1.15.2.7
> | diff -d -u -p -r1.15.2.7 langhooks.h
> | --- langhooks.h	6 Jun 2002 03:52:19 -0000	1.15.2.7
> | +++ langhooks.h	9 Jun 2002 17:08:00 -0000
> | @@ -24,6 +24,7 @@ Boston, MA 02111-1307, USA.  */
> |  /* This file should be #include-d after tree.h.  */
> |  
> |  struct diagnostic_context;
> | +struct output_buffer;
> 
> I would prefer #include "diagnostic.h" here.
> 
Agree, 
I've just followed the existing pattern.

> [...]
> 
> | +  /* Function for pretty print a declaration node.  */
> | +  void (*print_declaration) PARAMS ((struct output_buffer *, tree));
> | +  
> | +  /* Function for pretty print a function declaration node.  */
> | +  void (*print_function_decl) PARAMS ((struct output_buffer *, tree));
> 
> Since a function declaration is a declaration, I'm not convinced that
> we want to bring in that oddity from cp/error.c.  I would rather see
> hooks for pretty-printing
> 
>    * declarations
>    * definitions
>    * expressions
>    * statements (if they are relevant)
> 

I think that PRETTY_PRINT_NODE and PRETTY_PRINT_CHAIN are enough and 
we don't need any extra functions in langhooks if all C++ nodes are 
accessible from the C front-end.

pretty_print_function_decl comes from the call graph dumper, 
but it is possible to inline its body in the FUNCTION_DECL case, 
then just call PRETTY_PRINT_NODE for printing a function declaration.

pretty_print_op_prio is defined because some nodes from C++ aren't 
available in the C front-end.

Sebastian.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]