Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Fix debugging enum types/values.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Sep 16, 2013
1 parent 28c67ca commit 021dda8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from Object class.
* d-decls.cc(VarDeclaration::toSymbol): Remove redundant CONST_DECL
code as VarDeclaration::toObjFile does not emit manifest constants.
* d-ctype.cc(TypeEnum::toCtype): Generate CONST_DECLs for enumeration
members for correct debugging.
* d-objfile.cc(build_type_decl): Use fully qualified type name in
debugging code.

2013-09-10 Iain Buclaw <ibuclaw@gdcproject.org>

Expand Down
2 changes: 1 addition & 1 deletion gcc/d/d-codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ build_two_field_type (tree t1, tree t2, Type *type, const char *n1, const char *
// dynamic array varargs.
TYPE_LANG_SPECIFIC (rec_type) = build_d_type_lang_specific (type);

// Build_type_decl will try to declare it as top-level type which can
// build_type_decl will try to declare it as top-level type which can
// break debugging info for element types.
tree stub_decl = build_decl (BUILTINS_LOCATION, TYPE_DECL,
get_identifier (type->toChars()), rec_type);
Expand Down
25 changes: 14 additions & 11 deletions gcc/d/d-ctype.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ TypeEnum::toCtype (void)

TYPE_PRECISION (ctype) = size (sym->loc) * 8;
TYPE_SIZE (ctype) = 0;
TYPE_MAIN_VARIANT (ctype) = TYPE_MAIN_VARIANT (cmemtype);

if (sym->userAttributes)
decl_attributes (&ctype, build_attributes (sym->userAttributes),
Expand All @@ -247,7 +246,6 @@ TypeEnum::toCtype (void)
layout_type (ctype);
TYPE_UNSIGNED (ctype) = TYPE_UNSIGNED (cmemtype);

// Move this to toDebug() ?
tree enum_values = NULL_TREE;
if (sym->members)
{
Expand All @@ -258,19 +256,24 @@ TypeEnum::toCtype (void)
if (member == NULL)
continue;

char *ident = NULL;
if (sym->ident)
ident = concat (sym->ident->string, ".",
member->ident->string, NULL);
tree ident = get_identifier (member->toPrettyChars());
tree value = build_integer_cst (member->value->toInteger(), cmemtype);

tree tident = get_identifier (ident ? ident : member->ident->string);
tree tvalue = build_integer_cst (member->value->toInteger(), ctype);
enum_values = chainon (enum_values, build_tree_list (tident, tvalue));
// Build a identifier for the enumeration constant.
tree decl = build_decl (UNKNOWN_LOCATION, CONST_DECL, ident, cmemtype);
set_decl_location (decl, member->loc);
DECL_CONTEXT (decl) = ctype;
TREE_CONSTANT (decl) = 1;
TREE_READONLY (decl) = 1;
DECL_INITIAL (decl) = value;

if (sym->ident)
free (ident);
d_pushdecl (decl);

// Add this enumeration constant to the list for this type.
enum_values = chainon (enum_values, build_tree_list (ident, decl));
}
}

TYPE_VALUES (ctype) = enum_values;
build_type_decl (ctype, sym);
}
Expand Down
4 changes: 2 additions & 2 deletions gcc/d/d-objfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ VarDeclaration::toObjFile (int)
IRState *irs = current_irstate;
build_local_var (this, toParent2()->isFuncDeclaration());

if (init != NULL)
if (init)
{
if (!init->isVoidInitializer())
{
Expand Down Expand Up @@ -1814,7 +1814,7 @@ build_type_decl (tree t, Dsymbol *dsym)

gcc_assert (!POINTER_TYPE_P (t));

const char *name = dsym->ident ? dsym->ident->string : "fix";
const char *name = dsym->toPrettyChars();
tree decl = build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier (name), t);

DECL_CONTEXT (decl) = d_decl_context (dsym);
Expand Down

0 comments on commit 021dda8

Please sign in to comment.