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]

[Google 4.6] Backport C++ canonicalization patch (issue6297080)


The enclosed patch for Google 4.6 backports the final pubnames-canonicalization
patch from top of trunk.  It differs slightly from the earlier one because
google/4.6 had an earlier implementation already present.

OK for Google 4.6?

Sterling

2012-06-11  Sterling Augustine  <saugustine@google.com>

	* gcc/c-family/c-pretty-print.h: Adjust pp_c_pretty_print_flags enum.
	* gcc/cp/error.c (decl_as_dwarf_string, lang_decl_dwarf_name): New
	functions.
	* gcc/cp/cp-lang.c (cxx_dwarf_name): Call them.
	* gcc/cp/cp-tree.h: Declare them.

Index: gcc/c-family/c-pretty-print.h
===================================================================
--- gcc/c-family/c-pretty-print.h	(revision 188405)
+++ gcc/c-family/c-pretty-print.h	(working copy)
@@ -30,8 +30,8 @@
 typedef enum
   {
      pp_c_flag_abstract = 1 << 1,
-     pp_c_flag_last_bit = 2,
-     pp_c_flag_gnu_v3 = 4
+     pp_c_flag_gnu_v3 = 1 << 2,
+     pp_c_flag_last_bit = 3
   } pp_c_pretty_print_flags;
 
 
Index: gcc/cp/error.c
===================================================================
--- gcc/cp/error.c	(revision 188405)
+++ gcc/cp/error.c	(working copy)
@@ -2459,7 +2459,22 @@
   return pp_formatted_text (cxx_pp);
 }
 
+/* Wrap decl_as_string with options appropriate for dwarf.  */
+
 const char *
+decl_as_dwarf_string (tree decl, int flags)
+{
+  const char *name;
+  /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag
+     here will be adequate to get the desired behaviour.  */
+  pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3;
+  name = decl_as_string (decl, flags);
+  /* Subsequent calls to the pretty printer shouldn't use this style.  */
+  pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3;
+  return name;
+}
+
+const char *
 decl_as_string (tree decl, int flags)
 {
   reinit_cxx_pp ();
@@ -2479,6 +2494,21 @@
   return pp_formatted_text (cxx_pp);
 }
 
+/* Wrap lang_decl_name with options appropriate for dwarf.  */
+
+const char *
+lang_decl_dwarf_name (tree decl, int v, bool translate)
+{
+  const char *name;
+  /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag
+     here will be adequate to get the desired behaviour.  */
+  pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3;
+  name = lang_decl_name (decl, v, translate);
+  /* Subsequent calls to the pretty printer shouldn't use this style.  */
+  pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3;
+  return name;
+}
+
 /* Generate the three forms of printable names for cxx_printable_name.  */
 
 const char *
Index: gcc/cp/cp-lang.c
===================================================================
--- gcc/cp/cp-lang.c	(revision 188405)
+++ gcc/cp/cp-lang.c	(working copy)
@@ -183,17 +183,11 @@
       && (ANON_AGGRNAME_P (DECL_NAME (t)) || LAMBDANAME_P (DECL_NAME (t))))
     return NULL;
   if (verbosity >= 2)
-    return decl_as_string (t,
+    return decl_as_dwarf_string (t,
 			   TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME
-			   | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS
-                           | TFF_MATCH_GNU_V3_DEMANGLER);
+                                 | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS);
 
-  /* decl_as_string handles namespaces--especially anonymous ones--more
-     appropriately for debugging than cxx_printable_name.  But
-     cxx_printable_name handles templates and global ctors and dtors better.  */
-  if (TREE_CODE (t) == NAMESPACE_DECL)
-    return decl_as_string (t, TFF_MATCH_GNU_V3_DEMANGLER);
-  return cxx_printable_name (t, verbosity);
+  return lang_decl_dwarf_name (t, verbosity, false);
 }
 
 static enum classify_record
Index: gcc/cp/cp-tree.h
===================================================================
--- gcc/cp/cp-tree.h	(revision 188405)
+++ gcc/cp/cp-tree.h	(working copy)
@@ -4913,8 +4913,10 @@
 extern const char *type_as_string_translate	(tree, int);
 extern const char *decl_as_string		(tree, int);
 extern const char *decl_as_string_translate	(tree, int);
+extern const char *decl_as_dwarf_string		(tree, int);
 extern const char *expr_as_string		(tree, int);
 extern const char *lang_decl_name		(tree, int, bool);
+extern const char *lang_decl_dwarf_name		(tree, int, bool);
 extern const char *language_to_string		(enum languages);
 extern const char *class_key_or_enum_as_string	(tree);
 extern void print_instantiation_context		(void);

--
This patch is available for review at http://codereview.appspot.com/6297080


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