c++: tree dump indentation

Message ID a2299f19-3e42-1c84-8a38-38cd38a962c9@acm.org
State New
Headers show
Series
  • c++: tree dump indentation
Related show

Commit Message

Nathan Sidwell July 28, 2020, 3:35 p.m.
We were always forcing an indent, even if there was nothing to indent. 
Fixed thusly.

             gcc/cp/
             * ptree.c (cxx_print_decl): Better indentation.

pushing

-- 
Nathan Sidwell

Patch

diff --git i/gcc/cp/ptree.c w/gcc/cp/ptree.c
index 224cf14edb5..dfc244fdceb 100644
--- i/gcc/cp/ptree.c
+++ w/gcc/cp/ptree.c
@@ -57,17 +57,35 @@  cxx_print_decl (FILE *file, tree node, int indent)
 	       decl_as_string (node, TFF_TEMPLATE_HEADER));
     }
 
-  indent_to (file, indent + 3);
+  bool need_indent = true;
+
   if (DECL_EXTERNAL (node) && DECL_NOT_REALLY_EXTERN (node))
-    fprintf (file, " not-really-extern");
+    {
+      if (need_indent)
+	indent_to (file, indent + 3);
+      fprintf (file, " not-really-extern");
+      need_indent = false;
+    }
+
   if (TREE_CODE (node) == FUNCTION_DECL
       && DECL_PENDING_INLINE_INFO (node))
-    fprintf (file, " pending-inline-info %p",
-	     (void *) DECL_PENDING_INLINE_INFO (node));
+    {
+      if (need_indent)
+	indent_to (file, indent + 3);
+      fprintf (file, " pending-inline-info %p",
+	       (void *) DECL_PENDING_INLINE_INFO (node));
+      need_indent = false;
+    }
+  
   if (VAR_OR_FUNCTION_DECL_P (node)
       && DECL_TEMPLATE_INFO (node))
-    fprintf (file, " template-info %p",
-	     (void *) DECL_TEMPLATE_INFO (node));
+    {
+      if (need_indent)
+	indent_to (file, indent + 3);
+      fprintf (file, " template-info %p",
+	       (void *) DECL_TEMPLATE_INFO (node));
+      need_indent = false;
+    }
 }
 
 void