Commit 7cdfcf60 by Geoffrey Keating Committed by Geoffrey Keating

Index: gcc/ChangeLog

2006-02-13  Geoffrey Keating  <geoffk@apple.com>

	* dwarf2out.c (base_type_die): Don't add AT_name here.
	(subrange_type_die): Don't add AT_name here.
	(modified_type_die): Rearrange code flow.  Do add AT_name here.

Index: gcc/testsuite/ChangeLog
2006-02-13  Geoffrey Keating  <geoffk@apple.com>

	* objc.dg/dwarf-1.m: New.

From-SVN: r110925
parent bd361d85
2006-02-13 Geoffrey Keating <geoffk@apple.com>
* dwarf2out.c (base_type_die): Don't add AT_name here.
(subrange_type_die): Don't add AT_name here.
(modified_type_die): Rearrange code flow. Do add AT_name here.
2006-02-13 Zdenek Dvorak <dvorakz@suse.cz> 2006-02-13 Zdenek Dvorak <dvorakz@suse.cz>
PR rtl-optimization/26247 PR rtl-optimization/26247
......
...@@ -8085,23 +8085,11 @@ static dw_die_ref ...@@ -8085,23 +8085,11 @@ static dw_die_ref
base_type_die (tree type) base_type_die (tree type)
{ {
dw_die_ref base_type_result; dw_die_ref base_type_result;
const char *type_name;
enum dwarf_type encoding; enum dwarf_type encoding;
tree name = TYPE_NAME (type);
if (TREE_CODE (type) == ERROR_MARK || TREE_CODE (type) == VOID_TYPE) if (TREE_CODE (type) == ERROR_MARK || TREE_CODE (type) == VOID_TYPE)
return 0; return 0;
if (name)
{
if (TREE_CODE (name) == TYPE_DECL)
name = DECL_NAME (name);
type_name = IDENTIFIER_POINTER (name);
}
else
type_name = "__unknown__";
switch (TREE_CODE (type)) switch (TREE_CODE (type))
{ {
case INTEGER_TYPE: case INTEGER_TYPE:
...@@ -8145,10 +8133,11 @@ base_type_die (tree type) ...@@ -8145,10 +8133,11 @@ base_type_die (tree type)
} }
base_type_result = new_die (DW_TAG_base_type, comp_unit_die, type); base_type_result = new_die (DW_TAG_base_type, comp_unit_die, type);
if (demangle_name_func)
type_name = (*demangle_name_func) (type_name);
add_AT_string (base_type_result, DW_AT_name, type_name); /* This probably indicates a bug. */
if (! TYPE_NAME (type))
add_name_attribute (base_type_result, "__unknown__");
add_AT_unsigned (base_type_result, DW_AT_byte_size, add_AT_unsigned (base_type_result, DW_AT_byte_size,
int_size_in_bytes (type)); int_size_in_bytes (type));
add_AT_unsigned (base_type_result, DW_AT_encoding, encoding); add_AT_unsigned (base_type_result, DW_AT_encoding, encoding);
...@@ -8302,30 +8291,15 @@ is_subrange_type (tree type) ...@@ -8302,30 +8291,15 @@ is_subrange_type (tree type)
static dw_die_ref static dw_die_ref
subrange_type_die (tree type, dw_die_ref context_die) subrange_type_die (tree type, dw_die_ref context_die)
{ {
dw_die_ref subtype_die;
dw_die_ref subrange_die; dw_die_ref subrange_die;
tree name = TYPE_NAME (type);
const HOST_WIDE_INT size_in_bytes = int_size_in_bytes (type); const HOST_WIDE_INT size_in_bytes = int_size_in_bytes (type);
tree subtype = TREE_TYPE (type);
if (context_die == NULL) if (context_die == NULL)
context_die = comp_unit_die; context_die = comp_unit_die;
if (TREE_CODE (subtype) == ENUMERAL_TYPE)
subtype_die = gen_enumeration_type_die (subtype, context_die);
else
subtype_die = base_type_die (subtype);
subrange_die = new_die (DW_TAG_subrange_type, context_die, type); subrange_die = new_die (DW_TAG_subrange_type, context_die, type);
if (name != NULL) if (int_size_in_bytes (TREE_TYPE (type)) != size_in_bytes)
{
if (TREE_CODE (name) == TYPE_DECL)
name = DECL_NAME (name);
add_name_attribute (subrange_die, IDENTIFIER_POINTER (name));
}
if (int_size_in_bytes (subtype) != size_in_bytes)
{ {
/* The size of the subrange type and its base type do not match, /* The size of the subrange type and its base type do not match,
so we need to generate a size attribute for the subrange type. */ so we need to generate a size attribute for the subrange type. */
...@@ -8338,7 +8312,6 @@ subrange_type_die (tree type, dw_die_ref context_die) ...@@ -8338,7 +8312,6 @@ subrange_type_die (tree type, dw_die_ref context_die)
if (TYPE_MAX_VALUE (type) != NULL) if (TYPE_MAX_VALUE (type) != NULL)
add_bound_info (subrange_die, DW_AT_upper_bound, add_bound_info (subrange_die, DW_AT_upper_bound,
TYPE_MAX_VALUE (type)); TYPE_MAX_VALUE (type));
add_AT_die_ref (subrange_die, DW_AT_type, subtype_die);
return subrange_die; return subrange_die;
} }
...@@ -8351,21 +8324,21 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type, ...@@ -8351,21 +8324,21 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
dw_die_ref context_die) dw_die_ref context_die)
{ {
enum tree_code code = TREE_CODE (type); enum tree_code code = TREE_CODE (type);
dw_die_ref mod_type_die = NULL; dw_die_ref mod_type_die;
dw_die_ref sub_die = NULL; dw_die_ref sub_die = NULL;
tree item_type = NULL; tree item_type = NULL;
if (code != ERROR_MARK)
{
tree qualified_type; tree qualified_type;
tree name;
if (code == ERROR_MARK)
return NULL;
/* See if we already have the appropriately qualified variant of /* See if we already have the appropriately qualified variant of
this type. */ this type. */
qualified_type qualified_type
= get_qualified_type (type, = get_qualified_type (type,
((is_const_type ? TYPE_QUAL_CONST : 0) ((is_const_type ? TYPE_QUAL_CONST : 0)
| (is_volatile_type | (is_volatile_type ? TYPE_QUAL_VOLATILE : 0)));
? TYPE_QUAL_VOLATILE : 0)));
/* If we do, then we can just use its DIE, if it exists. */ /* If we do, then we can just use its DIE, if it exists. */
if (qualified_type) if (qualified_type)
...@@ -8375,36 +8348,31 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type, ...@@ -8375,36 +8348,31 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
return mod_type_die; return mod_type_die;
} }
name = qualified_type ? TYPE_NAME (qualified_type) : NULL;
/* Handle C typedef types. */ /* Handle C typedef types. */
if (qualified_type && TYPE_NAME (qualified_type) if (name && TREE_CODE (name) == TYPE_DECL && DECL_ORIGINAL_TYPE (name))
&& TREE_CODE (TYPE_NAME (qualified_type)) == TYPE_DECL
&& DECL_ORIGINAL_TYPE (TYPE_NAME (qualified_type)))
{ {
tree type_name = TYPE_NAME (qualified_type); tree dtype = TREE_TYPE (name);
tree dtype = TREE_TYPE (type_name);
if (qualified_type == dtype) if (qualified_type == dtype)
{ {
/* For a named type, use the typedef. */ /* For a named type, use the typedef. */
gen_type_die (qualified_type, context_die); gen_type_die (qualified_type, context_die);
mod_type_die = lookup_type_die (qualified_type); return lookup_type_die (qualified_type);
} }
else if (is_const_type < TYPE_READONLY (dtype) else if (DECL_ORIGINAL_TYPE (name)
|| is_volatile_type < TYPE_VOLATILE (dtype)) && (is_const_type < TYPE_READONLY (dtype)
|| is_volatile_type < TYPE_VOLATILE (dtype)))
/* cv-unqualified version of named type. Just use the unnamed /* cv-unqualified version of named type. Just use the unnamed
type to which it refers. */ type to which it refers. */
mod_type_die return modified_type_die (DECL_ORIGINAL_TYPE (name),
= modified_type_die (DECL_ORIGINAL_TYPE (type_name),
is_const_type, is_volatile_type, is_const_type, is_volatile_type,
context_die); context_die);
/* Else cv-qualified version of named type; fall through. */ /* Else cv-qualified version of named type; fall through. */
} }
if (mod_type_die) if (is_const_type)
/* OK. */
;
else if (is_const_type)
{ {
mod_type_die = new_die (DW_TAG_const_type, comp_unit_die, type); mod_type_die = new_die (DW_TAG_const_type, comp_unit_die, type);
sub_die = modified_type_die (type, 0, is_volatile_type, context_die); sub_die = modified_type_die (type, 0, is_volatile_type, context_die);
...@@ -8419,9 +8387,6 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type, ...@@ -8419,9 +8387,6 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die, type); mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size, add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT); simple_type_size_in_bits (type) / BITS_PER_UNIT);
#if 0
add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
#endif
item_type = TREE_TYPE (type); item_type = TREE_TYPE (type);
} }
else if (code == REFERENCE_TYPE) else if (code == REFERENCE_TYPE)
...@@ -8429,13 +8394,13 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type, ...@@ -8429,13 +8394,13 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die, type); mod_type_die = new_die (DW_TAG_reference_type, comp_unit_die, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size, add_AT_unsigned (mod_type_die, DW_AT_byte_size,
simple_type_size_in_bits (type) / BITS_PER_UNIT); simple_type_size_in_bits (type) / BITS_PER_UNIT);
#if 0
add_AT_unsigned (mod_type_die, DW_AT_address_class, 0);
#endif
item_type = TREE_TYPE (type); item_type = TREE_TYPE (type);
} }
else if (is_subrange_type (type)) else if (is_subrange_type (type))
{
mod_type_die = subrange_type_die (type, context_die); mod_type_die = subrange_type_die (type, context_die);
item_type = TREE_TYPE (type);
}
else if (is_base_type (type)) else if (is_base_type (type))
mod_type_die = base_type_die (type); mod_type_die = base_type_die (type);
else else
...@@ -8449,20 +8414,30 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type, ...@@ -8449,20 +8414,30 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
that copy might have a different TYPE_UID from the original that copy might have a different TYPE_UID from the original
..._TYPE node. */ ..._TYPE node. */
if (TREE_CODE (type) != VECTOR_TYPE) if (TREE_CODE (type) != VECTOR_TYPE)
mod_type_die = lookup_type_die (type_main_variant (type)); return lookup_type_die (type_main_variant (type));
else else
/* Vectors have the debugging information in the type, /* Vectors have the debugging information in the type,
not the main variant. */ not the main variant. */
mod_type_die = lookup_type_die (type); return lookup_type_die (type);
gcc_assert (mod_type_die);
} }
/* We want to equate the qualified type to the die below. */ /* Builtin types don't have a DECL_ORIGINAL_TYPE. For those,
type = qualified_type; don't output a DW_TAG_typedef, since there isn't one in the
user's program; just attach a DW_AT_name to the type. */
if (name
&& (TREE_CODE (name) != TYPE_DECL || TREE_TYPE (name) == qualified_type))
{
if (TREE_CODE (name) == TYPE_DECL)
/* Could just call add_name_and_src_coords_attributes here,
but since this is a builtin type it doesn't have any
useful source coordinates anyway. */
name = DECL_NAME (name);
add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name));
} }
if (type) if (qualified_type)
equate_type_number_to_die (type, mod_type_die); equate_type_number_to_die (qualified_type, mod_type_die);
if (item_type) if (item_type)
/* We must do this after the equate_type_number_to_die call, in case /* We must do this after the equate_type_number_to_die call, in case
this is a recursive type. This ensures that the modified_type_die this is a recursive type. This ensures that the modified_type_die
......
2006-02-13 Geoffrey Keating <geoffk@apple.com>
* objc.dg/dwarf-1.m: New.
2006-02-13 Roger Sayle <roger@eyesopen.com> 2006-02-13 Roger Sayle <roger@eyesopen.com>
PR middle-end/24427 PR middle-end/24427
/* { dg-options "-gdwarf-2 -dA" } */
/* { dg-final { scan-assembler "\"id.0\".*DW_AT_name" } } */
@interface foo
id x;
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment