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: [tree-ssa] Pretty print tweak


Op za 05-07-2003, om 16:07 schreef Diego Novillo:
> On Sat, 2003-07-05 at 09:39, Steven Bosscher wrote:
> 
> > 	* tree-pretty-print.c (dump_generic_node): Do not dump the
> > 	else clause of a COND_EXPR if it is an empty statmement.
> > 
> > 
> Could you change it so that it *does* output the empty ELSE_CLAUSE when
> TDF_BLOCKS is specified?  Otherwise, listings with basic block

OK

> information are confusing.  THEN_CLAUSE should be treated similarly if
> it's empty.

COND_EXPR_THEN is special because it can be empty empty even when
COND_EXPR_ELSE is not; this gives you confusing tree dumps as well.  I
think writing a ';' after the if should help.  Something like this.

Gr.
Steven

Index: tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-pretty-print.c,v
retrieving revision 1.1.2.31
diff -c -3 -p -r1.1.2.31 tree-pretty-print.c
*** tree-pretty-print.c	1 Jul 2003 04:04:31 -0000	1.1.2.31
--- tree-pretty-print.c	5 Jul 2003 15:14:20 -0000
*************** dump_generic_node (buffer, node, spc, fl
*** 699,706 ****
  	  output_add_character (buffer, ')');
  	  if (!(flags & TDF_SLIM))
  	    {
! 	      /* Output COND_EXPR_THEN.  */
! 	      if (COND_EXPR_THEN (node))
  		{
  		  newline_and_indent (buffer, spc+2);
  		  output_add_character (buffer, '{');
--- 699,710 ----
  	  output_add_character (buffer, ')');
  	  if (!(flags & TDF_SLIM))
  	    {
! 	      /* Output COND_EXPR_THEN if it is not empty.
! 		 Always dump if TDF_BLOCKS is set; otherwise,
! 		 listings with basic block info are confusing.  */
! 	      if (COND_EXPR_THEN (node)
! 		  && !(IS_EMPTY_STMT (COND_EXPR_THEN (node))
! 		       && !(flags & TDF_BLOCKS)))
  		{
  		  newline_and_indent (buffer, spc+2);
  		  output_add_character (buffer, '{');
*************** dump_generic_node (buffer, node, spc, fl
*** 710,718 ****
  		  newline_and_indent (buffer, spc+2);
  		  output_add_character (buffer, '}');
  		}
  
  	      /* Output COND_EXPR_ELSE.  */
! 	      if (COND_EXPR_ELSE (node))
  		{
  		  newline_and_indent (buffer, spc);
  		  output_add_string (buffer, "else");
--- 714,730 ----
  		  newline_and_indent (buffer, spc+2);
  		  output_add_character (buffer, '}');
  		}
+ 	      else
+ 		{
+ 		  /* Output a semicolon for readability.  */
+ 		  newline_and_indent (buffer, spc+2);
+ 		  output_add_character (buffer, ';');
+ 		}
  
  	      /* Output COND_EXPR_ELSE.  */
! 	      if (COND_EXPR_ELSE (node)
! 		  && !(IS_EMPTY_STMT (COND_EXPR_ELSE (node))
! 		       && !(flags & TDF_BLOCKS)))
  		{
  		  newline_and_indent (buffer, spc);
  		  output_add_string (buffer, "else");

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