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

Commit

Permalink
Set prettyIdent as DECL_NAME earlier.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Feb 15, 2014
1 parent 64b4aa7 commit 79ebb4c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
7 changes: 7 additions & 0 deletions gcc/d/ChangeLog
Expand Up @@ -3,6 +3,13 @@
* d-decls.cc(VarDeclaration::toSymbol): Don't call
setup_symbol_storage until after SET_DECL_ASSEMBLER_NAME has been set.

* d-decls.cc(VarDeclaration::toSymbol): Give prettyIdent precedence
for the DECL_NAME over the simple identifier.
(FuncDeclaration::toSymbol): Likewise.
* d-objfile.cc(d_finish_symbol): Remove setting DECL_NAME as
prettyIdent, this has already been done in Declaration::toSymbol.
(d_finish_function): Likewise.

2014-02-12 Johannes Pfau <johannespfau@gmail.com>

* d-decls.cc(FuncDeclaration::toSymbol): Do not set TREE_NOTHROW on
Expand Down
41 changes: 25 additions & 16 deletions gcc/d/d-decls.cc
Expand Up @@ -120,7 +120,12 @@ VarDeclaration::toSymbol (void)
csym->Sident = ident->string;

tree decl;
tree id = get_identifier (csym->Sident);
tree id;

if (csym->prettyIdent)
id = get_identifier (csym->prettyIdent);
else
id = get_identifier (csym->Sident);

if (isParameter())
{
Expand All @@ -139,12 +144,12 @@ VarDeclaration::toSymbol (void)

if (isDataseg())
{
tree id = get_identifier (csym->Sident);
tree mangle = get_identifier (csym->Sident);

if (protection == PROTpublic || storage_class & (STCstatic | STCextern))
id = targetm.mangle_decl_assembler_name (decl, id);
mangle = targetm.mangle_decl_assembler_name (decl, mangle);

SET_DECL_ASSEMBLER_NAME (decl, id);
SET_DECL_ASSEMBLER_NAME (decl, mangle);
setup_symbol_storage (this, decl, false);
}

Expand Down Expand Up @@ -256,27 +261,33 @@ FuncDeclaration::toSymbol (void)

if (!isym)
{
tree id;
TypeFunction *ftype = (TypeFunction *) (tintro ? tintro : type);
tree fndecl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
NULL_TREE, NULL_TREE);
tree fntype = NULL_TREE;
tree vindex = NULL_TREE;

csym->Stree = fndecl;
tree fndecl;
tree id;

if (ident)
id = get_identifier (ident->string);
{
// Save mangle/debug names for making thunks.
csym->Sident = mangleExact();
csym->prettyIdent = toPrettyChars();
id = get_identifier (csym->prettyIdent);
}
else
{
static unsigned unamed_seq = 0;
char buf[64];
snprintf (buf, sizeof(buf), "___unamed_%u", ++unamed_seq);
id = get_identifier (buf);
}
DECL_NAME (fndecl) = id;

fndecl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, id, NULL_TREE);
DECL_CONTEXT (fndecl) = d_decl_context (this);

csym->Stree = fndecl;

if (needs_static_chain (this))
{
D_DECL_STATIC_CHAIN (fndecl) = 1;
Expand Down Expand Up @@ -329,12 +340,9 @@ FuncDeclaration::toSymbol (void)

if (ident)
{
// Save mangle/debug names for making thunks.
csym->Sident = mangleExact();
csym->prettyIdent = toPrettyChars();
id = get_identifier (csym->Sident);
id = targetm.mangle_decl_assembler_name (fndecl, id);
SET_DECL_ASSEMBLER_NAME (fndecl, id);
tree mangle = get_identifier (csym->Sident);
mangle = targetm.mangle_decl_assembler_name (fndecl, mangle);
SET_DECL_ASSEMBLER_NAME (fndecl, mangle);
}

if (vindex)
Expand Down Expand Up @@ -402,6 +410,7 @@ FuncDeclaration::toSymbol (void)
#endif
set_decl_location (fndecl, this);
setup_symbol_storage (this, fndecl, false);

if (!ident)
TREE_PUBLIC (fndecl) = 0;

Expand Down
11 changes: 0 additions & 11 deletions gcc/d/d-objfile.cc
Expand Up @@ -1846,14 +1846,6 @@ d_finish_symbol (Symbol *sym)
}
#endif

// Our mangled symbol.
if (!DECL_ASSEMBLER_NAME_SET_P (decl) && sym->Sident)
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (sym->Sident));

// DECL_NAME for debugging.
if (sym->prettyIdent)
DECL_NAME (decl) = get_identifier (sym->prettyIdent);

// User declared alignment.
if (sym->Salignment > 0)
{
Expand Down Expand Up @@ -1882,9 +1874,6 @@ d_finish_function (FuncDeclaration *fd)

gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);

if (s->prettyIdent)
DECL_NAME (decl) = get_identifier (s->prettyIdent);

if (DECL_SAVED_TREE (decl) != NULL_TREE)
{
TREE_STATIC (decl) = 1;
Expand Down

0 comments on commit 79ebb4c

Please sign in to comment.