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]

[tree-ssa] PATCH to use DECL_UID in dumps


Along the same lines as rth's recent patch, this patch changes the tree
dumpers to use DECL_UID/TYPE_UID for decls and types without names.  The
difference between this and LABEL_DECL_UID is that DECL_UID is per-file and
LABEL_DECL_UID is per-function, so the latter is better to use when
available.

I also restored the debug_c_tree function, called by the pct macro in
gdbinit.in.

Applied to tree-ssa branch.

2003-11-16  Jason Merrill  <jason@redhat.com>

	* c-pretty-print.c (debug_c_tree): Restore removed fn.
	* diagnostic.h: Declare it.

	* tree-pretty-print.c (dump_generic_node): Use DECL_UID when
	dumping anonymous decls.

*** tree-pretty-print.c.~1~	2003-11-15 16:26:03.000000000 -0500
--- tree-pretty-print.c	2003-11-16 12:31:34.000000000 -0500
*************** dump_generic_node (pretty_printer *buffe
*** 287,293 ****
  	  if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
  	    pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
  	  else
! 	    pp_printf (buffer, "<U%x>", MASK_POINTER (node));
  
  	  pp_character (buffer, ')');
            pp_space (buffer);
--- 287,293 ----
  	  if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
  	    pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))));
  	  else
! 	    pp_printf (buffer, "<T%x>", TYPE_UID (node));
  
  	  pp_character (buffer, ')');
            pp_space (buffer);
*************** dump_generic_node (pretty_printer *buffe
*** 518,532 ****
      case LABEL_DECL:
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
        else
!         pp_printf (buffer, "<U%x>", MASK_POINTER (node));
        break;
  
      case CONST_DECL:
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
        else
!         pp_printf (buffer, "<U%x>", MASK_POINTER (node));
        break;
  
      case TYPE_DECL:
--- 518,535 ----
      case LABEL_DECL:
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
+       else if (LABEL_DECL_UID (node) != -1)
+         pp_printf (buffer, "<L" HOST_WIDE_INT_PRINT_DEC ">",
+ 		   LABEL_DECL_UID (node));
        else
!         pp_printf (buffer, "<D%x>", DECL_UID (node));
        break;
  
      case CONST_DECL:
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
        else
!         pp_printf (buffer, "<D%x>", DECL_UID (node));
        break;
  
      case TYPE_DECL:
*************** dump_generic_node (pretty_printer *buffe
*** 563,569 ****
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
        else
!         pp_printf (buffer, "<U%x>", MASK_POINTER (node));
        break;
  
      case RESULT_DECL:
--- 566,572 ----
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
        else
!         pp_printf (buffer, "<D%x>", DECL_UID (node));
        break;
  
      case RESULT_DECL:
*************** dump_generic_node (pretty_printer *buffe
*** 574,587 ****
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
        else
! 	pp_printf (buffer, "<U%x>", MASK_POINTER (node));
        break;
  
      case NAMESPACE_DECL:
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
        else
!         pp_printf (buffer, "<U%x>", MASK_POINTER (node));
        break;
  
      case COMPONENT_REF:
--- 577,590 ----
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
        else
! 	pp_printf (buffer, "<D%x>", DECL_UID (node));
        break;
  
      case NAMESPACE_DECL:
        if (DECL_NAME (node))
  	pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (node)));
        else
!         pp_printf (buffer, "<D%x>", DECL_UID (node));
        break;
  
      case COMPONENT_REF:
*************** dump_generic_node (pretty_printer *buffe
*** 658,664 ****
  		if (DECL_NAME (val))
  		  pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (val)));
  		else
! 		  pp_printf (buffer, "<U%x>", MASK_POINTER (val));
  	      }
  	    else
  	      {
--- 661,667 ----
  		if (DECL_NAME (val))
  		  pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (val)));
  		else
! 		  pp_printf (buffer, "<D%x>", DECL_UID (val));
  	      }
  	    else
  	      {
*** c-pretty-print.c.~1~	2003-11-15 16:26:03.000000000 -0500
--- c-pretty-print.c	2003-11-14 18:15:00.000000000 -0500
*************** print_c_tree (FILE *file, tree t)
*** 2201,2206 ****
--- 2201,2215 ----
    pp_flush (pp);
  }
  
+ /* Print the tree T in full, on stderr.  */
+ 
+ void
+ debug_c_tree (tree t)
+ {
+   print_c_tree (stderr, t);
+   fputc ('\n', stderr);
+ }
+ 
  /* Output the DECL_NAME of T.  If T has no DECL_NAME, output a string made
     up of T's memory address.  */
  
*** diagnostic.h.~1~	2003-11-15 16:26:03.000000000 -0500
--- diagnostic.h	2003-11-14 18:16:09.000000000 -0500
*************** extern void print_generic_decl (FILE *, 
*** 193,196 ****
--- 193,197 ----
  
  extern void debug_generic_expr (tree);
  extern void debug_generic_stmt (tree);
+ extern void debug_c_tree (tree);
  #endif /* ! GCC_DIAGNOSTIC_H */

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