tree-pretty-print.c (maybe_dump_asm_name): New.
authorRichard Henderson <rth@redhat.com>
Thu, 18 Jun 2009 00:30:48 +0000 (17:30 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 18 Jun 2009 00:30:48 +0000 (17:30 -0700)
        * tree-pretty-print.c (maybe_dump_asm_name): New.
        (dump_decl_name): Use it.
        (PRINT_FUNCTION_NAME): Merge into...
        (dump_function_name): ... here.  Use maybe_dump_asm_name.

From-SVN: r148642

gcc/ChangeLog
gcc/tree-pretty-print.c

index 1f8cb377ca421f31a0518db5c9ae1a3d9cb82b5b..b186ffa57fd2c82f1cfb6dfea512c0a3e2775ae4 100644 (file)
@@ -1,3 +1,10 @@
+2009-06-17  Richard Henderson  <rth@redhat.com>
+
+       * tree-pretty-print.c (maybe_dump_asm_name): New.
+       (dump_decl_name): Use it.
+       (PRINT_FUNCTION_NAME): Merge into...
+       (dump_function_name): ... here.  Use maybe_dump_asm_name.
+
 2009-06-17  Cary Coutant  <ccoutant@google.com>
 
        * dbxout.c (dbxout_source_line): Add is_stmt parameter.
index 0599e3c48977f336487721bfb2b2ca00e0244780..cd8033a152331a15c6b4b4e389afd648b81e8b4c 100644 (file)
@@ -50,11 +50,6 @@ static void do_niy (pretty_printer *, const_tree);
 
 #define NIY do_niy(buffer,node)
 
-#define PRINT_FUNCTION_NAME(NODE)  pp_printf             \
-  (buffer, "%s", TREE_CODE (NODE) == NOP_EXPR ?              \
-   lang_hooks.decl_printable_name (TREE_OPERAND (NODE, 0), 1) : \
-   lang_hooks.decl_printable_name (NODE, 1))
-
 static pretty_printer buffer;
 static int initialized = 0;
 
@@ -160,6 +155,32 @@ print_generic_expr (FILE *file, tree t, int flags)
   dump_generic_node (&buffer, t, 0, flags, false);
 }
 
+/* Dump the assembly name of a decl node if it's sufficiently different
+   from the decl name.  */
+
+static void
+maybe_dump_asm_name (pretty_printer *buffer, tree node, int flags)
+{
+  tree n, a;
+
+  if (flags & TDF_SLIM)
+    return;
+  if (DECL_NAME (node) == NULL || !DECL_ASSEMBLER_NAME_SET_P (node))
+    return;
+
+  n = DECL_NAME (node);
+  a = DECL_ASSEMBLER_NAME (node);
+  if (n == a)
+    return;
+  if (strncmp (IDENTIFIER_POINTER (n), "__builtin_", 10) == 0)
+    return;
+
+  pp_space (buffer);
+  pp_character (buffer, '[');
+  pp_tree_identifier (buffer, a);
+  pp_character (buffer, ']');
+}
+
 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
    in FLAGS.  */
 
@@ -182,6 +203,8 @@ dump_decl_name (pretty_printer *buffer, tree node, int flags)
          pp_printf (buffer, "%c.%u", c, DECL_UID (t));
        }
     }
+
+  maybe_dump_asm_name (buffer, node, flags);
 }
 
 /* Like the above, but used for pretty printing function calls.  */
@@ -190,7 +213,12 @@ static void
 dump_function_name (pretty_printer *buffer, tree node)
 {
   if (DECL_NAME (node))
-    PRINT_FUNCTION_NAME (node);
+    {
+      if (TREE_CODE (node) == NOP_EXPR)
+       node = TREE_OPERAND (node, 0);
+      pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
+      maybe_dump_asm_name (buffer, node, 0);
+    }
   else
     dump_decl_name (buffer, node, 0);
 }