diff mbox

Emit DW_AT_{MIPS_,}linkage_name in DW_TAG_variable instead of DW_TAG_member for C++ static data members

Message ID 20100617080011.GS7811@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek June 17, 2010, 8 a.m. UTC
Hi!

My request to allow DW_AT_linkage_name on DW_TAG_member has been denied,
with explanation that it should go into the corresponding DW_TAG_variable.
This patch implements that.

Ok for trunk?

2010-06-17  Jakub Jelinek  <jakub@redhat.com>

	* dwarf2out.c (add_linkage_name): New function.  Don't add
	anything to DW_TAG_member DIEs.
	(add_name_and_src_coords_attributes): Use it.
	(gen_variable_die): Call it for C++ static data members if
	specification is DW_TAG_member.


	Jakub

Comments

Jason Merrill June 21, 2010, 4:01 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

--- gcc/dwarf2out.c.jj	2010-06-17 09:17:12.000000000 +0200
+++ gcc/dwarf2out.c	2010-06-17 09:48:51.000000000 +0200
@@ -17331,6 +17331,34 @@  add_src_coords_attributes (dw_die_ref di
   add_AT_unsigned (die, DW_AT_decl_line, s.line);
 }
 
+/* Add DW_AT_{,MIPS_}linkage_name attribute for the given decl.  */
+
+static void
+add_linkage_name (dw_die_ref die, tree decl)
+{
+  if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
+       && TREE_PUBLIC (decl)
+       && !DECL_ABSTRACT (decl)
+       && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
+       && die->die_tag != DW_TAG_member)
+    {
+      /* Defer until we have an assembler name set.  */
+      if (!DECL_ASSEMBLER_NAME_SET_P (decl))
+	{
+	  limbo_die_node *asm_name;
+
+	  asm_name = ggc_alloc_cleared_limbo_die_node ();
+	  asm_name->die = die;
+	  asm_name->created_for = decl;
+	  asm_name->next = deferred_asm_name;
+	  deferred_asm_name = asm_name;
+	}
+      else if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
+	add_AT_string (die, AT_linkage_name,
+		       IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
+    }
+}
+
 /* Add a DW_AT_name attribute and source coordinate attribute for the
    given decl, but only if it actually has a name.  */
 
@@ -17348,26 +17376,7 @@  add_name_and_src_coords_attributes (dw_d
       if (! DECL_ARTIFICIAL (decl))
 	add_src_coords_attributes (die, decl);
 
-      if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
-	  && TREE_PUBLIC (decl)
-	  && !DECL_ABSTRACT (decl)
-	  && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl)))
-	{
-	  /* Defer until we have an assembler name set.  */
-	  if (!DECL_ASSEMBLER_NAME_SET_P (decl))
-	    {
-	      limbo_die_node *asm_name;
-
-	      asm_name = ggc_alloc_cleared_limbo_die_node ();
-	      asm_name->die = die;
-	      asm_name->created_for = decl;
-	      asm_name->next = deferred_asm_name;
-	      deferred_asm_name = asm_name;
-	    }
-	  else if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
-	    add_AT_string (die, AT_linkage_name,
-			   IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
-	}
+      add_linkage_name (die, decl);
     }
 
 #ifdef VMS_DEBUGGING_INFO
@@ -18985,6 +18994,9 @@  gen_variable_die (tree decl, tree origin
 
 	  if (get_AT_unsigned (old_die, DW_AT_decl_line) != (unsigned) s.line)
 	    add_AT_unsigned (var_die, DW_AT_decl_line, s.line);
+
+	  if (old_die->die_tag == DW_TAG_member)
+	    add_linkage_name (var_die, decl);
 	}
     }
   else